sonar-scala / sonar-scala

A free and open-source SonarQube plugin for static code analysis of Scala projects.

Home Page:https://sonar-scala.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"scalastyle:ignore" not working with a rule ID

gaelrenoux-datadome opened this issue · comments

I have some code like:

class unused extends scala.annotation.StaticAnnotation // scalastyle:ignore class.name

When running scalastyle locally, it rightly ignores the broken rule on the object name. In Sonar however, it appears as a code smell. It works in Sonar if I remove the rule ID:

class unused extends scala.annotation.StaticAnnotation // scalastyle:ignore

You have to use the fully qualified class name of the rule, so this would be org.scalastyle.scalariform.ClassNamesChecker in your case.

I think it's a bug, though (although obviously a rather minor one). Scalastyle documentation specifies it's the rule ID that should be used, and makes no mention of using the class name for this purpose. Your workaround did solve the issue in Sonar, but it failed in other tools using Scalastyle plugins (SBT and IntelliJ). So, I need to keep both definitions of the rule, which is a mouthful:

class unused extends scala.annotation.StaticAnnotation // scalastyle:ignore class.name org.scalastyle.scalariform.ClassNamesChecker

Yes, I see - that makes sense. I'm not sure why the scalastyle ids aren't working, but I'm not using scalastyle locally so that's probably why it's something that I missed. Leve it with me for now and I'll see what can be done to make this work.