From 128b886b4df4e9790c94d03809a21050d0fe41e8 Mon Sep 17 00:00:00 2001 From: Jim Bethancourt Date: Wed, 25 Sep 2024 08:16:42 -0500 Subject: [PATCH 1/3] #99 Now handling generated sources gracefully Creating a placeholder ScmLogInfo object when a source file has been generated. --- .../src/main/java/org/hjug/cbc/CostBenefitCalculator.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cost-benefit-calculator/src/main/java/org/hjug/cbc/CostBenefitCalculator.java b/cost-benefit-calculator/src/main/java/org/hjug/cbc/CostBenefitCalculator.java index d8e91fb3..b55d1665 100644 --- a/cost-benefit-calculator/src/main/java/org/hjug/cbc/CostBenefitCalculator.java +++ b/cost-benefit-calculator/src/main/java/org/hjug/cbc/CostBenefitCalculator.java @@ -248,7 +248,8 @@ List getRankedChangeProneness(List disharm } catch (GitAPIException | IOException e) { log.error("Error reading Git repository contents.", e); } catch (NullPointerException e) { - log.error("Encountered nested class in a class containing a violation. Class: {}", path); + log.info("Encountered nested class in a class containing a violation. Class: {}", path); + scmLogInfo = new ScmLogInfo(path, 0,0,0); } return scmLogInfo; }) From 6eabbaaf24dcc6f46e6cc9910a77271054411920 Mon Sep 17 00:00:00 2001 From: Jim Bethancourt Date: Wed, 25 Sep 2024 08:42:57 -0500 Subject: [PATCH 2/3] Updated readme for version 0.5.0 --- README.md | 49 +++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index b8ba55b6..1593c04d 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,40 @@ # RefactorFirst -This tool for Java codebases will help you identify the God Classes and classes with High Coupling you should refactor first. -It runs PMD's God Class Rule and Coupling Between Objects rule and scans your Git repository history. +This tool for Java codebases will help you identify classes you should refactor first: +- God Classes +- Highly Coupled classes +- Classes Cycles (with cycle images!) + +It scans your Git repository and runs: +- PMD's God Class Rule +- PMD's Coupling Between Objects +- Performs cycle analysis based on source code using [JavaParser](https://javaparser.org/) and [JGraphT](https://jgrapht.org/) + +Cycle analysis is performed based on class field types and method signature types at this time (more to come!). The graphs generated in the report will look similar to this one: ![image info](./RefactorFirst_Sample_Report.png) -## Please Note: Java 11 is now required to run RefactorFirst +## Please Note: Java 11 (or newer) required to run RefactorFirst The change to require Java 11 is needed to address vulnerability CVE-2023-4759 in JGit -Java 21 features are not yet integrated since PMD APIs have changed. +**Java 21 codebase analysis is supported!** ## There are several ways to run the analysis on your codebase: -### From The Command Line +### From The Command Line As an HTML Report Run the following command from the root of your project (the source code does not need to be built): ```bash -mvn org.hjug.refactorfirst.plugin:refactor-first-maven-plugin:0.5.0-M1:report +mvn org.hjug.refactorfirst.plugin:refactor-first-maven-plugin:0.5.0:htmlReport +``` +View the report at ```target/site/refactor-first-report.html``` + +### [As Part of GitHub Actions Output](https://github.blog/news-insights/product-news/supercharging-github-actions-with-job-summaries/) +This will generate a simplified HTML report (no graphs or images) as the output of a GitHub Action step +```bash +mvn -B clean test \ +org.hjug.refactorfirst.plugin:refactor-first-maven-plugin:0.5.0:simpleHtmlReport \ +&& echo "$(cat target/site/refactor-first-report.html)" >> $GITHUB_STEP_SUMMARY ``` ### As Part of a Build @@ -28,10 +46,10 @@ Add the following to your project in the build section. **showDetails** will sh org.hjug.refactorfirst.plugin refactor-first-maven-plugin - 0.5.0-M1 + 0.5.0 - true + false ... @@ -49,7 +67,7 @@ A RefactorFirst report will show up in the site report when you run ```mvn site` org.hjug.refactorfirst.plugin refactor-first-maven-plugin - 0.5.0-M1 + 0.5.0 ... @@ -78,11 +96,6 @@ you will need to add the following to your pom.xml: ``` -### As an HTML Report -```bash -mvn org.hjug.refactorfirst.plugin:refactor-first-maven-plugin:0.5.0-M1:htmlReport -``` -View the report at ```target/site/refactor-first-report.html``` ## But I'm using Gradle / my project layout isn't typical! 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 and then (assuming Maven is installed) run ```bash -mvn org.hjug.refactorfirst.plugin:refactor-first-maven-plugin:0.5.0-M1:htmlReport +mvn org.hjug.refactorfirst.plugin:refactor-first-maven-plugin:0.5.0:htmlReport ``` ## Viewing the Report @@ -126,10 +139,10 @@ There is still much to be done. Your feedback and collaboration would be greatl If you find this plugin useful, please star this repository and share with your friends & colleagues and on social media. ## Future Plans -* Identify class cycles and prioritize them. +* Improve class cycle analysis (only field member types and method signature types are currently supported). * Add a Gradle plugin. -* Incorporate Unit Test coverage metrics to quickly identify the safety of refactoring a God class. -* Incorporate bug counts per God class to the Impact (Y-Axis) calculation. +* Incorporate Unit Test coverage metrics to quickly identify the safety of refactoring classes. +* Incorporate bug counts per class to the Impact (Y-Axis) calculation. * Incorporate more disharmonies from Object Oriented Metrics In Practice (Lanza and Marinescu, 2004). ## Note: From c46014305a8f5e1486fa57f959ed294c467bfe66 Mon Sep 17 00:00:00 2001 From: Jim Bethancourt Date: Wed, 25 Sep 2024 08:48:43 -0500 Subject: [PATCH 3/3] Update version to 0.5.0-SNAPSHOT --- change-proneness-ranker/pom.xml | 2 +- circular-reference-detector/pom.xml | 2 +- cli/pom.xml | 2 +- cost-benefit-calculator/pom.xml | 2 +- .../src/main/java/org/hjug/cbc/CostBenefitCalculator.java | 2 +- coverage/pom.xml | 2 +- effort-ranker/pom.xml | 4 ++-- graph-data-generator/pom.xml | 4 ++-- pom.xml | 2 +- refactor-first-maven-plugin/pom.xml | 2 +- report/pom.xml | 2 +- test-resources/pom.xml | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/change-proneness-ranker/pom.xml b/change-proneness-ranker/pom.xml index b5fd02b9..4d3003ec 100644 --- a/change-proneness-ranker/pom.xml +++ b/change-proneness-ranker/pom.xml @@ -5,7 +5,7 @@ org.hjug.refactorfirst refactor-first - 0.5.0-M4-SNAPSHOT + 0.5.0-SNAPSHOT org.hjug.refactorfirst.changepronenessranker diff --git a/circular-reference-detector/pom.xml b/circular-reference-detector/pom.xml index 9ecf0ad3..b503c933 100644 --- a/circular-reference-detector/pom.xml +++ b/circular-reference-detector/pom.xml @@ -4,7 +4,7 @@ org.hjug.refactorfirst refactor-first - 0.5.0-M4-SNAPSHOT + 0.5.0-SNAPSHOT org.hjug.refactorfirst.circularreferencedetector diff --git a/cli/pom.xml b/cli/pom.xml index 69c93cbc..575b4a09 100644 --- a/cli/pom.xml +++ b/cli/pom.xml @@ -4,7 +4,7 @@ org.hjug.refactorfirst refactor-first - 0.5.0-M4-SNAPSHOT + 0.5.0-SNAPSHOT jar diff --git a/cost-benefit-calculator/pom.xml b/cost-benefit-calculator/pom.xml index 478a894d..ab1acb69 100644 --- a/cost-benefit-calculator/pom.xml +++ b/cost-benefit-calculator/pom.xml @@ -5,7 +5,7 @@ org.hjug.refactorfirst refactor-first - 0.5.0-M4-SNAPSHOT + 0.5.0-SNAPSHOT org.hjug.refactorfirst.costbenefitcalculator diff --git a/cost-benefit-calculator/src/main/java/org/hjug/cbc/CostBenefitCalculator.java b/cost-benefit-calculator/src/main/java/org/hjug/cbc/CostBenefitCalculator.java index b55d1665..fb08b6da 100644 --- a/cost-benefit-calculator/src/main/java/org/hjug/cbc/CostBenefitCalculator.java +++ b/cost-benefit-calculator/src/main/java/org/hjug/cbc/CostBenefitCalculator.java @@ -249,7 +249,7 @@ List getRankedChangeProneness(List disharm log.error("Error reading Git repository contents.", e); } catch (NullPointerException e) { log.info("Encountered nested class in a class containing a violation. Class: {}", path); - scmLogInfo = new ScmLogInfo(path, 0,0,0); + scmLogInfo = new ScmLogInfo(path, 0, 0, 0); } return scmLogInfo; }) diff --git a/coverage/pom.xml b/coverage/pom.xml index d473e9fc..e19cdffb 100644 --- a/coverage/pom.xml +++ b/coverage/pom.xml @@ -7,7 +7,7 @@ org.hjug.refactorfirst refactor-first - 0.5.0-M4-SNAPSHOT + 0.5.0-SNAPSHOT coverage diff --git a/effort-ranker/pom.xml b/effort-ranker/pom.xml index d711fa34..4d004b23 100644 --- a/effort-ranker/pom.xml +++ b/effort-ranker/pom.xml @@ -5,7 +5,7 @@ org.hjug.refactorfirst refactor-first - 0.5.0-M4-SNAPSHOT + 0.5.0-SNAPSHOT org.hjug.refactorfirst.effortranker @@ -20,7 +20,7 @@ org.hjug.refactorfirst.testresources test-resources - 0.5.0-M4-SNAPSHOT + 0.5.0-SNAPSHOT diff --git a/graph-data-generator/pom.xml b/graph-data-generator/pom.xml index e8bce68c..04a240ae 100644 --- a/graph-data-generator/pom.xml +++ b/graph-data-generator/pom.xml @@ -5,7 +5,7 @@ org.hjug.refactorfirst refactor-first - 0.5.0-M4-SNAPSHOT + 0.5.0-SNAPSHOT org.hjug.refactorfirst.graphdatagenerator @@ -15,7 +15,7 @@ org.hjug.refactorfirst.costbenefitcalculator cost-benefit-calculator - 0.5.0-M4-SNAPSHOT + 0.5.0-SNAPSHOT diff --git a/pom.xml b/pom.xml index fb7c14f6..965eddda 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.hjug.refactorfirst refactor-first - 0.5.0-M4-SNAPSHOT + 0.5.0-SNAPSHOT pom https://github.com/refactorfirst/RefactorFirst diff --git a/refactor-first-maven-plugin/pom.xml b/refactor-first-maven-plugin/pom.xml index 9ae41d7c..421ec661 100644 --- a/refactor-first-maven-plugin/pom.xml +++ b/refactor-first-maven-plugin/pom.xml @@ -5,7 +5,7 @@ org.hjug.refactorfirst refactor-first - 0.5.0-M4-SNAPSHOT + 0.5.0-SNAPSHOT org.hjug.refactorfirst.plugin diff --git a/report/pom.xml b/report/pom.xml index 47f3fbaf..95430faf 100644 --- a/report/pom.xml +++ b/report/pom.xml @@ -4,7 +4,7 @@ org.hjug.refactorfirst refactor-first - 0.5.0-M4-SNAPSHOT + 0.5.0-SNAPSHOT org.hjug.refactorfirst.report diff --git a/test-resources/pom.xml b/test-resources/pom.xml index 08c1a6c4..8bc8338b 100644 --- a/test-resources/pom.xml +++ b/test-resources/pom.xml @@ -5,7 +5,7 @@ org.hjug.refactorfirst refactor-first - 0.5.0-M4-SNAPSHOT + 0.5.0-SNAPSHOT org.hjug.refactorfirst.testresources