Skip to content

Commit b703679

Browse files
authoredSep 25, 2024··
Merge pull request #100 from refactorfirst/handle-generated-sources
Handle generated sources
2 parents 9cf5d34 + c460143 commit b703679

File tree

13 files changed

+46
-32
lines changed

13 files changed

+46
-32
lines changed
 

‎README.md

+31-18
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,40 @@
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

615
The 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
1019
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!**
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
1625
Run 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!
88101
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
100113
and 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
126139
If 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:

‎change-proneness-ranker/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.hjug.refactorfirst</groupId>
77
<artifactId>refactor-first</artifactId>
8-
<version>0.5.0-M4-SNAPSHOT</version>
8+
<version>0.5.0-SNAPSHOT</version>
99
</parent>
1010

1111
<groupId>org.hjug.refactorfirst.changepronenessranker</groupId>

‎circular-reference-detector/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.hjug.refactorfirst</groupId>
66
<artifactId>refactor-first</artifactId>
7-
<version>0.5.0-M4-SNAPSHOT</version>
7+
<version>0.5.0-SNAPSHOT</version>
88
</parent>
99

1010
<groupId>org.hjug.refactorfirst.circularreferencedetector</groupId>

‎cli/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.hjug.refactorfirst</groupId>
66
<artifactId>refactor-first</artifactId>
7-
<version>0.5.0-M4-SNAPSHOT</version>
7+
<version>0.5.0-SNAPSHOT</version>
88
</parent>
99

1010
<packaging>jar</packaging>

‎cost-benefit-calculator/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.hjug.refactorfirst</groupId>
77
<artifactId>refactor-first</artifactId>
8-
<version>0.5.0-M4-SNAPSHOT</version>
8+
<version>0.5.0-SNAPSHOT</version>
99
</parent>
1010

1111
<groupId>org.hjug.refactorfirst.costbenefitcalculator</groupId>

‎cost-benefit-calculator/src/main/java/org/hjug/cbc/CostBenefitCalculator.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ <T extends Disharmony> List<ScmLogInfo> getRankedChangeProneness(List<T> disharm
248248
} catch (GitAPIException | IOException e) {
249249
log.error("Error reading Git repository contents.", e);
250250
} catch (NullPointerException e) {
251-
log.error("Encountered nested class in a class containing a violation. Class: {}", path);
251+
log.info("Encountered nested class in a class containing a violation. Class: {}", path);
252+
scmLogInfo = new ScmLogInfo(path, 0, 0, 0);
252253
}
253254
return scmLogInfo;
254255
})

‎coverage/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.hjug.refactorfirst</groupId>
99
<artifactId>refactor-first</artifactId>
10-
<version>0.5.0-M4-SNAPSHOT</version>
10+
<version>0.5.0-SNAPSHOT</version>
1111
</parent>
1212

1313
<artifactId>coverage</artifactId>

‎effort-ranker/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.hjug.refactorfirst</groupId>
77
<artifactId>refactor-first</artifactId>
8-
<version>0.5.0-M4-SNAPSHOT</version>
8+
<version>0.5.0-SNAPSHOT</version>
99
</parent>
1010

1111
<groupId>org.hjug.refactorfirst.effortranker</groupId>
@@ -20,7 +20,7 @@
2020
<dependency>
2121
<groupId>org.hjug.refactorfirst.testresources</groupId>
2222
<artifactId>test-resources</artifactId>
23-
<version>0.5.0-M4-SNAPSHOT</version>
23+
<version>0.5.0-SNAPSHOT</version>
2424
</dependency>
2525

2626
<dependency>

‎graph-data-generator/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.hjug.refactorfirst</groupId>
77
<artifactId>refactor-first</artifactId>
8-
<version>0.5.0-M4-SNAPSHOT</version>
8+
<version>0.5.0-SNAPSHOT</version>
99
</parent>
1010

1111
<groupId>org.hjug.refactorfirst.graphdatagenerator</groupId>
@@ -15,7 +15,7 @@
1515
<dependency>
1616
<groupId>org.hjug.refactorfirst.costbenefitcalculator</groupId>
1717
<artifactId>cost-benefit-calculator</artifactId>
18-
<version>0.5.0-M4-SNAPSHOT</version>
18+
<version>0.5.0-SNAPSHOT</version>
1919
</dependency>
2020
</dependencies>
2121

‎pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>org.hjug.refactorfirst</groupId>
66
<artifactId>refactor-first</artifactId>
7-
<version>0.5.0-M4-SNAPSHOT</version>
7+
<version>0.5.0-SNAPSHOT</version>
88
<packaging>pom</packaging>
99

1010
<url>https://github.com/refactorfirst/RefactorFirst</url>

‎refactor-first-maven-plugin/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.hjug.refactorfirst</groupId>
77
<artifactId>refactor-first</artifactId>
8-
<version>0.5.0-M4-SNAPSHOT</version>
8+
<version>0.5.0-SNAPSHOT</version>
99
</parent>
1010

1111
<groupId>org.hjug.refactorfirst.plugin</groupId>

‎report/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.hjug.refactorfirst</groupId>
66
<artifactId>refactor-first</artifactId>
7-
<version>0.5.0-M4-SNAPSHOT</version>
7+
<version>0.5.0-SNAPSHOT</version>
88
</parent>
99

1010
<groupId>org.hjug.refactorfirst.report</groupId>

‎test-resources/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>org.hjug.refactorfirst</groupId>
77
<artifactId>refactor-first</artifactId>
8-
<version>0.5.0-M4-SNAPSHOT</version>
8+
<version>0.5.0-SNAPSHOT</version>
99
</parent>
1010

1111
<groupId>org.hjug.refactorfirst.testresources</groupId>

0 commit comments

Comments
 (0)
Please sign in to comment.