Should squid:S00100 care about test method names?

258 views
Skip to first unread message

Alix Warnke

unread,
Apr 13, 2018, 9:32:13 AM4/13/18
to SonarQube
Hi,

I noticed the the rule squid:S00100 (rule introduced in 2014) now reports violations in unit test method names as well.

Rule description (squid:S00100):

Shared naming conventions allow teams to collaborate efficiently. This rule checks that all method names match a provided regular expression.


I think it is perfectly reasonable to have a completely separate naming convention for test method names, i.e. http://osherove.com/blog/2005/4/3/naming-standards-for-unit-tests.html 
Test method names should convey a lot of information (hence makes it quite unreadable using the standard java naming convention for methods).

Does anybody know if the rule was accidentally enabled for tests or if there is reasoning behind the change?

Best Regards
Alix

Michael Gumowski

unread,
Apr 13, 2018, 10:08:03 AM4/13/18
to Alix Warnke, SonarQube
Hello Alix,

To me, it seems that it should be a configuration problem of your project rather than a change in the rule (we didn't change its scope). S00100 should only be applied to MAIN sources. I would guess that TEST sources of your project has not been identified by the scanner correctly (maven? gradle? sonar.propertiy file?). Consequently, you would end up with TEST sources being flagged as MAIN sources. Did you changed something in your project configuration? Maybe it's a bug on scanner side.

Regarding naming of tests, we have a dedicated rule, which is only going to be applied on TEST: RSPEC-3578 
The rule is however not part of SonarWay profile, so you will need to enable it manually.

Note that if your tests sources are mapped to MAIN sources, then all the rules which are supposed to be played only on MAIN and not on TEST are going to be applied as well, probably causing some noise in your project. Similarily, not a single rule targeting explicitly TEST sources is going to be played.

Finally, on a similar topic, in a near future, we plan to have some selected rules of each analyzer be played on both scopes (main/test), if it make sense for them. It is not yet implemented, but we are about to start working on the subject (for SonarJava plugin, see SONARJAVA-2684).

Regards,
Michael



--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/8ab7d13e-bc7e-4561-adc8-5c542a5d9bc3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Michael Gumowski | SonarSource
Software Developer, Language Team
https://www.sonarsource.com

Alix Warnke

unread,
Apr 13, 2018, 10:25:01 AM4/13/18
to SonarQube
Thank you, Michael, for the explanation.
Must be a configuration issue on my side then or a bug as you say.
It's Gradle (multi-module) and in the test sources

/ Alix
Reply all
Reply to author
Forward
0 new messages