Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,440 changes: 720 additions & 720 deletions .refactorfirst/refactor-first.json

Large diffs are not rendered by default.

19 changes: 14 additions & 5 deletions report/src/main/java/org/hjug/refactorfirst/report/HtmlReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,11 @@ String buildClassGraphDot(
return toJavaScriptTemplateLiteral(buildRawClassGraphDot(classGraph, repoUrl, codebaseGraphDTO));
}

/**
* Appends class DOT nodes, omitting sink-only anonymous or synthetic vertices and labels that
* match their node IDs. Includes source-link attributes supplied by the report and highlights
* classes selected for removal.
*/
private void renderClassVertices(
Graph<String, DefaultWeightedEdge> classGraph,
String repoUrl,
Expand All @@ -609,19 +614,23 @@ private void renderClassVertices(
continue;
}

dot.append(renderSafeNodeId(vertex, classGraph, codebaseGraphDTO));
String safeNodeId = renderSafeNodeId(vertex, classGraph, codebaseGraphDTO);
dot.append(safeNodeId);

dot.append(" [");
dot.append(hyperlinkClassForDot(vertex, repoUrl, codebaseGraphDTO));

String label;
if (isAnonymousFqn(vertex)) {
// Kotlin "<anonymous>" renders under the enclosing source file's base name as the
// owner with $ as the enclosing-class separator (escaped for DOT).
dot.append(" label=\"")
.append(escapeDotQuoted(anonymousOwnerLabel(vertex, codebaseGraphDTO)))
.append("\"");
label = escapeDotQuoted(anonymousOwnerLabel(vertex, codebaseGraphDTO));
} else {
dot.append(" label=\"").append(escapeDotQuoted(className)).append("\"");
label = escapeDotQuoted(className);
}

if (!label.equals(safeNodeId)) {
dot.append(" label=\"").append(label).append("\"");
}

if (classesToRemove.contains(vertex)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ public void execute(
// copyViewerResources(dotRefactorFirstDir);
}

/**
* Intentionally excluding hyperlinks in DOT to reduce JSON file size
*
* @param fqClassName The fully qualified class name
* @param repoUrl The repo URL
* @param codebaseGraphDTO The DTO containing the codebase graph
*/
String hyperlinkClassForDot(String fqClassName, String repoUrl, CodebaseGraphDTO codebaseGraphDTO) {
return "";
}
Comment thread
jimbethancourt marked this conversation as resolved.
Resolved

/** Copies the Mustache template and browser viewer into the report directory. */
private void copyViewerResources(Path targetDir) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
*/
class HtmlReportKotlinTest {

/** Verifies cycle DOT preserves Kotlin source links and edge weights while omitting redundant labels. */
@DisplayName("HtmlReport.buildClassCycleDot emits .kt URLs from Kotlin source-path mapping")
@Test
void buildClassCycleDot_kotlinSourcePaths() {
Expand Down Expand Up @@ -95,9 +96,9 @@ void buildClassCycleDot_kotlinSourcePaths() {
KotlinCycleA -\\u003E KotlinCycleB [ label = "2" weight = "2" ];
KotlinCycleB -\\u003E KotlinCycleC [ label = "1" weight = "1" ];
KotlinCycleC -\\u003E KotlinCycleA [ label = "1" weight = "1" ];
KotlinCycleA [URL="https://github.com/refactorfirst/RefactorFirst/blob/src/main/kotlin/com/kotlin/cycles/KotlinCycleA.kt" target="_blank" label="KotlinCycleA"];
KotlinCycleB [URL="https://github.com/refactorfirst/RefactorFirst/blob/src/main/kotlin/com/kotlin/cycles/KotlinCycleB.kt" target="_blank" label="KotlinCycleB"];
KotlinCycleC [URL="https://github.com/refactorfirst/RefactorFirst/blob/src/main/kotlin/com/kotlin/cycles/KotlinCycleC.kt" target="_blank" label="KotlinCycleC"];
KotlinCycleA [URL="https://github.com/refactorfirst/RefactorFirst/blob/src/main/kotlin/com/kotlin/cycles/KotlinCycleA.kt" target="_blank"];
KotlinCycleB [URL="https://github.com/refactorfirst/RefactorFirst/blob/src/main/kotlin/com/kotlin/cycles/KotlinCycleB.kt" target="_blank"];
KotlinCycleC [URL="https://github.com/refactorfirst/RefactorFirst/blob/src/main/kotlin/com/kotlin/cycles/KotlinCycleC.kt" target="_blank"];
}`;\
""";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void getDescription() {
mavenReport.getDescription(Locale.getDefault()));
}

/** Verifies cycle DOT preserves Java source links and edge weights while omitting redundant labels. */
@Test
void buildClassCycleDot() {
Graph<String, DefaultWeightedEdge> classGraph = new DefaultDirectedWeightedGraph<>(DefaultWeightedEdge.class);
Expand Down Expand Up @@ -66,9 +67,9 @@ void buildClassCycleDot() {
+ "A -\\u003E B [ label = \"2\" weight = \"2\" ];\n"
+ "B -\\u003E C [ label = \"1\" weight = \"1\" ];\n"
+ "C -\\u003E A [ label = \"1\" weight = \"1\" ];\n"
+ "A [URL=\"https://github.com/refactorfirst/RefactorFirst/blob/src/main/java/org/hjug/refactorfirst/A.java\" target=\"_blank\" label=\"A\"];\n"
+ "B [URL=\"https://github.com/refactorfirst/RefactorFirst/blob/src/main/java/org/hjug/refactorfirst/B.java\" target=\"_blank\" label=\"B\"];\n"
+ "C [URL=\"https://github.com/refactorfirst/RefactorFirst/blob/src/main/java/org/hjug/refactorfirst/C.java\" target=\"_blank\" label=\"C\"];\n"
+ "A [URL=\"https://github.com/refactorfirst/RefactorFirst/blob/src/main/java/org/hjug/refactorfirst/A.java\" target=\"_blank\"];\n"
+ "B [URL=\"https://github.com/refactorfirst/RefactorFirst/blob/src/main/java/org/hjug/refactorfirst/B.java\" target=\"_blank\"];\n"
+ "C [URL=\"https://github.com/refactorfirst/RefactorFirst/blob/src/main/java/org/hjug/refactorfirst/C.java\" target=\"_blank\"];\n"
+ "}`;";

assertEquals(expectedDot, dot);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ void given_repoWithOrigin_when_reportGenerated_then_bubbleUrlsPointToSourceFiles
complexMethod
.append(" if (a > ")
.append(i)
.append(") { for (int j = 0; j < a; j++) { if (j % 2 == 0 && b) { c += j; } else { c -= j; } } }\n");
.append(
") { for (int j = 0; j < a; j++) { if (j % 2 == 0 && b) { c += j; } else { c -= j; } } }\n");
}
Files.writeString(
new File(srcDir, "ComplexService.java").toPath(),
Expand Down
Loading