Skip to content

Commit 44ee1ae

Browse files
Merge pull request #120 from refactorfirst/minor-enhancements
#116 #119 Minor enhancements
2 parents 03b29ed + 795f153 commit 44ee1ae

File tree

5 files changed

+74
-171
lines changed

5 files changed

+74
-171
lines changed

pom.xml

+24-18
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
<sonar.organization>jimbethancourt-github</sonar.organization>
7070
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
7171

72-
<maven.core.version>3.9.4</maven.core.version>
72+
<maven.core.version>3.9.9</maven.core.version>
7373
</properties>
7474

7575
<modules>
@@ -140,7 +140,7 @@
140140
<dependency>
141141
<groupId>org.eclipse.jgit</groupId>
142142
<artifactId>org.eclipse.jgit</artifactId>
143-
<version>6.7.0.202309050840-r</version>
143+
<version>6.10.0.202406032230-r</version>
144144
<scope>compile</scope>
145145
</dependency>
146146

@@ -183,7 +183,6 @@
183183

184184

185185
<dependencies>
186-
187186
<dependency>
188187
<groupId>org.mockito</groupId>
189188
<artifactId>mockito-core</artifactId>
@@ -338,21 +337,6 @@
338337
</executions>
339338
-->
340339
</plugin>
341-
<!-- <plugin>-->
342-
<!-- <groupId>org.owasp</groupId>-->
343-
<!-- <artifactId>dependency-check-maven</artifactId>-->
344-
<!-- <version>6.1.0</version>-->
345-
<!-- <configuration>-->
346-
<!-- <failBuildOnCVSS>8.0</failBuildOnCVSS>-->
347-
<!-- </configuration>-->
348-
<!-- <executions>-->
349-
<!-- <execution>-->
350-
<!-- <goals>-->
351-
<!-- <goal>check</goal>-->
352-
<!-- </goals>-->
353-
<!-- </execution>-->
354-
<!-- </executions>-->
355-
<!-- </plugin>-->
356340
<!--TODO: Add the SNYK plugin-->
357341
<!-- https://github.com/snyk/snyk-maven-plugin -->
358342

@@ -395,6 +379,28 @@
395379

396380

397381
<profiles>
382+
<profile>
383+
<id>local</id>
384+
<build>
385+
<plugins>
386+
<plugin>
387+
<groupId>org.owasp</groupId>
388+
<artifactId>dependency-check-maven</artifactId>
389+
<version>6.1.0</version>
390+
<configuration>
391+
<failBuildOnCVSS>8.0</failBuildOnCVSS>
392+
</configuration>
393+
<executions>
394+
<execution>
395+
<goals>
396+
<goal>check</goal>
397+
</goals>
398+
</execution>
399+
</executions>
400+
</plugin>
401+
</plugins>
402+
</build>
403+
</profile>
398404
<profile>
399405
<id>snapshot-release</id>
400406
<build>

refactor-first-maven-plugin/pom.xml

+14-34
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,6 @@
2222
<groupId>org.hjug.refactorfirst.report</groupId>
2323
<artifactId>report</artifactId>
2424
</dependency>
25-
<!-- Doxia -->
26-
<!-- Needed since maven-reporting-impl brings in Struts 1.3.8 jars that have CVSS > 8 -->
27-
<dependency>
28-
<groupId>org.apache.maven.doxia</groupId>
29-
<artifactId>doxia-sink-api</artifactId>
30-
<version>2.0.0-M6</version>
31-
</dependency>
32-
<dependency>
33-
<groupId>org.apache.maven.doxia</groupId>
34-
<artifactId>doxia-decoration-model</artifactId>
35-
<version>2.0.0-M6</version>
36-
</dependency>
37-
<dependency>
38-
<groupId>org.apache.maven.doxia</groupId>
39-
<artifactId>doxia-core</artifactId>
40-
<version>2.0.0-M7</version>
41-
</dependency>
42-
<dependency>
43-
<groupId>org.apache.maven.doxia</groupId>
44-
<artifactId>doxia-site-renderer</artifactId>
45-
<version>2.0.0-M11</version>
46-
</dependency>
4725

4826
<!-- Maven Reporting -->
4927
<dependency>
@@ -52,35 +30,37 @@
5230
<version>${maven.core.version}</version>
5331
</dependency>
5432

55-
<!-- Maven Reporting -->
5633
<dependency>
5734
<groupId>org.apache.maven.reporting</groupId>
5835
<artifactId>maven-reporting-impl</artifactId>
59-
<version>3.2.0</version>
36+
<version>4.0.0</version>
37+
<exclusions>
38+
<!-- Remediates xz-1.9.jar: CVE-2022-1271 -->
39+
<!-- Unused transitive dependency -->
40+
<exclusion>
41+
<groupId>org.tukaani</groupId>
42+
<artifactId>xz</artifactId>
43+
</exclusion>
44+
</exclusions>
6045
</dependency>
6146
<dependency>
6247
<groupId>org.apache.maven.reporting</groupId>
6348
<artifactId>maven-reporting-api</artifactId>
64-
<version>3.1.1</version>
49+
<version>4.0.0</version>
6550
</dependency>
6651

6752
<!-- plugin API and plugin-tools -->
6853
<dependency>
6954
<groupId>org.apache.maven</groupId>
7055
<artifactId>maven-plugin-api</artifactId>
71-
<version>3.5.2</version>
56+
<version>3.9.9</version>
7257
</dependency>
7358
<dependency>
7459
<groupId>org.apache.maven.plugin-tools</groupId>
7560
<artifactId>maven-plugin-annotations</artifactId>
76-
<version>3.6.1</version>
61+
<version>3.15.1</version>
7762
<scope>provided</scope>
7863
</dependency>
79-
<dependency>
80-
<groupId>org.apache.maven.shared</groupId>
81-
<artifactId>maven-shared-utils</artifactId>
82-
<version>3.3.3</version>
83-
</dependency>
8464

8565
<dependency>
8666
<groupId>com.fasterxml.jackson.core</groupId>
@@ -92,12 +72,12 @@
9272
<plugins>
9373
<plugin>
9474
<artifactId>maven-install-plugin</artifactId>
95-
<version>2.5.2</version>
75+
<version>3.1.3</version>
9676
</plugin>
9777
<plugin>
9878
<groupId>org.apache.maven.plugins</groupId>
9979
<artifactId>maven-plugin-plugin</artifactId>
100-
<version>3.9.0</version>
80+
<version>3.15.1</version>
10181
<configuration>
10282
<goalPrefix>refactor-first</goalPrefix>
10383
</configuration>

refactor-first-maven-plugin/src/main/java/org/hjug/mavenreport/RefactorFirstMavenReport.java

+19-64
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package org.hjug.mavenreport;
22

3-
import java.io.BufferedWriter;
43
import java.io.File;
5-
import java.io.FileWriter;
6-
import java.io.IOException;
74
import java.nio.file.Paths;
85
import java.time.Instant;
96
import java.time.ZoneId;
@@ -147,20 +144,6 @@ public void executeReport(Locale locale) throws MavenReportException {
147144
mainSink.unknown(script, new Object[] {HtmlMarkup.TAG_TYPE_START}, googleChartImport);
148145
mainSink.unknown(script, new Object[] {HtmlMarkup.TAG_TYPE_END}, null);
149146

150-
SinkEventAttributeSet godClassJavascript = new SinkEventAttributeSet();
151-
godClassJavascript.addAttribute(SinkEventAttributes.TYPE, "text/javascript");
152-
godClassJavascript.addAttribute(SinkEventAttributes.SRC, "./godClassChart.js");
153-
154-
mainSink.unknown(script, new Object[] {HtmlMarkup.TAG_TYPE_START}, godClassJavascript);
155-
mainSink.unknown(script, new Object[] {HtmlMarkup.TAG_TYPE_END}, null);
156-
157-
SinkEventAttributeSet cboJavascript = new SinkEventAttributeSet();
158-
cboJavascript.addAttribute(SinkEventAttributes.TYPE, "text/javascript");
159-
cboJavascript.addAttribute(SinkEventAttributes.SRC, "./cboChart.js");
160-
161-
mainSink.unknown(script, new Object[] {HtmlMarkup.TAG_TYPE_START}, cboJavascript);
162-
mainSink.unknown(script, new Object[] {HtmlMarkup.TAG_TYPE_END}, null);
163-
164147
SinkEventAttributeSet d3js = new SinkEventAttributeSet();
165148
d3js.addAttribute(SinkEventAttributes.TYPE, "text/javascript");
166149
d3js.addAttribute(SinkEventAttributes.SRC, "https://d3js.org/d3.v5.min.js");
@@ -289,13 +272,19 @@ public void executeReport(Locale locale) throws MavenReportException {
289272
mainSink.section2_();
290273
mainSink.division_();
291274

292-
writeGodClassGchartJs(rankedGodClassDisharmonies, maxGodClassPriority - 1);
275+
String godClassScript = writeGodClassGchartJs(rankedGodClassDisharmonies, maxGodClassPriority - 1);
293276
SinkEventAttributeSet seriesChartDiv = new SinkEventAttributeSet();
294277
seriesChartDiv.addAttribute(SinkEventAttributes.ID, "series_chart_div");
295278
seriesChartDiv.addAttribute(SinkEventAttributes.ALIGN, "center");
296279
mainSink.division(seriesChartDiv);
297280
mainSink.division_();
298281

282+
SinkEventAttributeSet godClassJavascript = new SinkEventAttributeSet();
283+
godClassJavascript.addAttribute(SinkEventAttributes.TYPE, "text/javascript");
284+
mainSink.unknown(script, new Object[] {HtmlMarkup.TAG_TYPE_START}, godClassJavascript);
285+
mainSink.rawText(godClassScript);
286+
mainSink.unknown(script, new Object[] {HtmlMarkup.TAG_TYPE_END}, null);
287+
299288
renderGitHubButtons(mainSink);
300289

301290
String legendHeading = "God Class Chart Legend:";
@@ -399,7 +388,14 @@ public void executeReport(Locale locale) throws MavenReportException {
399388
seriesChartDiv.addAttribute(SinkEventAttributes.ALIGN, "center");
400389
mainSink.division(seriesChartDiv);
401390
mainSink.division_();
402-
writeGCBOGchartJs(rankedCBODisharmonies, maxCboPriority - 1);
391+
392+
String cboScript = writeGCBOGchartJs(rankedCBODisharmonies, maxCboPriority - 1);
393+
394+
SinkEventAttributeSet cboJavascript = new SinkEventAttributeSet();
395+
cboJavascript.addAttribute(SinkEventAttributes.TYPE, "text/javascript");
396+
mainSink.unknown(script, new Object[] {HtmlMarkup.TAG_TYPE_START}, cboJavascript);
397+
mainSink.rawText(cboScript);
398+
mainSink.unknown(script, new Object[] {HtmlMarkup.TAG_TYPE_END}, null);
403399

404400
renderGitHubButtons(mainSink);
405401

@@ -775,63 +771,22 @@ private static void renderGitHubButton(
775771
mainSink.unknown("a", new Object[] {HtmlMarkup.TAG_TYPE_END}, null);
776772
}
777773

778-
// TODO: Move to another class to allow use by Gradle plugin
779-
void writeGodClassGchartJs(List<RankedDisharmony> rankedDisharmonies, int maxPriority) {
774+
String writeGodClassGchartJs(List<RankedDisharmony> rankedDisharmonies, int maxPriority) {
780775
GraphDataGenerator graphDataGenerator = new GraphDataGenerator();
781776
String scriptStart = graphDataGenerator.getGodClassScriptStart();
782777
String bubbleChartData = graphDataGenerator.generateGodClassBubbleChartData(rankedDisharmonies, maxPriority);
783778
String scriptEnd = graphDataGenerator.getGodClassScriptEnd();
784779

785-
String javascriptCode = scriptStart + bubbleChartData + scriptEnd;
786-
787-
String reportOutputDirectory = project.getModel().getReporting().getOutputDirectory();
788-
File reportOutputDir = new File(reportOutputDirectory);
789-
if (!reportOutputDir.exists()) {
790-
reportOutputDir.mkdirs();
791-
}
792-
String pathname = reportOutputDirectory + File.separator + "godClassChart.js";
793-
794-
File scriptFile = new File(pathname);
795-
try {
796-
scriptFile.createNewFile();
797-
} catch (IOException e) {
798-
log.error("Failure creating God Class chart script file", e);
799-
}
800-
801-
try (BufferedWriter writer = new BufferedWriter(new FileWriter(scriptFile))) {
802-
writer.write(javascriptCode);
803-
} catch (IOException e) {
804-
log.error("Error writing chart script file", e);
805-
}
780+
return scriptStart + bubbleChartData + scriptEnd;
806781
}
807782

808-
void writeGCBOGchartJs(List<RankedDisharmony> rankedDisharmonies, int maxPriority) {
783+
String writeGCBOGchartJs(List<RankedDisharmony> rankedDisharmonies, int maxPriority) {
809784
GraphDataGenerator graphDataGenerator = new GraphDataGenerator();
810785
String scriptStart = graphDataGenerator.getCBOScriptStart();
811786
String bubbleChartData = graphDataGenerator.generateCBOBubbleChartData(rankedDisharmonies, maxPriority);
812787
String scriptEnd = graphDataGenerator.getCBOScriptEnd();
813788

814-
String javascriptCode = scriptStart + bubbleChartData + scriptEnd;
815-
816-
String reportOutputDirectory = project.getModel().getReporting().getOutputDirectory();
817-
File reportOutputDir = new File(reportOutputDirectory);
818-
if (!reportOutputDir.exists()) {
819-
reportOutputDir.mkdirs();
820-
}
821-
String pathname = reportOutputDirectory + File.separator + "cboChart.js";
822-
823-
File scriptFile = new File(pathname);
824-
try {
825-
scriptFile.createNewFile();
826-
} catch (IOException e) {
827-
log.error("Failure creating CBO chart script file", e);
828-
}
829-
830-
try (BufferedWriter writer = new BufferedWriter(new FileWriter(scriptFile))) {
831-
writer.write(javascriptCode);
832-
} catch (IOException e) {
833-
log.error("Error writing CBO chart script file", e);
834-
}
789+
return scriptStart + bubbleChartData + scriptEnd;
835790
}
836791

837792
void renderCycleImage(Graph<String, DefaultWeightedEdge> classGraph, RankedCycle cycle, Sink mainSink) {

0 commit comments

Comments
 (0)