-
Notifications
You must be signed in to change notification settings - Fork 362
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
Eliminate wrongly used static variables #1605
Eliminate wrongly used static variables #1605
Conversation
There is no need to share state between classes. This is error-prone and prohibits any possible parallelization of code analysis * BullseyeParser * HardcodedAccountCheck - refactored * HardcodedIpCheck - refactored
|
||
if (!regEx.isEmpty()) { | ||
if (!regularExpression.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
Objects.requireNonNull(regularExpression, "getRegularExpression() should not return null"); | ||
|
||
if (null != regEx && !regEx.isEmpty()) { | ||
if (!regularExpression.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably throwing an IllegalStateException
in case of empty regular expression would be more correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ivangalkin general rule we had in the past:
- configuration errors should result in errors and "stop" the analysis
- runtime errors: https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Supported-configuration-properties#sonarcxxerrorrecoveryenabled
Wrong regex is configuration error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Then I'll throw an exception if regular expression was empty
Objects.requireNonNull(regularExpression, "getRegularExpression() should not return null"); | ||
|
||
if (null != regEx && !regEx.isEmpty()) { | ||
if (!regularExpression.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ivangalkin general rule we had in the past:
- configuration errors should result in errors and "stop" the analysis
- runtime errors: https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Supported-configuration-properties#sonarcxxerrorrecoveryenabled
Wrong regex is configuration error.
@@ -39,9 +39,9 @@ | |||
public class BullseyeParser extends CxxCoverageParser { | |||
|
|||
private static final Logger LOG = Loggers.get(BullseyeParser.class); | |||
private static String prevLine; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ivangalkin don't know why they were static in the past? Seems ok now.
There is no need to share state between classes. This is error-prone and
prohibits any possible parallelization of code analysis
This change is