Package io.codemodder
Interface CodemodReporterStrategy
public interface CodemodReporterStrategy
A type responsible for reporting codemod changes.
-
Method Summary
Modifier and TypeMethodDescriptionstatic CodemodReporterStrategyempty()static CodemodReporterStrategyfromClasspath(Class<? extends CodeChanger> codemodType) ACodemodReporterStrategythat reports based on text from a predictable location on classpath.getChange(Path path, CodemodChange change)
-
Method Details
-
getSummary
String getSummary() -
getDescription
String getDescription() -
getChange
-
getReferences
-
fromClasspath
ACodemodReporterStrategythat reports based on text from a predictable location on classpath. This is an alternative to storing data inline to the Java source code of yourCodeChanger. It's easier to maintain this "data" outside of code, so we prefer a simple mechanism for doing that. Both the files read are expected to be in/com/acme/MyCodemod/
(assuming that's the name of your codemod type.)The first expected file in that directory is
report.json. It contains most of the fields we want to report:{ "summary": "A headline describing the changes provided by this codemod", "control": "A URL linking to the source of the security control added", "change": "A description of the change suitable for a particular instance of a change", "references": [ "A URL for further reading", "Another URL for further reading" ] }The second file is $
description.md, and it provides last field needed by aCodemodReporterStrategyis the description of the codemod itself. This is expected to be a bigger piece of text, and thus it is stored in a separate file where it can be easily edited with an IDE supporting markdown.Thus, in a typical Java project, using this
CodemodReporterStrategywould mean your artifact would retain at least these 3 files:- src/main/java/com/acme/MyCodemod.java
- src/main/resources/com/acme/MyCodemod/report.json
- src/main/resources/com/acme/MyCodemod/description.mdli>
- Parameters:
codemodType- theCodeChangertype to load the reporting text for- Returns:
- a
CodemodReporterStrategythat reports based on text from the classpath
-
empty
-