Rule squid:S2143 not applicable on Android

76 views
Skip to first unread message

alix....@gmail.com

unread,
Oct 11, 2017, 10:23:19 AM10/11/17
to SonarQube
Hi,

I've recently updated  the source Java language level on my Android project and noticed that I was getting squid:S2143 violations.
On a closer inspection I found that it's not really possible to follow the rule's advice on Android as the new Time and Date API (JSR-310) is not available in the Android Runtime (requires a non-standard library such as https://github.com/JakeWharton/ThreeTenABP ).

So I propose that this rule should not be applicable on an Android codebase, if this is possible.

/ Alix


Nicolas Peru

unread,
Oct 24, 2017, 5:30:18 AM10/24/17
to alix....@gmail.com, SonarQube
Hi, 

We have no mechanism to detect an Android codebase or not as of today. Best course of action would be to deactivate the rule in your quality profile.

Cheers, 

--
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/0acc9d99-d4d9-480d-85a7-0735115952bf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Nicolas Peru | SonarSource

cli...@gmail.com

unread,
Jan 16, 2018, 10:07:53 AM1/16/18
to SonarQube
Thanks Nicolas, 
I tried your suggestion but stumbled on a problem.
Our setup looks like this:

"Quality Profile Android"  inherits from "Quality Profile Java". Our thinking is that all rules that apply to generic Java code also applies to Android code.
But it seems that it's not possible to deactivate a rule that is inherited from a parent. I guess we could stop using inheritance as a workaround. 
What do you suggest?

Regards
Alix

Stas Vilchik

unread,
Feb 2, 2018, 5:31:04 AM2/2/18
to SonarQube
Hi,

You're absolutely right saying this is impossible to deactivate a rule inherited from a parent quality profile. Instead I'd suggest to slightly change your quality profile hierarchy:
  • create a copy of the "Quality Profile Java" quality profile and call it (for example) "Quality Profile Base"
  • deactivate the rule causing the problem in "Quality Profile Base"
  • inherit both "Quality Profile Java" and "Quality Profile Android" from newly created "Quality Profile Base"
  • activate back the rule only in "Quality Profile Java"
This way the rule set of  "Quality Profile Java" stays exactly the same, "Quality Profile Android" doesn't have the problematic rule, and you still inherit most of the rules.

Cheers!
Reply all
Reply to author
Forward
0 new messages