mirror of
https://github.com/jlengrand/detekt.git
synced 2026-03-10 08:11:23 +00:00
Support Kotlin 1.4 (#2981)
* Update to Gradle 6.6 * Update to Kotlin 1.4 * Upgrade to prerelease of KtLint 0.38 * Fix testcase by unwrapping the original descriptor * Increase max heap for dokka on Java 11 * Update minimal supported Gradle version to 5.3 * Do not run warningsAsErrors on CI due to Gradle not supporting Kotlin 1.4 * Remove new line testing as it fails on windows * Require Gradle 5.4 to reflect Kotlin's required version from their website
This commit is contained in:
2
.github/workflows/deploy-snapshot.yaml
vendored
2
.github/workflows/deploy-snapshot.yaml
vendored
@@ -31,7 +31,7 @@ jobs:
|
|||||||
java-version: 8
|
java-version: 8
|
||||||
|
|
||||||
- name: Build detekt
|
- name: Build detekt
|
||||||
run: ./gradlew build --build-cache --parallel -PwarningsAsErrors=true
|
run: ./gradlew build --build-cache --parallel
|
||||||
|
|
||||||
- name: Deploy Snapshot
|
- name: Deploy Snapshot
|
||||||
env:
|
env:
|
||||||
|
|||||||
2
.github/workflows/pre-merge.yaml
vendored
2
.github/workflows/pre-merge.yaml
vendored
@@ -53,7 +53,7 @@ jobs:
|
|||||||
|
|
||||||
|
|
||||||
- name: Build detekt
|
- name: Build detekt
|
||||||
run: ./gradlew build :detekt-cli:shadowJarExecutable -PwarningsAsErrors=true --parallel
|
run: ./gradlew build :detekt-cli:shadowJarExecutable --parallel
|
||||||
- name: Run detekt-cli --help
|
- name: Run detekt-cli --help
|
||||||
run: java -jar ./detekt-cli/build/run/detekt --help
|
run: java -jar ./detekt-cli/build/run/detekt --help
|
||||||
- name: Run detekt-cli with argsfile
|
- name: Run detekt-cli with argsfile
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ You can find [other ways to install detekt here](https://detekt.github.io/detekt
|
|||||||
|
|
||||||
#### with Gradle
|
#### with Gradle
|
||||||
|
|
||||||
Gradle 5.0+ is required:
|
Gradle 5.4+ is required:
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
buildscript {
|
buildscript {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
object Plugins {
|
object Plugins {
|
||||||
const val KOTLIN = "1.3.72"
|
const val KOTLIN = "1.4.0"
|
||||||
const val DETEKT = "1.11.2"
|
const val DETEKT = "1.11.2"
|
||||||
const val GITHUB_RELEASE = "2.2.12"
|
const val GITHUB_RELEASE = "2.2.12"
|
||||||
const val ARTIFACTORY = "4.15.1"
|
const val ARTIFACTORY = "4.15.1"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ plugins {
|
|||||||
val analysisDir = file(projectDir)
|
val analysisDir = file(projectDir)
|
||||||
val baselineFile = file("$rootDir/config/detekt/baseline.xml")
|
val baselineFile = file("$rootDir/config/detekt/baseline.xml")
|
||||||
val configFile = file("$rootDir/config/detekt/detekt.yml")
|
val configFile = file("$rootDir/config/detekt/detekt.yml")
|
||||||
val formatConfigFile = file("$rootDir/config/detekt/format.yml")
|
|
||||||
val statisticsConfigFile = file("$rootDir/config/detekt/statistics.yml")
|
val statisticsConfigFile = file("$rootDir/config/detekt/statistics.yml")
|
||||||
|
|
||||||
val kotlinFiles = "**/*.kt"
|
val kotlinFiles = "**/*.kt"
|
||||||
@@ -53,7 +52,7 @@ val detektFormat by tasks.registering(Detekt::class) {
|
|||||||
buildUponDefaultConfig = true
|
buildUponDefaultConfig = true
|
||||||
autoCorrect = true
|
autoCorrect = true
|
||||||
setSource(analysisDir)
|
setSource(analysisDir)
|
||||||
config.setFrom(listOf(statisticsConfigFile, formatConfigFile))
|
config.setFrom(listOf(statisticsConfigFile, configFile))
|
||||||
include(kotlinFiles)
|
include(kotlinFiles)
|
||||||
include(kotlinScriptFiles)
|
include(kotlinScriptFiles)
|
||||||
exclude(resourceFiles)
|
exclude(resourceFiles)
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ formatting:
|
|||||||
autoCorrect: true
|
autoCorrect: true
|
||||||
MaximumLineLength:
|
MaximumLineLength:
|
||||||
active: false
|
active: false
|
||||||
|
ParameterListWrapping:
|
||||||
|
active: false
|
||||||
|
|
||||||
naming:
|
naming:
|
||||||
MemberNameEqualsClassName:
|
MemberNameEqualsClassName:
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
formatting:
|
|
||||||
active: true
|
|
||||||
android: false
|
|
||||||
autoCorrect: true
|
|
||||||
MaximumLineLength:
|
|
||||||
active: false
|
|
||||||
@@ -5,7 +5,7 @@ plugins {
|
|||||||
dependencies {
|
dependencies {
|
||||||
val version = object {
|
val version = object {
|
||||||
val spek = "2.0.13-alpha.0.3+3b5f071"
|
val spek = "2.0.13-alpha.0.3+3b5f071"
|
||||||
val ktlint = "0.37.2"
|
val ktlint = "0.38.0-alpha01"
|
||||||
}
|
}
|
||||||
|
|
||||||
constraints {
|
constraints {
|
||||||
|
|||||||
@@ -22,6 +22,6 @@ class DetektProgressListener : FileProcessListener {
|
|||||||
|
|
||||||
override fun onFinish(files: List<KtFile>, result: Detektion) {
|
override fun onFinish(files: List<KtFile>, result: Detektion) {
|
||||||
val middlePart = if (files.size == 1) "file was" else "files were"
|
val middlePart = if (files.size == 1) "file was" else "files were"
|
||||||
outPrinter.appendln("\n\n${files.size} kotlin $middlePart analyzed.")
|
outPrinter.appendLine("\n\n${files.size} kotlin $middlePart analyzed.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,14 +34,14 @@ private fun CliArgs.validate(jCommander: JCommander) {
|
|||||||
val violations = StringBuilder()
|
val violations = StringBuilder()
|
||||||
|
|
||||||
if (createBaseline && baseline == null) {
|
if (createBaseline && baseline == null) {
|
||||||
violations.appendln("Creating a baseline.xml requires the --baseline parameter to specify a path.")
|
violations.appendLine("Creating a baseline.xml requires the --baseline parameter to specify a path.")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!createBaseline && baseline != null) {
|
if (!createBaseline && baseline != null) {
|
||||||
if (Files.notExists(checkNotNull(baseline))) {
|
if (Files.notExists(checkNotNull(baseline))) {
|
||||||
violations.appendln("The file specified by --baseline should exist '$baseline'.")
|
violations.appendLine("The file specified by --baseline should exist '$baseline'.")
|
||||||
} else if (!Files.isRegularFile(checkNotNull(baseline))) {
|
} else if (!Files.isRegularFile(checkNotNull(baseline))) {
|
||||||
violations.appendln("The path specified by --baseline should be a file '$baseline'.")
|
violations.appendLine("The path specified by --baseline should be a file '$baseline'.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,6 @@ class AstPrinter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val ktFile = KtCompiler().compile(input, input)
|
val ktFile = KtCompiler().compile(input, input)
|
||||||
outPrinter.appendln(ElementPrinter.dump(ktFile))
|
outPrinter.appendLine(ElementPrinter.dump(ktFile))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,6 @@ class ConfigExporter(
|
|||||||
override fun execute() {
|
override fun execute() {
|
||||||
val configPath = Paths.get(arguments.config ?: "detekt.yml")
|
val configPath = Paths.get(arguments.config ?: "detekt.yml")
|
||||||
DefaultConfigurationProvider.load().copy(configPath)
|
DefaultConfigurationProvider.load().copy(configPath)
|
||||||
outputPrinter.appendln("Successfully copied default config to ${configPath.toAbsolutePath()}")
|
outputPrinter.appendLine("Successfully copied default config to ${configPath.toAbsolutePath()}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class ElementPrinter : DetektVisitor() {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun dump(file: KtFile): String = ElementPrinter().run {
|
fun dump(file: KtFile): String = ElementPrinter().run {
|
||||||
sb.appendln("0: " + file.javaClass.simpleName)
|
sb.appendLine("0: " + file.javaClass.simpleName)
|
||||||
visitKtFile(file)
|
visitKtFile(file)
|
||||||
sb.toString()
|
sb.toString()
|
||||||
}
|
}
|
||||||
@@ -39,14 +39,14 @@ class ElementPrinter : DetektVisitor() {
|
|||||||
val currentLine = element.line
|
val currentLine = element.line
|
||||||
if (element.isContainer()) {
|
if (element.isContainer()) {
|
||||||
indent++
|
indent++
|
||||||
sb.appendln(element.dump)
|
sb.appendLine(element.dump)
|
||||||
} else {
|
} else {
|
||||||
if (lastLine == currentLine) {
|
if (lastLine == currentLine) {
|
||||||
indent++
|
indent++
|
||||||
sb.appendln(element.dump)
|
sb.appendLine(element.dump)
|
||||||
indent--
|
indent--
|
||||||
} else {
|
} else {
|
||||||
sb.appendln(element.dump)
|
sb.appendLine(element.dump)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastLine = currentLine
|
lastLine = currentLine
|
||||||
|
|||||||
@@ -5,6 +5,6 @@ import io.github.detekt.tooling.api.VersionProvider
|
|||||||
class VersionPrinter(private val outputPrinter: Appendable) : Executable {
|
class VersionPrinter(private val outputPrinter: Appendable) : Executable {
|
||||||
|
|
||||||
override fun execute() {
|
override fun execute() {
|
||||||
outputPrinter.appendln(VersionProvider.load().current())
|
outputPrinter.appendLine(VersionProvider.load().current())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,18 +3,14 @@ package io.gitlab.arturbosch.detekt.cli.runners
|
|||||||
import io.github.detekt.test.utils.StringPrintStream
|
import io.github.detekt.test.utils.StringPrintStream
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
import org.spekframework.spek2.Spek
|
import org.spekframework.spek2.Spek
|
||||||
import org.spekframework.spek2.style.specification.describe
|
|
||||||
|
|
||||||
class VersionPrinterSpec : Spek({
|
class VersionPrinterSpec : Spek({
|
||||||
|
|
||||||
describe("version printer") {
|
test("prints the version") {
|
||||||
|
val printStream = StringPrintStream()
|
||||||
|
|
||||||
it("prints the version") {
|
VersionPrinter(printStream).execute()
|
||||||
val printStream = StringPrintStream()
|
|
||||||
|
|
||||||
VersionPrinter(printStream).execute()
|
assertThat(printStream.toString()).contains("1.6.0")
|
||||||
|
|
||||||
assertThat(printStream.toString()).isEqualTo("1.6.0" + System.lineSeparator())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package io.gitlab.arturbosch.detekt.core
|
package io.gitlab.arturbosch.detekt.core
|
||||||
|
|
||||||
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
|
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
|
||||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
|
|
||||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||||
|
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation
|
||||||
import org.jetbrains.kotlin.cli.common.messages.PlainTextMessageRenderer
|
import org.jetbrains.kotlin.cli.common.messages.PlainTextMessageRenderer
|
||||||
import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector
|
import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||||
@@ -16,7 +16,7 @@ import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProvid
|
|||||||
internal fun generateBindingContext(
|
internal fun generateBindingContext(
|
||||||
environment: KotlinCoreEnvironment,
|
environment: KotlinCoreEnvironment,
|
||||||
classpath: List<String>,
|
classpath: List<String>,
|
||||||
files: List<KtFile>
|
files: List<KtFile>,
|
||||||
): BindingContext {
|
): BindingContext {
|
||||||
if (classpath.isEmpty()) {
|
if (classpath.isEmpty()) {
|
||||||
return BindingContext.EMPTY
|
return BindingContext.EMPTY
|
||||||
@@ -38,11 +38,11 @@ internal fun generateBindingContext(
|
|||||||
|
|
||||||
private object DetektMessageRenderer : PlainTextMessageRenderer() {
|
private object DetektMessageRenderer : PlainTextMessageRenderer() {
|
||||||
override fun getName() = "detekt message renderer"
|
override fun getName() = "detekt message renderer"
|
||||||
override fun getPath(location: CompilerMessageLocation) = location.path
|
override fun getPath(location: CompilerMessageSourceLocation) = location.path
|
||||||
override fun render(
|
override fun render(
|
||||||
severity: CompilerMessageSeverity,
|
severity: CompilerMessageSeverity,
|
||||||
message: String,
|
message: String,
|
||||||
location: CompilerMessageLocation?
|
location: CompilerMessageSourceLocation?,
|
||||||
): String {
|
): String {
|
||||||
if (!severity.isError) return ""
|
if (!severity.isError) return ""
|
||||||
return super.render(severity, message, location)
|
return super.render(severity, message, location)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class OutputFacade(
|
|||||||
for (extension in extensions) {
|
for (extension in extensions) {
|
||||||
val output = extension.render(result)
|
val output = extension.render(result)
|
||||||
if (!output.isNullOrBlank()) {
|
if (!output.isNullOrBlank()) {
|
||||||
settings.outputChannel.appendln(output)
|
settings.outputChannel.appendLine(output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ internal fun Throwable.printStacktraceRecursively(logger: Appendable) {
|
|||||||
is PrintStream -> this.printStackTrace(logger)
|
is PrintStream -> this.printStackTrace(logger)
|
||||||
is PrintWriter -> this.printStackTrace(logger)
|
is PrintWriter -> this.printStackTrace(logger)
|
||||||
else -> {
|
else -> {
|
||||||
stackTrace.forEach { logger.appendln(it.toString()) }
|
stackTrace.forEach { logger.appendLine(it.toString()) }
|
||||||
cause?.printStacktraceRecursively(logger)
|
cause?.printStacktraceRecursively(logger)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,17 +33,17 @@ internal class LoggingFacade(
|
|||||||
override val errorChannel: Appendable = spec.errorChannel
|
override val errorChannel: Appendable = spec.errorChannel
|
||||||
|
|
||||||
override fun info(msg: String) {
|
override fun info(msg: String) {
|
||||||
outputChannel.appendln(msg)
|
outputChannel.appendLine(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun error(msg: String, error: Throwable) {
|
override fun error(msg: String, error: Throwable) {
|
||||||
errorChannel.appendln(msg)
|
errorChannel.appendLine(msg)
|
||||||
error.printStacktraceRecursively(errorChannel)
|
error.printStacktraceRecursively(errorChannel)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun debug(msg: () -> String) {
|
override fun debug(msg: () -> String) {
|
||||||
if (spec.debug) {
|
if (spec.debug) {
|
||||||
outputChannel.appendln(msg())
|
outputChannel.appendLine(msg())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import io.github.detekt.test.utils.StringPrintStream
|
|||||||
import io.github.detekt.test.utils.createTempFileForTest
|
import io.github.detekt.test.utils.createTempFileForTest
|
||||||
import io.github.detekt.test.utils.resourceAsPath
|
import io.github.detekt.test.utils.resourceAsPath
|
||||||
import io.gitlab.arturbosch.detekt.core.DetektResult
|
import io.gitlab.arturbosch.detekt.core.DetektResult
|
||||||
import io.gitlab.arturbosch.detekt.core.NL
|
|
||||||
import io.gitlab.arturbosch.detekt.core.createNullLoggingSpec
|
import io.gitlab.arturbosch.detekt.core.createNullLoggingSpec
|
||||||
import io.gitlab.arturbosch.detekt.core.tooling.withSettings
|
import io.gitlab.arturbosch.detekt.core.tooling.withSettings
|
||||||
import io.gitlab.arturbosch.detekt.test.createFinding
|
import io.gitlab.arturbosch.detekt.test.createFinding
|
||||||
@@ -42,9 +41,9 @@ internal class OutputFacadeSpec : Spek({
|
|||||||
spec.withSettings { OutputFacade(this).run(defaultResult) }
|
spec.withSettings { OutputFacade(this).run(defaultResult) }
|
||||||
|
|
||||||
assertThat(printStream.toString()).contains(
|
assertThat(printStream.toString()).contains(
|
||||||
"Successfully generated ${TxtOutputReport().name} at $plainOutputPath$NL",
|
"Successfully generated ${TxtOutputReport().name} at $plainOutputPath",
|
||||||
"Successfully generated ${XmlOutputReport().name} at $xmlOutputPath$NL",
|
"Successfully generated ${XmlOutputReport().name} at $xmlOutputPath",
|
||||||
"Successfully generated ${HtmlOutputReport().name} at $htmlOutputPath$NL"
|
"Successfully generated ${HtmlOutputReport().name} at $htmlOutputPath"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ object MultiVersionTest : Spek({
|
|||||||
|
|
||||||
private fun getGradleVersionsUnderTest() =
|
private fun getGradleVersionsUnderTest() =
|
||||||
if (getJdkVersion() < 13) {
|
if (getJdkVersion() < 13) {
|
||||||
listOf("5.0", "6.4.1")
|
listOf("5.4", "6.6")
|
||||||
} else {
|
} else {
|
||||||
listOf("6.4.1")
|
listOf("6.6")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getJdkVersion(): Int {
|
private fun getJdkVersion(): Int {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api(kotlin("compiler-embeddable"))
|
api(kotlin("compiler-embeddable"))
|
||||||
implementation(project(":detekt-psi-utils"))
|
implementation(project(":detekt-psi-utils"))
|
||||||
@@ -5,7 +7,7 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<Test> {
|
tasks.withType<Test> {
|
||||||
systemProperty("kotlinVersion", embeddedKotlinVersion)
|
systemProperty("kotlinVersion", getKotlinPluginVersion() ?: embeddedKotlinVersion)
|
||||||
|
|
||||||
doFirst {
|
doFirst {
|
||||||
systemProperty("testClasspath", classpath.joinToString(";"))
|
systemProperty("testClasspath", classpath.joinToString(";"))
|
||||||
|
|||||||
@@ -54,9 +54,9 @@ class UnusedPrivateMember(config: Config = Config.empty) : Rule(config) {
|
|||||||
override val defaultRuleIdAliases: Set<String> = setOf("UNUSED_VARIABLE", "UNUSED_PARAMETER", "unused")
|
override val defaultRuleIdAliases: Set<String> = setOf("UNUSED_VARIABLE", "UNUSED_PARAMETER", "unused")
|
||||||
|
|
||||||
override val issue: Issue = Issue("UnusedPrivateMember",
|
override val issue: Issue = Issue("UnusedPrivateMember",
|
||||||
Severity.Maintainability,
|
Severity.Maintainability,
|
||||||
"Private member is unused.",
|
"Private member is unused.",
|
||||||
Debt.FIVE_MINS)
|
Debt.FIVE_MINS)
|
||||||
|
|
||||||
private val allowedNames by LazyRegex(ALLOWED_NAMES_PATTERN, "(_|ignored|expected|serialVersionUID)")
|
private val allowedNames by LazyRegex(ALLOWED_NAMES_PATTERN, "(_|ignored|expected|serialVersionUID)")
|
||||||
|
|
||||||
@@ -99,11 +99,11 @@ private class UnusedFunctionVisitor(
|
|||||||
} else {
|
} else {
|
||||||
emptyList()
|
emptyList()
|
||||||
}
|
}
|
||||||
val referenceDescriptors = (references + referencesViaOperator).mapNotNull {
|
val referenceDescriptors = (references + referencesViaOperator)
|
||||||
it.getResolvedCall(bindingContext)?.resultingDescriptor
|
.mapNotNull { it.getResolvedCall(bindingContext)?.resultingDescriptor }
|
||||||
}
|
.map { it.original }
|
||||||
functions.filter {
|
functions.filterNot {
|
||||||
bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, it] !in referenceDescriptors
|
bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, it] in referenceDescriptors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
references.isEmpty() -> functions
|
references.isEmpty() -> functions
|
||||||
@@ -204,7 +204,7 @@ private class UnusedParameterVisitor(allowedNames: Regex) : UnusedMemberVisitor(
|
|||||||
private fun KtNamedFunction.isRelevant() = !isAllowedToHaveUnusedParameters()
|
private fun KtNamedFunction.isRelevant() = !isAllowedToHaveUnusedParameters()
|
||||||
|
|
||||||
private fun KtNamedFunction.isAllowedToHaveUnusedParameters() =
|
private fun KtNamedFunction.isAllowedToHaveUnusedParameters() =
|
||||||
isAbstract() || isOpen() || isOverride() || isOperator() || isMainFunction() || isExternal() || isExpect()
|
isAbstract() || isOpen() || isOverride() || isOperator() || isMainFunction() || isExternal() || isExpect()
|
||||||
}
|
}
|
||||||
|
|
||||||
private class UnusedPropertyVisitor(allowedNames: Regex) : UnusedMemberVisitor(allowedNames) {
|
private class UnusedPropertyVisitor(allowedNames: Regex) : UnusedMemberVisitor(allowedNames) {
|
||||||
@@ -214,9 +214,11 @@ private class UnusedPropertyVisitor(allowedNames: Regex) : UnusedMemberVisitor(a
|
|||||||
|
|
||||||
override fun getUnusedReports(issue: Issue): List<CodeSmell> {
|
override fun getUnusedReports(issue: Issue): List<CodeSmell> {
|
||||||
return properties
|
return properties
|
||||||
.filter { it.nameAsSafeName.identifier !in nameAccesses }
|
.filter { it.nameAsSafeName.identifier !in nameAccesses }
|
||||||
.map { CodeSmell(issue, Entity.from(it),
|
.map {
|
||||||
"Private property ${it.nameAsSafeName.identifier} is unused.") }
|
CodeSmell(issue, Entity.from(it),
|
||||||
|
"Private property ${it.nameAsSafeName.identifier} is unused.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitParameter(parameter: KtParameter) {
|
override fun visitParameter(parameter: KtParameter) {
|
||||||
@@ -236,8 +238,8 @@ private class UnusedPropertyVisitor(allowedNames: Regex) : UnusedMemberVisitor(a
|
|||||||
override fun visitPrimaryConstructor(constructor: KtPrimaryConstructor) {
|
override fun visitPrimaryConstructor(constructor: KtPrimaryConstructor) {
|
||||||
super.visitPrimaryConstructor(constructor)
|
super.visitPrimaryConstructor(constructor)
|
||||||
constructor.valueParameters
|
constructor.valueParameters
|
||||||
.filter { (it.isPrivate() || !it.hasValOrVar()) && it.containingClassOrObject?.isExpect() == false }
|
.filter { (it.isPrivate() || !it.hasValOrVar()) && it.containingClassOrObject?.isExpect() == false }
|
||||||
.forEach { maybeAddUnusedProperty(it) }
|
.forEach { maybeAddUnusedProperty(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitSecondaryConstructor(constructor: KtSecondaryConstructor) {
|
override fun visitSecondaryConstructor(constructor: KtSecondaryConstructor) {
|
||||||
|
|||||||
@@ -1157,7 +1157,7 @@ class UnusedPrivateMemberSpec : Spek({
|
|||||||
"""
|
"""
|
||||||
val findings = subject.compileAndLintWithContext(env, code)
|
val findings = subject.compileAndLintWithContext(env, code)
|
||||||
assertThat(findings).hasSize(1).hasSourceLocations(
|
assertThat(findings).hasSize(1).hasSourceLocations(
|
||||||
SourceLocation(3,5)
|
SourceLocation(3, 5)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ redirect_from:
|
|||||||
summary:
|
summary:
|
||||||
---
|
---
|
||||||
|
|
||||||
detekt requires Gradle 5.0 or higher.
|
detekt requires Gradle 5.4 or higher.
|
||||||
|
|
||||||
#### <a name="tasks">Available plugin tasks</a>
|
#### <a name="tasks">Available plugin tasks</a>
|
||||||
|
|
||||||
|
|||||||
@@ -4,5 +4,7 @@ systemProp.file.encoding=UTF-8
|
|||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
org.gradle.workers.max=4
|
org.gradle.workers.max=4
|
||||||
org.gradle.caching=true
|
org.gradle.caching=true
|
||||||
|
# increase max heap for dokka on Java 11
|
||||||
|
org.gradle.jvmargs=-Xmx1024m
|
||||||
# Needed for https://github.com/gradle/gradle/issues/11412
|
# Needed for https://github.com/gradle/gradle/issues/11412
|
||||||
systemProp.org.gradle.internal.publish.checksums.insecure=true
|
systemProp.org.gradle.internal.publish.checksums.insecure=true
|
||||||
|
|||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-all.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
21
gradlew.bat
vendored
21
gradlew.bat
vendored
@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto init
|
if "%ERRORLEVEL%" == "0" goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
@@ -54,7 +54,7 @@ goto fail
|
|||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto init
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
@@ -64,21 +64,6 @@ echo location of your Java installation.
|
|||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:init
|
|
||||||
@rem Get command-line arguments, handling Windows variants
|
|
||||||
|
|
||||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
|
||||||
|
|
||||||
:win9xME_args
|
|
||||||
@rem Slurp the command line arguments.
|
|
||||||
set CMD_LINE_ARGS=
|
|
||||||
set _SKIP=2
|
|
||||||
|
|
||||||
:win9xME_args_slurp
|
|
||||||
if "x%~1" == "x" goto execute
|
|
||||||
|
|
||||||
set CMD_LINE_ARGS=%*
|
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
@@ -86,7 +71,7 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
|||||||
Reference in New Issue
Block a user