1
1
# RefactorFirst
2
2
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!).
5
14
6
15
The graphs generated in the report will look similar to this one:
7
16
![ image info] ( ./RefactorFirst_Sample_Report.png )
8
17
9
- ## Please Note: Java 11 is now required to run RefactorFirst
18
+ ## Please Note: Java 11 (or newer) required to run RefactorFirst
10
19
The 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! **
12
21
13
22
## There are several ways to run the analysis on your codebase:
14
23
15
- ### From The Command Line
24
+ ### From The Command Line As an HTML Report
16
25
Run the following command from the root of your project (the source code does not need to be built):
17
26
18
27
``` 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
20
38
```
21
39
22
40
### As Part of a Build
@@ -28,10 +46,10 @@ Add the following to your project in the build section. **showDetails** will sh
28
46
<plugin >
29
47
<groupId >org.hjug.refactorfirst.plugin</groupId >
30
48
<artifactId >refactor-first-maven-plugin</artifactId >
31
- <version >0.5.0-M1 </version >
49
+ <version >0.5.0</version >
32
50
<!-- optional -->
33
51
<configuration >
34
- <showDetails >true </showDetails >
52
+ <showDetails >false </showDetails >
35
53
</configuration >
36
54
</plugin >
37
55
...
@@ -49,7 +67,7 @@ A RefactorFirst report will show up in the site report when you run ```mvn site`
49
67
<plugin >
50
68
<groupId >org.hjug.refactorfirst.plugin</groupId >
51
69
<artifactId >refactor-first-maven-plugin</artifactId >
52
- <version >0.5.0-M1 </version >
70
+ <version >0.5.0</version >
53
71
</plugin >
54
72
...
55
73
</plugins >
@@ -78,11 +96,6 @@ you will need to add the following to your pom.xml:
78
96
</build >
79
97
```
80
98
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 ```
86
99
87
100
## But I'm using Gradle / my project layout isn't typical!
88
101
I 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
100
113
and then (assuming Maven is installed) run
101
114
102
115
``` 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
104
117
```
105
118
106
119
## Viewing the Report
@@ -126,10 +139,10 @@ There is still much to be done. Your feedback and collaboration would be greatl
126
139
If you find this plugin useful, please star this repository and share with your friends & colleagues and on social media.
127
140
128
141
## 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) .
130
143
* 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.
133
146
* Incorporate more disharmonies from Object Oriented Metrics In Practice (Lanza and Marinescu, 2004).
134
147
135
148
## Note:
0 commit comments