Avoid of sections of code should not be "commented out"

2,540 views
Skip to first unread message

iliadu...@gmail.com

unread,
Aug 18, 2015, 8:12:11 PM8/18/15
to SonarQube
Hello,

Is there a way to escape code in comments and avoid this violation?

Sometimes we need to keep part of code "commented out" like an example and obviously we get violation from this rule.

G. Ann Campbell

unread,
Aug 19, 2015, 12:28:47 PM8/19/15
to SonarQube, iliadu...@gmail.com
Hi,

Your choices are to use //NOSONAR, or simply mark the issues as false positives.


Ann

Michal Kordas

unread,
Aug 19, 2015, 12:55:39 PM8/19/15
to G. Ann Campbell, SonarQube, iliadu...@gmail.com

Hi Ann,

In Checkstyle we use Nemo instance. Can anyone mark for us these issues as false-positives?

We don't want to pollute our Javadocs with //NOSONAR.

Thanks,
Michal Kordas

19-08-2015 18:28 użytkownik "G. Ann Campbell" <ann.ca...@sonarsource.com> napisał:

G. Ann Campbell

unread,
Aug 19, 2015, 1:06:31 PM8/19/15
to SonarQube, ann.ca...@sonarsource.com, iliadu...@gmail.com
I've resolved all but one of these as either False Positive (when the line was a mix of commentary and code) or Won't Fix (when the line was pure code but clearly intended to be documentary). The last one looks like the real deal.



Ann

Michał Kordas

unread,
Aug 19, 2015, 3:44:43 PM8/19/15
to G. Ann Campbell, SonarQube, Ilja Dubinin
Thanks a lot Ann!

We have couple more obvious false-positives/won't fixes for squid:S1135 ("TODO" tags should be handled): http://nemo.sonarqube.org/issues/search#projectUuids=93eb9164-80ec-4136-9c42-d4d23deed1db|resolved=false|rules=squid%3AS1135

This is just documentation for our check detecting TODO in code, not actual TODO comments.

Can you mark them as well?

Best,
Michal Kordas


--
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/cca700ab-b333-4cef-9ae2-472553904e8c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

G. Ann Campbell

unread,
Aug 19, 2015, 4:37:52 PM8/19/15
to Michał Kordas, SonarQube, Ilja Dubinin
Hmmm... I fear I have opened a can of worms. Sorry, but I'm not going to make these changes.





---
G. Ann CAMPBELL | SonarSource
Product Owner

Ilja Dubinin

unread,
Aug 20, 2015, 3:41:16 AM8/20/15
to G. Ann Campbell, Michał Kordas, SonarQube
Thanks, Ann

Roman Ivanov

unread,
Aug 20, 2015, 3:58:02 AM8/20/15
to SonarQube
Hi Ilja and Michal,

Please request updates for suppressions ONLY at
https://groups.google.com/forum/m/#!msg/sonarqube/bYanojEy9LI/H0a6dWQvWeQJ

It would be better if you send me you proposal for suppression and I communicate with Sonar team as sign of final and whole team decision ( not a desire one team member).

Thanks.
Roman Ivanov

Roman Ivanov

unread,
Sep 13, 2015, 6:53:23 PM9/13/15
to SonarQube
Hi Ann,

Can you please help us to suppress some violations  that I listed at https://groups.google.com/d/msg/sonarqube/bYanojEy9LI/ol_WuCmGBQAJ


thanks,
Roman Ivanov

G. Ann Campbell

unread,
Sep 14, 2015, 9:55:07 AM9/14/15
to Roman Ivanov, SonarQube
Freddy is actually asking in that message what filters we should apply to the project to prevent issues from being created in the first place.



---
G. Ann CAMPBELL | SonarSource
Product Owner

--
You received this message because you are subscribed to a topic in the Google Groups "SonarQube" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonarqube/e5xnjMxnz04/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/53442235-f40d-4b3d-bba1-3cf32aecca36%40googlegroups.com.

Roman Ivanov

unread,
Sep 17, 2015, 9:33:12 AM9/17/15
to SonarQube, romani...@gmail.com
Hi Ann,

thanks for reply and explanation. I presume you mean filters at projects Settings / Exclusions / Issues / "Ignore Issues on Multiple Criteria"

1)

there is no other way to work with javadoc , com.sun.javadoc package is still not deprecated.

"squid:S1191"     "**/doclets/TokenTypesDoclet.java"

2)

TODO is a part of documentation we need to keep it.

"squid:S1135"     "**/TodoCommentCheck.java"

3)

All violations are against c-tors, we intentionally put avoid setters, so all data should come through c-tor arguments.

"squid:S00107"     "**/LocalizedMessage.java"

4)

Standard output is used only in one class that that our CLI (Main.java) that is ok, usage of logger is not appropriate.

"squid:S106"     "**/Main.java"

5)

This case could be considered as bug/false-positive as we use "for (int index = 1; index < lines.length;    ) {" empty iteration at FOR.
This form does not brake a rule but this corner case is not covered. So right now we need to filter it out or mark them as Wontfix.

"squid:ForLoopCounterChangedCheck"    "**/*.java"

6)

Following to this rule lead code to be too abstract/wrapped for no benefit, it is better to limit amount exceptions to certain limit.

"squid:S1160"    "**/*.java"

7)

All of these are pure false-positives (bugs) in Sonar. I recommend to open issue against Sonar on these items.
For our project it would be better to mark them as wontfix till issues are resolved, if not an option - please use filter below.

"squid:MissingDeprecatedCheck"       "**/*.java"


thanks,
Roman Ivanov
Reply all
Reply to author
Forward
0 new messages