Skip to content

GCI94 systematically suggests orElseGet, but could be further optimized#183

Open
MohamedAliSidibe wants to merge 3 commits into
green-code-initiative:mainfrom
MohamedAliSidibe:GCI94/OptionalOrElseGetVsOrElse
Open

GCI94 systematically suggests orElseGet, but could be further optimized#183
MohamedAliSidibe wants to merge 3 commits into
green-code-initiative:mainfrom
MohamedAliSidibe:GCI94/OptionalOrElseGetVsOrElse

Conversation

@MohamedAliSidibe
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown
Contributor

@jbureau92 jbureau92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR. Few suggestions :

  • CHANGELOG should be updated, I suggest adding :
    #183 GCI94 - reduce false positives by not flagging orElse with already-defined values (literals, constants, identifiers)
  • Issue #119 can be automatically closed by adding "Closes #119" in description.
  • Nice to have : You should add tests about concatenation, ternary, casts and arrays with // Noncompliant, to assume these usecases are non compliant.

reportIssue(memberSelect, MESSAGE_RULE);
}
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

import org.sonar.plugins.java.api.tree.MemberSelectExpressionTree;
import org.sonar.plugins.java.api.tree.MethodInvocationTree;
import org.sonar.plugins.java.api.tree.Tree;
import org.sonar.plugins.java.api.tree.*;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import org.sonar.plugins.java.api.tree.*;
import org.sonar.plugins.java.api.tree.BaseTreeVisitor;
import org.sonar.plugins.java.api.tree.ExpressionTree;
import org.sonar.plugins.java.api.tree.MemberSelectExpressionTree;
import org.sonar.plugins.java.api.tree.MethodInvocationTree;
import org.sonar.plugins.java.api.tree.Tree;

@MohamedAliSidibe
Copy link
Copy Markdown
Author

Closes #119

@MohamedAliSidibe
Copy link
Copy Markdown
Author

Mahamadou Ali Sidibe / LesShreks des dépendances moisies / CGI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants