Package io.codemodder.codemods
Class SwitchLiteralFirstComparisonsCodemod
java.lang.Object
io.codemodder.javaparser.JavaParserChanger
io.codemodder.SarifPluginJavaParserChanger<com.github.javaparser.ast.expr.MethodCallExpr>
io.codemodder.codemods.SwitchLiteralFirstComparisonsCodemod
- All Implemented Interfaces:
io.codemodder.CodeChanger
@Codemod(id="pixee:java/switch-literal-first",
reviewGuidance=MERGE_WITHOUT_REVIEW)
public final class SwitchLiteralFirstComparisonsCodemod
extends io.codemodder.SarifPluginJavaParserChanger<com.github.javaparser.ast.expr.MethodCallExpr>
A codemod for automatically switching the order of literals and variables in comparisons so
they're guaranteed not to throw
NullPointerException
when the variable is unexpectedly
null.-
Field Summary
Fields inherited from class io.codemodder.SarifPluginJavaParserChanger
sarif
Fields inherited from class io.codemodder.javaparser.JavaParserChanger
reporter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
onResultFound
(io.codemodder.CodemodInvocationContext context, com.github.javaparser.ast.CompilationUnit cu, com.github.javaparser.ast.expr.MethodCallExpr methodCallExpr, com.contrastsecurity.sarif.Result result) Methods inherited from class io.codemodder.SarifPluginJavaParserChanger
visit
Methods inherited from class io.codemodder.javaparser.JavaParserChanger
dependenciesRequired, getDescription, getIndividualChangeDescription, getReferences, getSummary
-
Constructor Details
-
SwitchLiteralFirstComparisonsCodemod
@Inject public SwitchLiteralFirstComparisonsCodemod(@PmdScan(ruleId="category/java/bestpractices.xml/LiteralsFirstInComparisons") io.codemodder.RuleSarif ruleSarif)
-
-
Method Details
-
onResultFound
public boolean onResultFound(io.codemodder.CodemodInvocationContext context, com.github.javaparser.ast.CompilationUnit cu, com.github.javaparser.ast.expr.MethodCallExpr methodCallExpr, com.contrastsecurity.sarif.Result result) - Specified by:
onResultFound
in classio.codemodder.SarifPluginJavaParserChanger<com.github.javaparser.ast.expr.MethodCallExpr>
-