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

    sarif

    Fields inherited from class io.codemodder.javaparser.JavaParserChanger

    reporter
  • Constructor Summary

    Constructors
    Constructor
    Description
    MoveSwitchDefaultCaseLastCodemod(io.codemodder.RuleSarif ruleSarif)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    onResultFound(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, visit

    Methods inherited from class io.codemodder.javaparser.JavaParserChanger

    dependenciesRequired, getDescription, getIndividualChangeDescription, getReferences, getSummary

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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:
      onResultFound in class io.codemodder.SarifPluginJavaParserChanger<com.github.javaparser.ast.stmt.SwitchEntry>