Skip to content

Commit e510bab

Browse files
committed
chore: apply spotless
Signed-off-by: Kengo TODA <[email protected]>
1 parent 7242399 commit e510bab

17 files changed

+506
-451
lines changed

src/main/kotlin/com/github/spotbugs/snom/Confidence.kt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,22 @@ import java.util.Optional
4545
enum class Confidence {
4646
/** The report level to report all detected bugs in the report. */
4747
LOW {
48-
override fun toCommandLineOption(): Optional<String> =
49-
Optional.of("-low")
48+
override fun toCommandLineOption(): Optional<String> = Optional.of("-low")
5049
},
5150

5251
/** The report level to report medium and high priority detected bugs in the report. */
5352
MEDIUM {
54-
override fun toCommandLineOption(): Optional<String> =
55-
Optional.of("-medium")
53+
override fun toCommandLineOption(): Optional<String> = Optional.of("-medium")
5654
},
5755

5856
/** The default level that provides the same feature with {@link #MEDIUM}. */
5957
DEFAULT {
60-
override fun toCommandLineOption(): Optional<String> =
61-
Optional.empty()
58+
override fun toCommandLineOption(): Optional<String> = Optional.empty()
6259
},
6360

6461
/** The report level to report high priority detected bugs in the report. */
6562
HIGH {
66-
override fun toCommandLineOption(): Optional<String> =
67-
Optional.of("-high")
63+
override fun toCommandLineOption(): Optional<String> = Optional.of("-high")
6864
}, ;
6965

7066
@Internal("This is internally used property so no need to refer to judge out-of-date or not.")

src/main/kotlin/com/github/spotbugs/snom/SpotBugsBasePlugin.kt

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import org.gradle.api.reporting.ReportingExtension
2323
import org.gradle.util.GradleVersion
2424
import java.io.IOException
2525
import java.io.UncheckedIOException
26-
import java.util.*
26+
import java.util.Properties
2727
import kotlin.IllegalArgumentException
2828
import kotlin.String
2929
import kotlin.toString
@@ -50,12 +50,13 @@ class SpotBugsBasePlugin : Plugin<Project> {
5050
}
5151

5252
private fun createExtension(project: Project): SpotBugsExtension {
53-
val extension = project
54-
.extensions
55-
.create(
56-
SpotBugsPlugin.EXTENSION_NAME,
57-
SpotBugsExtension::class.java,
58-
)
53+
val extension =
54+
project
55+
.extensions
56+
.create(
57+
SpotBugsPlugin.EXTENSION_NAME,
58+
SpotBugsExtension::class.java,
59+
)
5960
extension.ignoreFailures.convention(false)
6061
extension.showStackTraces.convention(false)
6162
extension.projectName.convention(project.provider { project.name })
@@ -66,9 +67,10 @@ class SpotBugsBasePlugin : Plugin<Project> {
6667
)
6768

6869
// ReportingBasePlugin should be applied before we create this SpotBugsExtension instance
69-
val baseReportsDir = project.extensions.getByType(
70-
ReportingExtension::class.java,
71-
).baseDirectory
70+
val baseReportsDir =
71+
project.extensions.getByType(
72+
ReportingExtension::class.java,
73+
).baseDirectory
7274
extension
7375
.reportsDir
7476
.convention(
@@ -83,15 +85,19 @@ class SpotBugsBasePlugin : Plugin<Project> {
8385
return extension
8486
}
8587

86-
private fun createConfiguration(project: Project, extension: SpotBugsExtension) {
88+
private fun createConfiguration(
89+
project: Project,
90+
extension: SpotBugsExtension,
91+
) {
8792
val props = loadProperties()
8893
extension.toolVersion.convention(props.getProperty("spotbugs-version"))
89-
val configuration = project
90-
.configurations
91-
.create(SpotBugsPlugin.CONFIG_NAME)
92-
.setDescription("configuration for the SpotBugs engine")
93-
.setVisible(false)
94-
.setTransitive(true)
94+
val configuration =
95+
project
96+
.configurations
97+
.create(SpotBugsPlugin.CONFIG_NAME)
98+
.setDescription("configuration for the SpotBugs engine")
99+
.setVisible(false)
100+
.setTransitive(true)
95101
configuration.defaultDependencies { dependencies: DependencySet ->
96102
dependencies.add(
97103
project
@@ -103,12 +109,13 @@ class SpotBugsBasePlugin : Plugin<Project> {
103109
),
104110
)
105111
}
106-
val spotbugsSlf4j = project
107-
.configurations
108-
.create(SpotBugsPlugin.SLF4J_CONFIG_NAME)
109-
.setDescription("configuration for the SLF4J provider to run SpotBugs")
110-
.setVisible(false)
111-
.setTransitive(true)
112+
val spotbugsSlf4j =
113+
project
114+
.configurations
115+
.create(SpotBugsPlugin.SLF4J_CONFIG_NAME)
116+
.setDescription("configuration for the SLF4J provider to run SpotBugs")
117+
.setVisible(false)
118+
.setTransitive(true)
112119
spotbugsSlf4j.defaultDependencies { dependencies: DependencySet ->
113120
dependencies.add(
114121
project
@@ -142,16 +149,21 @@ class SpotBugsBasePlugin : Plugin<Project> {
142149

143150
fun verifyGradleVersion(version: GradleVersion) {
144151
if (version < SUPPORTED_VERSION) {
145-
val message = String.format(
146-
"Gradle version %s is unsupported. Please use %s or later.",
147-
version,
148-
SUPPORTED_VERSION,
149-
)
152+
val message =
153+
String.format(
154+
"Gradle version %s is unsupported. Please use %s or later.",
155+
version,
156+
SUPPORTED_VERSION,
157+
)
150158
throw IllegalArgumentException(message)
151159
}
152160
}
153161

154-
private fun getPropertyOrDefault(project: Project, propertyName: String, defaultValue: String): String {
162+
private fun getPropertyOrDefault(
163+
project: Project,
164+
propertyName: String,
165+
defaultValue: String,
166+
): String {
155167
return if (project.hasProperty(propertyName)) project.property(propertyName).toString() else defaultValue
156168
}
157169

src/main/kotlin/com/github/spotbugs/snom/SpotBugsPlugin.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory
2222

2323
class SpotBugsPlugin : Plugin<Project> {
2424
private val log = LoggerFactory.getLogger(javaClass)
25+
2526
override fun apply(project: Project) {
2627
project.pluginManager.apply(SpotBugsBasePlugin::class.java)
2728
project

src/main/kotlin/com/github/spotbugs/snom/SpotBugsReport.kt

Lines changed: 85 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
package com.github.spotbugs.snom
1515

1616
import groovy.lang.Closure
17-
import org.gradle.api.Action;
17+
import org.gradle.api.Action
1818
import org.gradle.api.file.RegularFileProperty
1919
import org.gradle.api.model.ObjectFactory
2020
import org.gradle.api.provider.Property
@@ -28,103 +28,105 @@ import org.gradle.api.tasks.Internal
2828
import java.io.File
2929
import javax.inject.Inject
3030

31-
abstract class SpotBugsReport @Inject constructor(
32-
objects: ObjectFactory,
33-
@get:Internal
34-
protected val task: SpotBugsTask,
35-
) :
31+
abstract class SpotBugsReport
32+
@Inject
33+
constructor(
34+
objects: ObjectFactory,
35+
@get:Internal
36+
protected val task: SpotBugsTask,
37+
) :
3638
SingleFileReport, CustomizableHtmlReport { // to expose CustomizableHtmlReport#setStylesheet to build script
37-
private val destination: RegularFileProperty
38-
private val isRequired: Property<Boolean>
39+
private val destination: RegularFileProperty
40+
private val isRequired: Property<Boolean>
3941

40-
init {
41-
destination = objects.fileProperty()
42-
isRequired = objects.property(Boolean::class.java).convention(true)
43-
}
44-
45-
abstract fun toCommandLineOption(): String
42+
init {
43+
destination = objects.fileProperty()
44+
isRequired = objects.property(Boolean::class.java).convention(true)
45+
}
4646

47-
@Internal
48-
@Deprecated("use {@link #getOutputLocation()} instead.")
49-
fun getDestination(): File {
50-
return destination.get().asFile
51-
}
47+
abstract fun toCommandLineOption(): String
5248

53-
override fun getOutputLocation(): RegularFileProperty {
54-
return destination
55-
}
49+
@Internal
50+
@Deprecated("use {@link #getOutputLocation()} instead.")
51+
fun getDestination(): File {
52+
return destination.get().asFile
53+
}
5654

57-
@Internal("This property returns always same value")
58-
override fun getOutputType(): Report.OutputType {
59-
return Report.OutputType.FILE
60-
}
55+
override fun getOutputLocation(): RegularFileProperty {
56+
return destination
57+
}
6158

62-
@Input
63-
override fun getRequired(): Property<Boolean> {
64-
return isRequired
65-
}
59+
@Internal("This property returns always same value")
60+
override fun getOutputType(): Report.OutputType {
61+
return Report.OutputType.FILE
62+
}
6663

67-
@get:Deprecated("use {@link #getRequired()} instead.")
68-
@get:Internal
69-
@set:Deprecated("use {@code getRequired().set(value)} instead.")
70-
var isEnabled: Boolean
71-
get() = isRequired.get()
72-
set(b) {
73-
isRequired.set(b)
64+
@Input
65+
override fun getRequired(): Property<Boolean> {
66+
return isRequired
7467
}
7568

76-
@Deprecated("use {@code getRequired().set(provider)} instead.")
77-
fun setEnabled(provider: Provider<Boolean>) {
78-
isRequired.set(provider)
79-
}
69+
@get:Deprecated("use {@link #getRequired()} instead.")
70+
@get:Internal
71+
@set:Deprecated("use {@code getRequired().set(value)} instead.")
72+
var isEnabled: Boolean
73+
get() = isRequired.get()
74+
set(b) {
75+
isRequired.set(b)
76+
}
77+
78+
@Deprecated("use {@code getRequired().set(provider)} instead.")
79+
fun setEnabled(provider: Provider<Boolean>) {
80+
isRequired.set(provider)
81+
}
8082

81-
@Deprecated("use {@code getOutputLocation().set(file)} instead.")
82-
override fun setDestination(file: File) {
83-
destination.set(file)
84-
}
83+
@Deprecated("use {@code getOutputLocation().set(file)} instead.")
84+
override fun setDestination(file: File) {
85+
destination.set(file)
86+
}
8587

86-
@Deprecated("use {@code getOutputLocation().set(provider)} instead.")
87-
fun setDestination(provider: Provider<File?>) {
88-
destination.set(task.project.layout.file(provider))
89-
}
88+
@Deprecated("use {@code getOutputLocation().set(provider)} instead.")
89+
fun setDestination(provider: Provider<File?>) {
90+
destination.set(task.project.layout.file(provider))
91+
}
9092

91-
override fun configure(closure: Closure<in Report>): Report {
92-
return configure { report ->
93-
closure.delegate = report;
94-
closure.call(report);
95-
};
96-
}
93+
override fun configure(closure: Closure<in Report>): Report {
94+
return configure { report ->
95+
closure.delegate = report
96+
closure.call(report)
97+
}
98+
}
9799

98-
fun configure(action: Action<in Report>): Report {
99-
action.execute(this);
100-
return this;
101-
}
100+
fun configure(action: Action<in Report>): Report {
101+
action.execute(this)
102+
return this
103+
}
102104

103-
@Internal("This property provides only a human readable name.")
104-
override fun getDisplayName(): String {
105-
return String.format("%s type report generated by the task %s", name, task.path)
106-
}
105+
@Internal("This property provides only a human readable name.")
106+
override fun getDisplayName(): String {
107+
return String.format("%s type report generated by the task %s", name, task.path)
108+
}
107109

108-
// TODO adding an @Input triggers 'cannot be serialized' exception
109-
override fun getStylesheet(): TextResource? {
110-
return null
111-
}
110+
// TODO adding an @Input triggers 'cannot be serialized' exception
111+
override fun getStylesheet(): TextResource? {
112+
return null
113+
}
112114

113-
override fun setStylesheet(textResource: TextResource?) {
114-
throw UnsupportedOperationException(
115-
String.format(
116-
"stylesheet property is not available in the %s type report",
117-
name,
118-
),
119-
)
120-
}
115+
override fun setStylesheet(textResource: TextResource?) {
116+
throw UnsupportedOperationException(
117+
String.format(
118+
"stylesheet property is not available in the %s type report",
119+
name,
120+
),
121+
)
122+
}
121123

122-
open fun setStylesheet(path: String?) {
123-
throw UnsupportedOperationException(
124-
String.format(
125-
"stylesheet property is not available in the %s type report",
126-
name,
127-
),
128-
)
124+
open fun setStylesheet(path: String?) {
125+
throw UnsupportedOperationException(
126+
String.format(
127+
"stylesheet property is not available in the %s type report",
128+
name,
129+
),
130+
)
131+
}
129132
}
130-
}

0 commit comments

Comments
 (0)