Package io.codemodder.codemods
Class MoveSwitchDefaultCaseLastCodemod
java.lang.Object
io.codemodder.javaparser.JavaParserChanger
io.codemodder.SarifPluginJavaParserChanger<com.github.javaparser.ast.stmt.SwitchEntry>
io.codemodder.codemods.MoveSwitchDefaultCaseLastCodemod
- All Implemented Interfaces:
io.codemodder.CodeChanger
@Codemod(id="pixee:java/move-switch-default-last",
importance=LOW,
reviewGuidance=MERGE_WITHOUT_REVIEW)
public final class MoveSwitchDefaultCaseLastCodemod
extends io.codemodder.SarifPluginJavaParserChanger<com.github.javaparser.ast.stmt.SwitchEntry>
A codemod for moving the "default" case to last in switch statements. This codemod is not
currently in the default set because it could conceivably change behavior when other case
statements fall through to it. It should be improved to only move if the previous case does not
fall through.
-
Field Summary
Fields inherited from class io.codemodder.SarifPluginJavaParserChanger
sarifFields inherited from class io.codemodder.javaparser.JavaParserChanger
reporter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanonResultFound(io.codemodder.CodemodInvocationContext context, com.github.javaparser.ast.CompilationUnit cu, com.github.javaparser.ast.stmt.SwitchEntry switchEntry, com.contrastsecurity.sarif.Result result) Methods inherited from class io.codemodder.SarifPluginJavaParserChanger
shouldRun, visitMethods inherited from class io.codemodder.javaparser.JavaParserChanger
dependenciesRequired, getDescription, getIndividualChangeDescription, getReferences, getSummary
-
Constructor Details
-
MoveSwitchDefaultCaseLastCodemod
@Inject public MoveSwitchDefaultCaseLastCodemod(@PmdScan(ruleId="category/java/bestpractices.xml/DefaultLabelNotLastInSwitchStmt") io.codemodder.RuleSarif ruleSarif)
-
-
Method Details
-
onResultFound
public boolean onResultFound(io.codemodder.CodemodInvocationContext context, com.github.javaparser.ast.CompilationUnit cu, com.github.javaparser.ast.stmt.SwitchEntry switchEntry, com.contrastsecurity.sarif.Result result) - Specified by:
onResultFoundin classio.codemodder.SarifPluginJavaParserChanger<com.github.javaparser.ast.stmt.SwitchEntry>
-