-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document correct Report generate Gradle Kotlin configuration, and small questions #7
Comments
Yeah, all the samples for the build file are in groovy except one for how to use with kotlin and only there I used kotlin script. The way to configure plugins in kotlin script is quite different. Regarding the report, right now it isn't configurable what to include. |
Yeah, hopefully someone will find the time to add that configuration parameter, as increasing minimum level seems like quite an important use-case. I added PR with the documentation, also added
tasks.sonarlintTest {
ignoreFailures = false
}
Also with this configuration, (Also, I'm curious why the default report file is |
Hi With kotlin DSL (build.gradle.kts) the so called extension (i.e. sonarlint {}) doesn't work. ReportsDir will be used if you don't explicitly set the report file per report type. I must say I haven't tested kotlin DSL that much. But in groovy you can just add:
If you have many projects you want to configure the I suggest that you do a "convention" plugin that all of your projects depends on. I have my own here: https://github.com/Lucas3oo/solrike-conventions-gradle-plugin I think most developer would like to have two reports; one for the "real" source code and one for tests code. SonarLint test different things also depending on main or test code. E.g SonarLint check if all your test cases have at least one assert. That check would be pointless for main code. |
I was wrong , extension works it is just some other syntax that must be used. |
Oh, my bad, the I guess it makes sense that we'll need to duplicate the configuration if we also want tests to be tested, it gets verbose though, one combined report for the build is often enough. Also, when you run Also, I tested reports without any |
:-) I actually tested on one of my kotlin projects and I didn't get the report generated. So there are some funny things going around here. I will investigate. If you do not want to break the build you can set "ignoreFailures = true". The purpose of that is your use case actually. |
Seems like when enabling reports on the "extensions" it doesn't work but setting directly on the task then it works. In Kotlin DSL this works:
|
docs: add kotlin syntax to sonarlint config of java project, fix #7
I have a lot of javadoc so not sure why it can't be seen in IntelliJ. |
I'm curious if you've been able to find a way to also write the Plus I've noticed that a syntax like
|
Yeah, I update the readme with more accurate kotlin code. And the sonarlint {} shall work in kolin DSL too. I have some unit tests for that actually. Normally in Kotlin DSL you need to do sorting like this for lists: |
I just released a new version where the report section for sonarlnt {} works. |
Oh, I'd swear that Btw. if I use |
Yup, I am pretty sure I didn't ge the extension to work in Kotlin DLS before too. And I am sing the same version of Gradle too. The outputLocation shall be configured per task and not in the extension, otherwise it will overwrite. The "config" in the extension is used as default in the tasks (regardless of main, test, node or testFixture). Yeah, I looked a lot on the spot bugs plugin when I made this plugin. Gradles own plugins in this area like Checkstyle are all cheating and are using internal API of Gradle. |
Documentation should be updated.
On page https://github.com/Lucas3oo/sonarlint-gradle-plugin?tab=readme-ov-file#sonarlint-ci-reports there is an example:
It doesn't work with Gradle 8.9 when using Kotlin syntax, i.e. file
build.gradle.kts
. I made it work as follows:(Note:
tasks.sonarlintMain<se.solrike.sonarlint.Sonarlint>
also works.)Also, I'd like to ask how is it possible to change the minimum level in failures/reports. For example, I want
Major️
andMinor
but notInfo
. Can this be documented?The text was updated successfully, but these errors were encountered: