It is not possible to configure a rule to have an empty value, the default value is automatically applied. I have noticed this for java:S1166 for which we would like to have no exceptions. It is possible to use a fantasy value as workaround.
It probably would be better to have a mechanism to explicitely reset the rule to the default values.
IMO, it’s no bug, buts works as designed.
Does a blank value of a parametrized rule without defaults make any sense ?!
Stripping blanks is a standard part of sanitizing input, maybe it’s an accidental entry ?
If it’s only blank(s) it gets nothing which means default setting will / should be used.
Thus you have to use a fantasy value.
For rules which use a threshold (like line length) resetting to the default value is reasonable and expectable. However, being unable to clear a list of exemptions because I’d like to not have any exemptions is unexpected.
I have found no other rule, where one would completely remove the preconfigured value, so it is not big of an issue.
Entering whitespace seems to work, too. I simply hope the Scanner does not implode.
OK, got your point
Didn’t expect a whitespace would work, are you sure it’s saved as whitespace ?
Guess that might cause problems later on, how did your tests work ?
In order to reset a rule to its default configuration, it’s still possible to deactivate/re-activate the rule, this would do the job (test on a LTS 7.9). So I’m not sure a button would be useful here.
Now, I was not aware of this mechanism of getting back to default if no value is provided… And in such cases that’s indeed annoying. This behavior is unfortunately out of reach of SonarJava analyzer, as we fully rely on the configuration provided by SonarQube API:
On Quality Profile side, SonarJava tells SQ what we suggest as default value;
At analysis time, SonarJava get an instance of the rule from SQ, with parameters already configured.
That’s a nice workaround. Looking at implementation of the rule, it will do the trick perfectly well (and SonarJava will not implode ).
I’ll modify the description of the parameter in order to make this case explicit and tell people to simply fill the parameter with a simple dash character (‘-’) to tell the rule to inspect every exceptions (a comma would have done it as well). I created the following ticket to track this small update: SONARJAVA-3323
Don’t hesitate to get back to us on this forum if you see any other rules that would need such behavior!