Annotation Interface Metadata


@Retention(RUNTIME) @Target(TYPE) public @interface Metadata
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Class<? extends io.codemodder.CodeChanger>
    The codemod being tested.
    The GAV coordinates of any dependencies that should be added to the project after the codemod's execution.
    The classpath-based test directory containing the test case artifacts.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Whether to re-run the transformed code through a second transformation with the same inputs, but with the transformed code, to see if another transformation is erroneously made.
    int[]
    The expected failed fix metadata that the codemod should report.
    int[]
    The expected fix metadata that the codemod should report.
    Used to filter test execution to only the tests with a display name that matches the given regex.
    Class<? extends io.codemodder.ProjectProvider>[]
    Some codemods change their behavior based on the context of the app -- like which versions of libraries are present.
    Test files should always be renamed to this before execution.
    Sonar hotspots file names for testing multiple json files
    Sonar issues file names for testing multiple json files
  • Element Details

    • codemodType

      Class<? extends io.codemodder.CodeChanger> codemodType
      The codemod being tested.
    • testResourceDir

      String testResourceDir
      The classpath-based test directory containing the test case artifacts.
    • dependencies

      String[] dependencies
      The GAV coordinates of any dependencies that should be added to the project after the codemod's execution.
    • renameTestFile

      String renameTestFile
      Test files should always be renamed to this before execution. Helps test codemods that only target certain file names. Also supports directories in the path.
      Default:
      ""
    • doRetransformTest

      boolean doRetransformTest
      Whether to re-run the transformed code through a second transformation with the same inputs, but with the transformed code, to see if another transformation is erroneously made.
      Default:
      true
    • projectProviders

      Class<? extends io.codemodder.ProjectProvider>[] projectProviders
      Some codemods change their behavior based on the context of the app -- like which versions of libraries are present. If you want to simulate specific contextual conditions related to dependencies, you can add a customized provider here A usage example can be found at HardenXStreamCodemodTestProjectProvider
      Default:
      {}
    • expectingFixesAtLines

      int[] expectingFixesAtLines
      The expected fix metadata that the codemod should report.
      Default:
      {}
    • expectingFailedFixesAtLines

      int[] expectingFailedFixesAtLines
      The expected failed fix metadata that the codemod should report.
      Default:
      {}
    • sonarIssuesJsonFiles

      String[] sonarIssuesJsonFiles
      Sonar issues file names for testing multiple json files
      Default:
      {}
    • sonarHotspotsJsonFiles

      String[] sonarHotspotsJsonFiles
      Sonar hotspots file names for testing multiple json files
      Default:
      {}
    • only

      String only
      Used to filter test execution to only the tests with a display name that matches the given regex. This is a test-driven development tool for iterating on a single, dynamic test case.
       @Metadata(
         codemodType = LogFailedLoginCodemod.class,
         testResourceDir = "log-failed-login",
         only = "\\/safe\\/.*",
         dependencies = {})
       public final class LogFailedLoginCodemodTest implements CodemodTestMixin {
       
      Default:
      ""