Class MakeJUnit5TestsPackagePrivateCodemod

java.lang.Object
io.codemodder.javaparser.JavaParserChanger
io.codemodder.SarifPluginJavaParserChanger<com.github.javaparser.ast.body.ClassOrInterfaceDeclaration>
io.codemodder.examples.MakeJUnit5TestsPackagePrivateCodemod
All Implemented Interfaces:
io.codemodder.CodeChanger

@Codemod(id="codemodder:java/make-junit5-tests-package-private", reviewGuidance=MERGE_WITHOUT_REVIEW, importance=LOW) public final class MakeJUnit5TestsPackagePrivateCodemod extends io.codemodder.SarifPluginJavaParserChanger<com.github.javaparser.ast.body.ClassOrInterfaceDeclaration>
A codemod that makes JUnit 5 tests package private.
  • Field Summary

    Fields inherited from class io.codemodder.SarifPluginJavaParserChanger

    sarif

    Fields inherited from class io.codemodder.javaparser.JavaParserChanger

    reporter
  • Constructor Summary

    Constructors
    Constructor
    Description
    MakeJUnit5TestsPackagePrivateCodemod(io.codemodder.RuleSarif sarif)
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    getIndividualChangeDescription(Path filePath, io.codemodder.CodemodChange change)
     
    List<io.codemodder.codetf.CodeTFReference>
     
     
    io.codemodder.javaparser.ChangesResult
    onResultFound(io.codemodder.CodemodInvocationContext context, com.github.javaparser.ast.CompilationUnit cu, com.github.javaparser.ast.body.ClassOrInterfaceDeclaration typeDefinition, com.contrastsecurity.sarif.Result result)
     

    Methods inherited from class io.codemodder.SarifPluginJavaParserChanger

    shouldRun, supports, visit

    Methods inherited from class io.codemodder.javaparser.JavaParserChanger

    getIncludesExcludesPattern

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MakeJUnit5TestsPackagePrivateCodemod

      @Inject public MakeJUnit5TestsPackagePrivateCodemod(@SemgrepScan(yaml="rules:\n - id: find-public-junit-class-modifiers\n patterns:\n - pattern: public class $CLASS { ... }\n - metavariable-regex:\n metavariable: $CLASS\n regex: .*Test\n - pattern-inside: |\n ...\n import org.junit.jupiter.api.Test;\n ...\n") io.codemodder.RuleSarif sarif)
  • Method Details

    • onResultFound

      public io.codemodder.javaparser.ChangesResult onResultFound(io.codemodder.CodemodInvocationContext context, com.github.javaparser.ast.CompilationUnit cu, com.github.javaparser.ast.body.ClassOrInterfaceDeclaration typeDefinition, com.contrastsecurity.sarif.Result result)
      Specified by:
      onResultFound in class io.codemodder.SarifPluginJavaParserChanger<com.github.javaparser.ast.body.ClassOrInterfaceDeclaration>
    • getSummary

      public String getSummary()
      Specified by:
      getSummary in interface io.codemodder.CodeChanger
      Overrides:
      getSummary in class io.codemodder.javaparser.JavaParserChanger
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface io.codemodder.CodeChanger
      Overrides:
      getDescription in class io.codemodder.javaparser.JavaParserChanger
    • getReferences

      public List<io.codemodder.codetf.CodeTFReference> getReferences()
      Specified by:
      getReferences in interface io.codemodder.CodeChanger
      Overrides:
      getReferences in class io.codemodder.javaparser.JavaParserChanger
    • getIndividualChangeDescription

      public String getIndividualChangeDescription(Path filePath, io.codemodder.CodemodChange change)
      Specified by:
      getIndividualChangeDescription in interface io.codemodder.CodeChanger
      Overrides:
      getIndividualChangeDescription in class io.codemodder.javaparser.JavaParserChanger