Skip to content

Commit ab06eef

Browse files
Update README for clarity and for version 0.9.0 changes
Updated README to reflect changes in features, usage instructions, and plugin version updates added to version 0.9.0
1 parent 9ecf9a8 commit ab06eef

1 file changed

Lines changed: 49 additions & 48 deletions

File tree

README.md

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,67 @@
11
# RefactorFirst
22

33
This tool for Java codebases will help you identify what you should refactor first:
4-
- God Classes
5-
- Highly Coupled classes
6-
- Class Cycles (with cycle images!)
4+
- Class and Package Cycles (with cycle images!)
5+
- Object Oriented Disharmonies (a.k.a anti-patterns) identified in [Object Oriented Metrics in Practice](https://link.springer.com/book/10.1007/3-540-39538-5)
76

8-
It scans your Git repository generates a single page application by runing:
7+
It scans your Git repository and generates a single page application by running:
98
- Cycle analysis on your source code using the [OpenRewrite](https://github.com/openrewrite/rewrite) Java parser and [JGraphT](https://jgrapht.org/)
109
- What-if analysis to identify the most optimal relationships in a class cycle to remove
11-
- PMD's God Class Rule
12-
- PMD's Coupling Between Objects
1310

14-
Code map viewers are powered by [3D Force Graph](https://vasturiano.github.io/3d-force-graph), [sigma.js](https://www.sigmajs.org/), and [GraphViz DOT](https://graphviz.org/docs/layouts/dot/)
15-
<br>If there are more than 4000 classes + relationships, a simplified 3D viewer will be used to avoid slowdowns. Features will be toggleable in the 3D UI in a future release.
11+
Code map viewers are powered by [3D Force Graph](https://vasturiano.github.io/3d-force-graph), [sigma.js](https://www.sigmajs.org/), and [GraphViz DOT](https://graphviz.org/docs/layouts/dot/) using [Vizdom](https://github.com/vizdom-dev/vizdom) to render the DOT graph.
12+
<br>If there are more than 4000 classes + relationships, a simplified 3D viewer will be available to avoid page load slowdowns. Features will be toggleable in the 3D UI in a future release.
13+
14+
## How to Use RefactorFirst Quickly
15+
Run the command below in your Java project's top-level directory. You'll need Git, Java 11 (or newer) and Maven 3 installed. This command will analyze Maven and non-Maven projects:
16+
```bash
17+
mvn org.hjug.refactorfirst.plugin:refactor-first-maven-plugin:0.9.0:htmlReport
18+
```
19+
View the report at ```target/site/refactor-first-report.html``` in your project.
20+
Full instructions for various usage scenarios are below.
21+
Great effort has been taken to make both the analysis and page rendering times as fast as possible.
1622

1723
## Decomposing and Removing Cycles
1824
Cycle analysis is performed with cutting-edge [Directed Feedback Vertex Set](https://dl.acm.org/doi/10.1145/3711669) and [Directed Feedback Arc Set](https://arxiv.org/abs/2208.09234)
1925
algorithms to identify the optimal classes and relationships between classes for removal to get rid of cycles in your codebase.
20-
These algorithms are powerful and will push your CPU to its limits for large codebases, though it does play nice and shouldn't slow your computer down.
21-
These graph algorithms can be used outside RefactorFirst.
26+
These algorithms are powerful and will push your CPU to its limits for large codebases, though they do play nice and shouldn't slow your computer down.
27+
These graph algorithms can be used outside of RefactorFirst.
2228
See [DIAGRAM.md](./graph-algorithms/src/main/java/org/hjug/feedback/vertex/kernelized/DIAGRAM.md) for the flow of the vertex kernelized algorithm.
2329
See [DIAGRAM.md](./graph-algorithms/src/main/java/org/hjug/feedback/arc/pageRank/DIAGRAM.md) for more details on the arc kernelized algorithm.
2430

2531

2632
### How to understand the Relationship Removal Priority table
2733

28-
The Relationship Removal Priority table shows the most optimal relationships to remove from your codebase to remove all cycles.
34+
The Relationship Removal Priority tables shows the most optimal relationships to remove from your codebase to remove all cycles.
2935
The table is sorted by the number of cycles that a relationship exists in and then the change proneness of the classes in the relationship.
30-
- Classes that should be broken apart / removed from the codebase are bold.
31-
- If only one class is bold, the shared functionality should be moved to the non-bold class.
32-
- If neither class or both classes are bold, examine both classes and reassess the responsibilities of the classes and refactor to remove the relationship.
36+
- Classes that should be broken apart / removed from the codebase have a *.
37+
- If only one class is bold, the shared functionality should be moved to the non-bold class or classes.
38+
- If neither class or both classes are bold: examine both classes carefully, reassess the responsibilities of the classes and then refactor to remove the relationship. If one or both classes are identified as a disharmony, follow the guidance provided for the disharmony.
3339

3440
Take a look at the [Spring Petclinic REST project sample report](https://rawcdn.githack.com/refactorfirst/RefactorFirst/c46d26211a91ffbe08d4089e04a85ff31eb093c0/spring-petclinic-rest-report.html)!
3541

3642
The graphs generated in the report will look similar to this one:
3743
![image info](./RefactorFirst_Sample_Report.png)
3844

3945
## Please Note: Java 11 (or newer) required to run RefactorFirst
40-
**Java 21 codebase analysis is supported!**
41-
The change to require Java 11 is needed to address vulnerability CVE-2023-4759 in JGit
46+
**Java 25 codebase analysis is supported!**
4247
Please use a recent JDK release of the Java version you are using.
4348
If you use an old JDK release of your chosen Java version, you may encounter issues during analysis.
4449

4550

46-
## There are several ways to run the analysis on your codebase:
47-
51+
## How to use RefactorFirst:
4852
### From The Command Line As an HTML Report
4953
Run the following command from the root of your project (the source code does not need to be built):
5054

5155
```bash
52-
mvn org.hjug.refactorfirst.plugin:refactor-first-maven-plugin:0.8.0:htmlReport
56+
mvn org.hjug.refactorfirst.plugin:refactor-first-maven-plugin:0.9.0:htmlReport
5357
```
54-
View the report at ```target/site/refactor-first-report.html```
58+
View the report at `target/site/refactor-first-report.html`
5559

5660
### [As Part of GitHub Actions Output](https://github.blog/news-insights/product-news/supercharging-github-actions-with-job-summaries/)
5761
This will generate a simplified HTML report (no graphs or images) as the output of a GitHub Action step
5862
```bash
5963
mvn -B clean test \
60-
org.hjug.refactorfirst.plugin:refactor-first-maven-plugin:0.8.0:simpleHtmlReport \
64+
org.hjug.refactorfirst.plugin:refactor-first-maven-plugin:0.9.0:simpleHtmlReport \
6165
&& echo "$(cat target/site/refactor-first-report.html)" >> $GITHUB_STEP_SUMMARY
6266
```
6367

@@ -70,7 +74,7 @@ Add the following to your project in the build section. **showDetails** will sh
7074
<plugin>
7175
<groupId>org.hjug.refactorfirst.plugin</groupId>
7276
<artifactId>refactor-first-maven-plugin</artifactId>
73-
<version>0.8.0</version>
77+
<version>0.9.0</version>
7478
<!-- optional -->
7579
<configuration>
7680
<showDetails>false</showDetails>
@@ -91,7 +95,7 @@ A RefactorFirst report will show up in the site report when you run ```mvn site`
9195
<plugin>
9296
<groupId>org.hjug.refactorfirst.plugin</groupId>
9397
<artifactId>refactor-first-maven-plugin</artifactId>
94-
<version>0.8.0</version>
98+
<version>0.9.0</version>
9599
</plugin>
96100
...
97101
</plugins>
@@ -109,12 +113,31 @@ Specify with -D if running on the command line. e.g. ```-DbackEdgeAnalysisCount
109113
|analyzeCycles|Analyzes the 10 largest cycles (will be configurable in the future)| true |
110114
|minifyHtml|Minifies the generated HTML report. Only available on ```htmlReport``` and ```simpleHtmlReport``` goals. May cause issues with large reports.| false |
111115
|excludeTests|Exclude test classes from analysis| true |
112-
|testSrcDirectory|Excludes classes containing this pattern from analysis| ```src/test``` and ```src\test``` |
116+
|testSrcDirectory|Excludes classes containing this pattern from analysis| ```src/test``` |
113117
|projectName|The name of your project to be displayed on the report| Your Maven project name |
114118
|projectVersion|The version of your project to be displayed on the report| Your Maven project version |
115119
|outputDirectory|The location the project report will be written| ```${projectDir}/target/site/refactor-first-report.html```
116120

117121

122+
## But I'm using Gradle / my project layout isn't typical!
123+
I plan to create a Gradle plugin and (possibly) support non-conventional project structures in the future, but in the meantime you can create a dummy POM file in the same directory as your .git directory to show your project's name in the report:
124+
125+
```xml
126+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
127+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
128+
<modelVersion>4.0.0</modelVersion>
129+
130+
<groupId>com.mycompany.app</groupId>
131+
<artifactId>my-app</artifactId>
132+
<version>1.0-SNAPSHOT</version>
133+
</project>
134+
```
135+
and then (assuming Maven is installed) run
136+
137+
```bash
138+
mvn org.hjug.refactorfirst.plugin:refactor-first-maven-plugin:0.9.0:htmlReport
139+
```
140+
118141
### Seeing Errors?
119142

120143
If you see an error similar to
@@ -139,26 +162,6 @@ you will need to add the following to your pom.xml:
139162
</build>
140163
```
141164

142-
143-
## But I'm using Gradle / my project layout isn't typical!
144-
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:
145-
146-
```xml
147-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
148-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
149-
<modelVersion>4.0.0</modelVersion>
150-
151-
<groupId>com.mycompany.app</groupId>
152-
<artifactId>my-app</artifactId>
153-
<version>1.0-SNAPSHOT</version>
154-
</project>
155-
```
156-
and then (assuming Maven is installed) run
157-
158-
```bash
159-
mvn org.hjug.refactorfirst.plugin:refactor-first-maven-plugin:0.8.0:htmlReport
160-
```
161-
162165
## Viewing the Report
163166
View the report at ```target/site/refactor-first-report.html```
164167
Once the plugin finishes executing (it may take a while for a large / old codebase), open the file **target/site/refactor-first-report.html** in the root of the project. It will contain a graph similar to the one above, and a table that lists God classes in the recommended order that they should be refactored. The classes in the top left of the graph are the easiest to refactor while also having the biggest positive impact to team productivity.
@@ -182,13 +185,11 @@ There is still much to be done. Your feedback and collaboration would be greatl
182185
If you find this plugin useful, please star this repository and share with your friends & colleagues and on social media.
183186

184187
## Future Plans
185-
* Improve class cycle analysis
186188
* Add a Gradle plugin.
187189
* Incorporate Unit Test coverage metrics to quickly identify the safety of refactoring classes.
188-
* Incorporate bug counts per class to the Impact (Y-Axis) calculation.
189-
* Incorporate more disharmonies from Object Oriented Metrics In Practice (Lanza and Marinescu, 2004).
190+
* Incorporate additional meaningful metrics.
190191

191192
## Note:
192-
If you are a user of Version 0.1.0 or 0.1.1, you may notice that the list of God classes found by the plugin has changed. This is due to changes in PMD.
193+
If you are a user of Version 0.8.0 or older, you may notice that the list of God classes found by the plugin has changed starting in version 0.9.0. This is due to the fact that the God class metric used starting with version 0.9.0 is faithful to the metric parameters defined in Object Oriented Metrics in Practice.
193194

194195
# Thank You! Enjoy!

0 commit comments

Comments
 (0)