sonar-checkstyle
sonar-checkstyle copied to clipboard
Resolve violations from sonarcloud.io
https://sonarcloud.io/dashboard?id=checkstyle_sonar-checkstyle
lets try to resolve all violations in our code, if reasonable.
I started looking through them and found those issues to be discussed:
-
CheckstyleRulesDefinition::extractRulesData -> uses deprecated (and without provided alternative) classes from
sslr-squid-bridge
to load the HTML and SQALE model- HTML loading is not a problem; we can kinda migrate the code as it's simple and short
- SQALE seems to not be used anymore by
sslr-squid-bridge
(see: https://github.com/SonarSource/sslr-squid-bridge/blob/master/src/main/java/org/sonar/squidbridge/rules/SqaleXmlLoader.java#L42); hence, we can migrate the code or use any alternative? I don't use SQALE myself - any ideas?
-
RuleFinder
is not deprecated; only marked deprecated wrongly in our used API version - we investigated this issue before already -
violation. To remove https://sonarcloud.io/code?id=checkstyle_sonar-checkstyle&line=114&selected=checkstyle_sonar-checkstyle%3Asrc%2Fmain%2Fjava%2Forg%2Fsonar%2Fplugins%2Fcheckstyle%2FCheckstyleExecutor.java we would need to perform some refactoring since
file()
is deprecated without replacement - we have a lot of usage of
RulePriority
but Sonar still uses that one - we discussed it earlier as well; once Sonar replaces their return values we can solve this - I actually don't know if it's wise to change this one: https://sonarcloud.io/code?id=checkstyle_sonar-checkstyle&line=55&selected=checkstyle_sonar-checkstyle%3Asrc%2Fmain%2Fjava%2Forg%2Fsonar%2Fplugins%2Fcheckstyle%2FCheckstyleExecutor.java
For the other issues, it's quite straight forward to resolve them.
For the other issues, it's quite straight forward to resolve them.
please do. the less violations the better. No need to fix the all in one PR, even 1 violation in separate PR is ok. Continuous improvements ...
CheckstyleRulesDefinition::extractRulesData -> uses deprecated (and without provided alternative)
I see clear meassage in javadoc that plugin need to host this functionality in their own code. https://github.com/SonarSource/sslr-squid-bridge/blob/master/src/main/java/org/sonar/squidbridge/rules/ExternalDescriptionLoader.java#L33 Lets just copy such files to us.
RuleFinder is not deprecated; only marked deprecated wrongly in our used API version - we investigated this issue before already
I do not see deprecation in latest code https://github.com/SonarSource/sonarqube/blob/master/sonar-plugin-api/src/main/java/org/sonar/api/rules/RuleFinder.java should be upgrade to new version ?
file() is deprecated without replacement
I see suggestion on what to use instead - https://github.com/SonarSource/sonarqube/blob/master/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/InputFile.java#L91
we have a lot of usage of RulePriority but Sonar still uses that one
https://github.com/SonarSource/sonarqube/blob/master/sonar-plugin-api/src/main/java/org/sonar/api/rules/RulePriority.java#L30 Please open issue on them to let when describe what is better way to define this.
I actually don't know if it's wise to change this one
It is false positive for sure, but ... according to
https://jira.sonarsource.com/browse/RSPEC-1075 we probably can remove leading "/" and pass validation.
Or according to https://github.com/SonarSource/sonar-dotnet/pull/556/files#diff-4682fc1f8b2440f08cbc43fa1a536fa0R56 , name variable as xxxxLocation
and pass :).
I created issues for:
-
RulePriority
: #220 - the SQALE model: #219
Working on the others.
@romani Is it possible to put sonar as part of CI so we can see violations are fixed and won't come back?
Yes, they do have PR processing now, but I didn't have time to set up it. There is still problem to set up custom gate, suppression, rules. it will require extra scripting to make it prevents new issue to appear.
No spacial scripting is required now, now sonarqube is completely customizable. We just need to resolve or mark as won't fix all issues
https://github.com/checkstyle/sonar-checkstyle/blob/master/src/main/resources/org/sonar/plugins/checkstyle/rules.xml#L77
this i the only major violations that is left - https://sonarcloud.io/project/issues?id=checkstyle_sonar-checkstyle&open=AWpuVgQeyRjJygCrGbZ-&resolved=false&severities=MAJOR
Al other related to deprecation resolving it is part of #58.
So as this major is resolved we can close this issue.