Suppress squid:S1191 with @SuppressWarnings

2,120 views
Skip to first unread message

roman....@gmail.com

unread,
Sep 26, 2017, 9:28:29 AM9/26/17
to SonarQube
Hi guys,

how would you recommend tu suppress the rule squid:S1191?

  1. @SuppressWarnings seems not working for imports.
    In your documentation (https://docs.sonarqube.org/display/PLUG/Java+FAQ#JavaFAQ-SuppressWarnings) stands: "Known limitation: Annotation can not be used to suppress issues occuring at file level". Is this the cause? Are you going to support it in the (near) future?
  2. //NOSONAR trailing comment behind an import is unfortunately removed by IntelliJ after every code formatting.
  3. Exclude feature can't be used since I don't wanna exclude it for all occurences. Only specific file has to be suppressed.
Thanks.
Regards,
Roman

G. Ann Campbell

unread,
Sep 26, 2017, 11:12:04 AM9/26/17
to SonarQube
Hi Roman,

I'd recommend you use the Ignore Issues on Multiple Criteria to ignore this rule on that file.

Note that it's waaaay easier to correctly set multi-criteria exclusions through the UI than through settings. 


Ann

Tibor Blenessy

unread,
Sep 28, 2017, 11:24:43 AM9/28/17
to G. Ann Campbell, SonarQube
Hi Roman,

alternative solution to the one that Ann suggested, could be to use fully qualified names instead of imports. Depending on the context you might be able to annotate language elements with @SuppressWarnings . Of course this is not always applicable, and ignoring issues with properties is more universal.

Hope that helps

Tibor

--
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/02eac291-6842-40c5-a43d-665b2f3d9cb4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--

Tibor Blenessy | SonarSource

SonarJava Developer

http://sonarsource.com 

roman....@gmail.com

unread,
Oct 3, 2017, 4:21:27 PM10/3/17
to SonarQube
Hi Ann and Tibor, 

thank you both for your suggestions. We decided to apply the last one proposed by Tibor because it respects the very important internal rule - every suppression MUST stay with the source code in the repository if it is possible. It's transparent for any programmer and there is no WHY. 

Nevertheless from the long-term point of view I'm not happy with this kind of "hack" and I'd really appreciate suppressing at the file level. Is there any plan to deliver it?

Regards,
Roman

Dne čtvrtek 28. září 2017 17:24:43 UTC+2 Tibor Blenessy napsal(a):
Reply all
Reply to author
Forward
0 new messages