Venkat , Bangalore , India
05/27/2020, 8:52 PMVenkat , Bangalore , India
05/27/2020, 8:53 PMvoben
05/29/2020, 4:49 PMapply plugin: 'io.gitlab.arturbosch.detekt'
detekt {
parallel = true
config = files("$rootDir/codeQuality/detekt.yml")
autoCorrect = true
reports {
xml {
enabled = false
}
txt {
enabled = false
}
}
}
Pamm Sar
06/01/2020, 8:21 AM./gradlew :app:detekt
(or ./gradlew :submodule-name:detekt
) I get the following output:
Task 'detekt' not found in project ':app'. Some candidates are: 'test'.
however if I run just ./gradlew detekt
it runs the task.Javier
06/01/2020, 4:35 PMRodrigo Silva
06/01/2020, 8:16 PMthuytrinh
06/02/2020, 2:34 PMThrowsCount
rule. I have a violated code here:
private fun ensureScanningIsPossible() {
if (!isDiscoveryPermissionGranted) {
throw DiscoveryErrors.DiscoveryPermissionsMissingError(neededDiscoveryPermissions)
} else if (isDiscoveryOngoing) {
throw DiscoveryErrors.DiscoveryAlreadyStarted
} else if (!isBluetoothAvailable()) {
throw DiscoveryErrors.BluetoothDisabledError
} // More to come later...
}
Why is this discouraged? The doc said: “Functions should have clear throw
statements”. How can we achieve a “clear” version? I tried to refactor by using nullable type but I feel a bit skeptical about the new code:
private fun ensureScanningIsPossible() {
val error: DiscoveryErrors? = when {
!isDiscoveryPermissionGranted -> DiscoveryErrors.DiscoveryPermissionsMissingError(neededDiscoveryPermissions)
isDiscoveryOngoing -> DiscoveryErrors.DiscoveryAlreadyStarted
!isBluetoothAvailable() -> DiscoveryErrors.BluetoothDisabledError
else -> null
}
error?.let { throw it }
}
Rodrigo Silva
06/03/2020, 6:41 PMdead.fish
06/12/2020, 8:44 AMVenkat , Bangalore , India
06/15/2020, 12:43 PMsanogueralorenzo
07/02/2020, 4:34 PMpedro
07/04/2020, 3:19 PMExecution failed for task ':foo:detekt'.
> Could not resolve all files for configuration ':foo:detekt'.
> Could not find io.gitlab.arturbosch.detekt:detekt-cli:1.10.0.
Searched in the following locations:
- <https://repo.maven.apache.org/maven2/io/gitlab/arturbosch/detekt/detekt-cli/1.10.0/detekt-cli-1.10.0.pom>
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
I have seen someone mentioning in github issues that it seems that some artifacts weren’t published in all repositories
If I try to use 1.9.1:
> Could not find org.jetbrains.kotlinx:kotlinx-html-jvm:0.7.1.
Searched in the following locations:
- <https://repo.maven.apache.org/maven2/org/jetbrains/kotlinx/kotlinx-html-jvm/0.7.1/kotlinx-html-jvm-0.7.1.pom>
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
Required by:
project :foo > io.gitlab.arturbosch.detekt:detekt-cli:1.9.1
I’ve tried all possible combinations of the instructions in the website and still haven’t got it to work. Can someone help?bbaldino
07/08/2020, 5:23 PMForbiddenMethodCall
to work, I've got it configured like so:
style:
active: true
ForbiddenMethodCall:
active: true
methods: ['java.util.concurrent.ExecutorService.submit', 'kotlin.io.println']
in a custom detekt.yml
(which doesn't contain much else). I'm using the maven plugin and have it pointing to that config file. (I added println
in there to try and test after the first one wasn't working.) It's not triggering for println
calls or ExecutorService.submit
calls. I tried adding another rule and that did work...so maybe I've just got something misconfigured for ForbiddenMethodCall
?nkiesel
07/09/2020, 12:59 AMdetekt-config.yml
in my root directory, and another `detekt-config.yml`in my module directory. To use both, I use detekt { config = files("${project.rootDir}/detekt-config.yml", "detekt-config.yml") }
. Is there a better way which e.g. does not require to repeat the base config file name or perhaps even a mergeConfigs: true
which will automatically merge these? I tried detekt { config += files("detekt-config.yml") }
but that did not work.bbaldino
07/14/2020, 5:01 PMMarco Righini
07/17/2020, 10:53 AMdetekt
block in the gradle file) with a command line gradle task parameter?
I checked the docs but I didn’t find how. I’ve also tried ./gradlew detekt -Pauto-correct=true
and ./gradlew detekt -PautoCorrect=true
along with some other similar commands but none of them worked.Rodrigo Silva
07/19/2020, 4:13 PMdetekt(DetektExtension.() -> Unit): Unit' is deprecated. Either apply detekt plugin to root project
why?
gradle version: 6.5
detekt version: 1.10.dead.fish
07/20/2020, 1:39 PMComplexMethod
only works on single methods, but I’m looking for class and inter-class complexity calculation. Is this even possible with Detekt?Charles
07/29/2020, 2:28 PMdetekt
+ ktlint
I'm used to using the Android Studio shortcuts to format a file to fix basic issues. After attempting to upgrade to 1.10.0
this no longer seems to fix the new Indentation
issue being reported. If a file format command doesn't fix that we can't reasonably upgrade our projects. Any ideas?zmunm
08/05/2020, 3:56 AMObservable.something()
.map {
mutableList.apply {
addAll(list)
}
}
Console says UnnecessaryApply
.. But I need return MutableList
I don't know if this is really wrong. How can I fix it? Thank you for reading..Slackbot
08/07/2020, 9:04 AMorafaaraujo
08/07/2020, 9:04 AMdanger-kotlin_detekt
) read only one file…
Thanks in advancezmunm
08/14/2020, 6:39 AMa?.let { 1.plus(1) } // can be replaced with `if (a == null) 1.plus(1)`
to
a?:let { 1.plus(1) } // can be replaced with `if (a == null) 1.plus(1)`
a?.let { 1.plus(1) } // can be replaced with `if (a != null) 1.plus(1)`
Artur Bosch
08/17/2020, 3:50 PMJukka Siivonen
08/18/2020, 9:25 AMsanogueralorenzo
08/25/2020, 11:52 PMjava -jar config/detekt/detekt-cli-1.12.0-all.jar --build-upon-default-config --includes "**/src/main/**/*.kt" -p config/detekt/detekt-formatting-1.12.0.jar --auto-correct --baseline "config/detekt/baseline.yml" --parallel
Adam
08/26/2020, 1:15 PMParameterListWrapping
in 1.12.0 that look either questionable or wrong. Avoiding upgrading for now, rather than disabling the rule. A couple of examples:
Questionable. Fails with Argument should be on a separate line (unless all arguments can fit a single line)
and Missing newline before ")"
.
foo(bar.apply {
// stuff
})
Wrong? Fails function(arg1, arg2, arg3)
with Argument should be on a separate line (unless all arguments can fit a single line)
.
json(
"""
{
"array": [
${function(arg1, arg2, arg3)}
]
}
""".trimIndent()
)
Related to this ktlint PR?Javier
09/02/2020, 8:54 AMsanogueralorenzo
09/09/2020, 12:12 PM-input
only on changed files) and also to avoid the gradle overhead/plugin
# Get kotlin changed files
changedFiles=$(git --no-pager diff --diff-filter=d --name-only HEAD | grep '\.kt[s"]\?$')
if [ -n "$changedFiles" ]; then
# `paste -sd "," -` replaces newlines with commas so detekt cli -i parameter can take it
java -jar config/detekt/detekt-cli-1.11.2-all.jar --build-upon-default-config --config "config/detekt/detekt.yml" --baseline "config/detekt/baseline.xml" -p config/detekt/detekt-formatting-1.11.2.jar --auto-correct -i "$( printf "%s" "$changedFiles" | paste -sd "," - )"
if [ $? -ne 0 ]; then
echo "***********************************************"
echo " Detekt failed "
echo " Please fix the above issues before committing "
echo "***********************************************"
exit 1
fi
fi
The above takes around 2 seconds and it is working properly from the tests I've been doing
My main issue is that from java -jar
to --auto-correct
is something I already have in my top level detekt task and my top level detekt baseline task (and I wouldn't want to have all that script line repeated in several files since you will have to remember to update all of them when updating version.
Is there any way to reuse that part?
Thanks! 🙏kenkyee
09/09/2020, 11:07 PM