11# RefactorFirst
22
3- This tool for Java codebases will help you identify the God Classes and classes with High Coupling you should refactor first.
4- It runs PMD's God Class Rule and Coupling Between Objects rule and scans your Git repository history.
3+ This tool for Java codebases will help you identify classes you should refactor first:
4+ - God Classes
5+ - Highly Coupled classes
6+ - Classes Cycles (with cycle images!)
7+
8+ It scans your Git repository and runs:
9+ - PMD's God Class Rule
10+ - PMD's Coupling Between Objects
11+ - Performs cycle analysis based on source code using [ JavaParser] ( https://javaparser.org/ ) and [ JGraphT] ( https://jgrapht.org/ )
12+
13+ Cycle analysis is performed based on class field types and method signature types at this time (more to come!).
514
615The graphs generated in the report will look similar to this one:
716![ image info] ( ./RefactorFirst_Sample_Report.png )
817
9- ## Please Note: Java 11 is now required to run RefactorFirst
18+ ## Please Note: Java 11 (or newer) required to run RefactorFirst
1019The change to require Java 11 is needed to address vulnerability CVE-2023 -4759 in JGit
11- Java 21 features are not yet integrated since PMD APIs have changed.
20+ ** Java 21 codebase analysis is supported! **
1221
1322## There are several ways to run the analysis on your codebase:
1423
15- ### From The Command Line
24+ ### From The Command Line As an HTML Report
1625Run the following command from the root of your project (the source code does not need to be built):
1726
1827``` bash
19- mvn org.hjug.refactorfirst.plugin:refactor-first-maven-plugin:0.5.0-M1:report
28+ mvn org.hjug.refactorfirst.plugin:refactor-first-maven-plugin:0.5.0:htmlReport
29+ ```
30+ View the report at ``` target/site/refactor-first-report.html ```
31+
32+ ### [ As Part of GitHub Actions Output] ( https://github.blog/news-insights/product-news/supercharging-github-actions-with-job-summaries/ )
33+ This will generate a simplified HTML report (no graphs or images) as the output of a GitHub Action step
34+ ``` bash
35+ mvn -B clean test \
36+ org.hjug.refactorfirst.plugin:refactor-first-maven-plugin:0.5.0:simpleHtmlReport \
37+ && echo " $( cat target/site/refactor-first-report.html) " >> $GITHUB_STEP_SUMMARY
2038```
2139
2240### As Part of a Build
@@ -28,10 +46,10 @@ Add the following to your project in the build section. **showDetails** will sh
2846 <plugin >
2947 <groupId >org.hjug.refactorfirst.plugin</groupId >
3048 <artifactId >refactor-first-maven-plugin</artifactId >
31- <version >0.5.0-M1 </version >
49+ <version >0.5.0</version >
3250 <!-- optional -->
3351 <configuration >
34- <showDetails >true </showDetails >
52+ <showDetails >false </showDetails >
3553 </configuration >
3654 </plugin >
3755 ...
@@ -49,7 +67,7 @@ A RefactorFirst report will show up in the site report when you run ```mvn site`
4967 <plugin >
5068 <groupId >org.hjug.refactorfirst.plugin</groupId >
5169 <artifactId >refactor-first-maven-plugin</artifactId >
52- <version >0.5.0-M1 </version >
70+ <version >0.5.0</version >
5371 </plugin >
5472 ...
5573 </plugins >
@@ -78,11 +96,6 @@ you will need to add the following to your pom.xml:
7896 </build >
7997```
8098
81- ### As an HTML Report
82- ``` bash
83- mvn org.hjug.refactorfirst.plugin:refactor-first-maven-plugin:0.5.0-M1:htmlReport
84- ```
85- View the report at ``` target/site/refactor-first-report.html ```
8699
87100## But I'm using Gradle / my project layout isn't typical!
88101I would like to create a Gradle plugin and (possibly) support non-conventional projects in the future, but in the meantime you can create a dummy POM file in the same directory as your .git directory:
@@ -100,7 +113,7 @@ I would like to create a Gradle plugin and (possibly) support non-conventional p
100113and then (assuming Maven is installed) run
101114
102115``` bash
103- mvn org.hjug.refactorfirst.plugin:refactor-first-maven-plugin:0.5.0-M1 :htmlReport
116+ mvn org.hjug.refactorfirst.plugin:refactor-first-maven-plugin:0.5.0:htmlReport
104117```
105118
106119## Viewing the Report
@@ -126,10 +139,10 @@ There is still much to be done. Your feedback and collaboration would be greatl
126139If you find this plugin useful, please star this repository and share with your friends & colleagues and on social media.
127140
128141## Future Plans
129- * Identify class cycles and prioritize them .
142+ * Improve class cycle analysis (only field member types and method signature types are currently supported) .
130143* Add a Gradle plugin.
131- * Incorporate Unit Test coverage metrics to quickly identify the safety of refactoring a God class .
132- * Incorporate bug counts per God class to the Impact (Y-Axis) calculation.
144+ * Incorporate Unit Test coverage metrics to quickly identify the safety of refactoring classes .
145+ * Incorporate bug counts per class to the Impact (Y-Axis) calculation.
133146* Incorporate more disharmonies from Object Oriented Metrics In Practice (Lanza and Marinescu, 2004).
134147
135148## Note:
0 commit comments