Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude deprecated rules from pre-defined profiles #1147

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions generate_profiles/BuildXmlFiles.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,11 @@ def getAllPatternsFromPlugin(Plugin plugin) {
patternsXml.BugPattern.each { pattern ->

category = getFindBugsCategory([plugin], pattern.attribute("type"))
deprecated = deprecated = (pattern.attribute("deprecated") == "true")


if (category == "EXPERIMENTAL" || category == "NOISE") return;
if (deprecated) return;
//if (category == "MT_CORRECTNESS") category = "MULTI-THREADING";

patterns << pattern.attribute("type")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public final class FindbugsRulesDefinition implements RulesDefinition {
public static final String REPOSITORY_KEY = "findbugs";
public static final String REPOSITORY_NAME = "FindBugs";
public static final int RULE_COUNT = 483;
public static final int DEPRECATED_RULE_COUNT = 4;
public static final int DEACTIVED_RULE_COUNT = 6;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,6 @@
<Match>
<Bug pattern='TLW_TWO_LOCK_WAIT' />
</Match>
<Match>
<Bug pattern='TLW_TWO_LOCK_NOTIFY' />
</Match>
<Match>
<Bug pattern='UW_UNCOND_WAIT' />
</Match>
Expand Down Expand Up @@ -953,9 +950,6 @@
<Match>
<Bug pattern='BIT_IOR' />
</Match>
<Match>
<Bug pattern='LI_LAZY_INIT_INSTANCE' />
</Match>
<Match>
<Bug pattern='LI_LAZY_INIT_STATIC' />
</Match>
Expand Down Expand Up @@ -1028,9 +1022,6 @@
<Match>
<Bug pattern='BOA_BADLY_OVERRIDDEN_ADAPTER' />
</Match>
<Match>
<Bug pattern='BRSA_BAD_RESULTSET_ACCESS' />
</Match>
<Match>
<Bug pattern='SQL_BAD_RESULTSET_ACCESS' />
</Match>
Expand Down Expand Up @@ -1169,9 +1160,6 @@
<Match>
<Bug pattern='NP_NULL_INSTANCEOF' />
</Match>
<Match>
<Bug pattern='BC_NULL_INSTANCEOF' />
</Match>
<Match>
<Bug pattern='BC_IMPOSSIBLE_INSTANCEOF' />
</Match>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,6 @@
<Match>
<Bug pattern='TLW_TWO_LOCK_WAIT' />
</Match>
<Match>
<Bug pattern='TLW_TWO_LOCK_NOTIFY' />
</Match>
<Match>
<Bug pattern='UW_UNCOND_WAIT' />
</Match>
Expand Down Expand Up @@ -953,9 +950,6 @@
<Match>
<Bug pattern='BIT_IOR' />
</Match>
<Match>
<Bug pattern='LI_LAZY_INIT_INSTANCE' />
</Match>
<Match>
<Bug pattern='LI_LAZY_INIT_STATIC' />
</Match>
Expand Down Expand Up @@ -1028,9 +1022,6 @@
<Match>
<Bug pattern='BOA_BADLY_OVERRIDDEN_ADAPTER' />
</Match>
<Match>
<Bug pattern='BRSA_BAD_RESULTSET_ACCESS' />
</Match>
<Match>
<Bug pattern='SQL_BAD_RESULTSET_ACCESS' />
</Match>
Expand Down Expand Up @@ -1169,9 +1160,6 @@
<Match>
<Bug pattern='NP_NULL_INSTANCEOF' />
</Match>
<Match>
<Bug pattern='BC_NULL_INSTANCEOF' />
</Match>
<Match>
<Bug pattern='BC_IMPOSSIBLE_INSTANCEOF' />
</Match>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void shouldCreateProfile() {
findbugsProfile.define(context);

BuiltInQualityProfile profile = context.profile(Java.KEY, FindbugsContribProfile.FB_CONTRIB_PROFILE_NAME);
assertThat(profile.rules().stream().filter(r -> r.repoKey().equals(FindbugsRulesDefinition.REPOSITORY_KEY)).count()).isEqualTo(FindbugsRulesDefinition.RULE_COUNT);
assertThat(profile.rules().stream().filter(r -> r.repoKey().equals(FindbugsRulesDefinition.REPOSITORY_KEY)).count()).isEqualTo(FindbugsRulesDefinition.RULE_COUNT - FindbugsRulesDefinition.DEPRECATED_RULE_COUNT);
assertThat(profile.rules().stream().filter(r -> r.repoKey().equals(FbContribRulesDefinition.REPOSITORY_KEY)).count()).isEqualTo(FbContribRulesDefinition.RULE_COUNT);
assertThat(logTester.getLogs(Level.ERROR)).isEmpty();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ void shouldCreateProfile() {
findbugsProfile.define(context);

BuiltInQualityProfile profile = context.profile(Java.KEY, FindbugsProfile.FINDBUGS_PROFILE_NAME);
assertThat(profile.rules()).hasSize(FindbugsRulesDefinition.RULE_COUNT);
assertThat(profile.rules().stream().filter(r -> r.repoKey().equals(FindbugsRulesDefinition.REPOSITORY_KEY)).count()).isEqualTo(FindbugsRulesDefinition.RULE_COUNT);
assertThat(profile.rules()).hasSize(FindbugsRulesDefinition.RULE_COUNT - FindbugsRulesDefinition.DEPRECATED_RULE_COUNT);
assertThat(profile.rules().stream().filter(r -> r.repoKey().equals(FindbugsRulesDefinition.REPOSITORY_KEY)).count()).isEqualTo(FindbugsRulesDefinition.RULE_COUNT - FindbugsRulesDefinition.DEPRECATED_RULE_COUNT);
assertThat(logTester.getLogs(Level.ERROR)).isEmpty();

FindbugsProfileTest.assertHasOnlyRulesForLanguage(profile.rules(), Java.KEY);
Expand Down
Loading