We have just updated SonarQube to version v10.5.1 in our organization, and with that, updated all the quality profile rules.
With this update, we got a new rule S6669: Logger field or property name should comply with a naming convention
We have a lot of existing code where we have used the property name DefaultLogger instead of the more appropriate name Logger, and this rule is of course complaining about this.
We do not want to change all of this existing code, and have instead decided to override this rule in our custom quality profile to also accept DefaultLogger as a valid propertyname.
This is done by changing the format from the default value ‘’^_?[Ll]og(ger)?$" to our custom value “^(Default)?_?[Ll]og(ger)?$”
*Note that the regex in the error message is always the original value, and not our custom value!*
We know that we are using the correct quality profile, since we have overridden a few other rules as well, and they all seems to accept our overridden values, except from rule S6669.
Are there any bugs to this rule?
Or could there be another explanation for this behavior?
I have also started using SonarLint in VS2022 bound to our SonarQube project, and we see the same issue there with rule S6999.
We have one other parameterized rule that we successfully override: S3776 Cognitive Complexity of methods should not be too high
We have changed the threshold parameter value from default 15 to 30, and this works fine.
The other parameter, propertyThreshold, is kept unchanged (default 3)
SonarQube is now happy with this as long as we keep our code below our custom threshold value, 30.
So yes, rule S3775 is using the expected changed value, while rule S6669 is still not.
All other overridden rules only have changes to the severity level.
Regarding the upgrade to SonarQube, we previously used v8.9.xxx. (Not sure about the minor version number)
I believe it was first upgraded to the latest v9.9
And finally to our current version: Developer Edition v10.5.1 (90531)
In your screenshot, there is an underscore in the regex between Default and Logger
However, the regex you mention in the post shows no underscore. I guess it is a side effect of embedding in HTML. Just want to make sure that the regex you want to use is:
^(Default)?_?[Ll]og(ger)?$
This is the same optional underscore that is in the default regex. I just added a optional (Default)? in front of the default one.
It looks like the post was not showing the underscore correctly. I have fixed the post now.
I also tried a lot of other, much simpler regex, and they are all ignored. The rule is using the default all the time.
Like this one: ^DefaultLogger$
So the problem is not within my regex, but that the rule is ignoring any changes to it.