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

why SuppressWarningsFilter and SuppressionCommentFilter are default filters ? #98

Closed
rnveach opened this issue Mar 29, 2017 · 5 comments
Labels

Comments

@rnveach
Copy link
Member

rnveach commented Mar 29, 2017

When I define one rule in a sonar profile, like Indentation, the following configuration is created:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<!-- Generated by Sonar -->
<module name="Checker">
  <module name="SuppressionCommentFilter"/>
  <module name="SuppressWarningsFilter"/>
  <module name="TreeWalker">
    <module name="FileContentsHolder"/>
    <module name="SuppressWarningsHolder"/>
    <module name="Indentation">
      <property name="severity" value="info"/>
      <property name="throwsIndent" value="4"/>
      <property name="arrayInitIndent" value="4"/>
      <property name="forceStrictCondition" value="false"/>
      <property name="caseIndent" value="4"/>
      <property name="basicOffset" value="4"/>
      <property name="braceAdjustment" value="0"/>
      <property name="lineWrappingIndentation" value="4"/>
    </module>
  </module>
</module>

The addition of the default filters SuppressWarningsFilter and SuppressionCommentFilter were unexpected and were causing issues for me.

SuppressWarningsFilter by default will hide any violations when SuppressWarnings is used with it. I had added SuppressWarnings annotations for other tests.
So I can't get violations in the following java file unless SuppressWarningsFilter is removed:

import java.lang.Boolean;

public class Testing {
    @SuppressWarnings("all")
    public void method() {
		test:
		;

        Boolean s = new Boolean("testing");
        Boolean t = new java.lang.Boolean("test");
        
        new Thread(
    		() -> System.out.println("hello world")
    	).start();
int a = 0;
a++;
    }

    @SuppressWarnings("   ")
    public void test() {
    }

	public @interface NonNull {
	}
	/** */
	public @interface NonNull2 {
	}
}
@romani
Copy link
Member

romani commented Apr 5, 2017

How default value is looks like in sonar:
image

@romani
Copy link
Member

romani commented Apr 5, 2017

The addition of the default filters SuppressWarningsFilter and SuppressionCommentFilter were unexpected and were causing issues for me.

Do you propose to make default as nothing (empty string) ?

@rnveach
Copy link
Member Author

rnveach commented Apr 5, 2017

Do you propose to make default as nothing (empty string) ?

I did.
Does the screenshot mean that filters are global and each profile can't define it's own filters like rules?

@romani
Copy link
Member

romani commented Apr 5, 2017

No, each project can override this value, to make it specific to the project in Administation menu of certain project.
image
Default is value from global Sonar Administration menu.

@romani romani changed the title Sonar: unexpected filters added why SuppressWarningsFilter and SuppressionCommentFilter are default filters ? Apr 5, 2017
@romani romani added the approved label Mar 8, 2019
@muhlba91
Copy link
Contributor

has been moved into #99 - closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants