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

Eliminate wrongly used static variables #1605

Merged
merged 1 commit into from
Nov 28, 2018

Conversation

ivangalkin
Copy link
Contributor

@ivangalkin ivangalkin commented Nov 27, 2018

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

This change is Reviewable

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
@ivangalkin ivangalkin added this to the 1.2.1 milestone Nov 27, 2018
@ivangalkin ivangalkin self-assigned this Nov 27, 2018
@ivangalkin ivangalkin requested review from Bertk and guwirth November 27, 2018 14:51

if (!regEx.isEmpty()) {
if (!regularExpression.isEmpty()) {
Copy link
Contributor Author

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()) {
Copy link
Contributor Author

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

Copy link
Collaborator

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:

Wrong regex is configuration error.

Copy link
Contributor Author

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()) {
Copy link
Collaborator

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:

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;
Copy link
Collaborator

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.

@guwirth guwirth merged commit ee91258 into SonarOpenCommunity:master Nov 28, 2018
@guwirth guwirth mentioned this pull request Dec 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants