@@ -419,12 +419,14 @@ public StringBuilder generateReport(
419419 return stringBuilder ;
420420 }
421421
422+ /** Reads the repository's remote URL from the project Git metadata. */
422423 static String getRepoUrl (String projectBaseDir ) throws Exception {
423424 try (GitLogReader glr = new GitLogReader (new File (projectBaseDir ))) {
424425 return glr .getRepoUrl ();
425426 }
426427 }
427428
429+ /** Builds the report navigation menu for the available graphs, findings, and cycles. */
428430 StringBuilder createMenu (
429431 List <DisharmonySpec > disharmonySpecs ,
430432 Map <String , List <RankedDisharmony >> rankedDisharmoniesByAnchor ,
@@ -478,10 +480,13 @@ StringBuilder createMenu(
478480 return menu ;
479481 }
480482
483+ /** Extension hook for adding a class-map entry to the navigation menu. */
481484 void renderClassMapMenu (StringBuilder stringBuilder ) {}
482485
486+ /** Extension hook for adding a package-map entry to the navigation menu. */
483487 void renderPackageMapMenu (StringBuilder stringBuilder ) {}
484488
489+ /** Renders the class-cycle summary and the largest cycle's details. */
485490 private String renderCycles (List <RankedCycle > rankedCycles , String repoUrl , CodebaseGraphDTO codebaseGraphDTO ) {
486491 StringBuilder stringBuilder = new StringBuilder ();
487492 stringBuilder .append (renderClassCycleSummary (rankedCycles ));
@@ -494,6 +499,7 @@ private String renderCycles(List<RankedCycle> rankedCycles, String repoUrl, Code
494499 return stringBuilder .toString ();
495500 }
496501
502+ /** Renders the prioritized class relationships whose removal breaks cycles. */
497503 private String renderClassEdgeDisharmonies (
498504 List <RankedDisharmony > classRelationshipDisharmonies ,
499505 List <RankedDisharmony > packageRelationshipDisharmonies ,
@@ -548,6 +554,7 @@ private String renderClassEdgeDisharmonies(
548554 return stringBuilder .toString ();
549555 }
550556
557+ /** Renders the prioritized package relationships whose removal breaks cycles. */
551558 private String renderPackageEdgeDisharmonies (
552559 List <RankedDisharmony > edgeDisharmonies , String repoUrl , CodebaseGraphDTO codebaseGraphDTO ) {
553560 StringBuilder stringBuilder = new StringBuilder ();
@@ -599,6 +606,7 @@ private String renderPackageEdgeDisharmonies(
599606 return stringBuilder .toString ();
600607 }
601608
609+ /** Returns column headings for the class-relationship table. */
602610 private String [] getClassRelationshipDisharmonyTableHeadings () {
603611 return new String [] {
604612 "Class Relationship" ,
@@ -610,6 +618,7 @@ private String[] getClassRelationshipDisharmonyTableHeadings() {
610618 };
611619 }
612620
621+ /** Returns column headings for the package-relationship table. */
613622 private String [] getPackageRelationshipDisharmonyTableHeadings () {
614623 return new String [] {
615624 "Package Relationship" ,
@@ -656,6 +665,7 @@ String[] getPackageRelationshipDisharmony(
656665 };
657666 }
658667
668+ /** Renders summary rows for the ranked class cycles. */
659669 private String renderClassCycleSummary (List <RankedCycle > rankedCycles ) {
660670 StringBuilder stringBuilder = new StringBuilder ();
661671
@@ -704,6 +714,7 @@ String renderClassEdge(DefaultWeightedEdge edge) {
704714 .toString ();
705715 }
706716
717+ /** Renders a weighted class edge with repository links and removal markers. */
707718 private String renderClassEdge (DefaultWeightedEdge edge , String repoUrl , CodebaseGraphDTO codebaseGraphDTO ) {
708719 StringBuilder edgesToCut = new StringBuilder ();
709720 String [] vertexes = extractVertexes (edge );
@@ -730,6 +741,7 @@ private String renderClassEdge(DefaultWeightedEdge edge, String repoUrl, Codebas
730741 .toString ();
731742 }
732743
744+ /** Renders a weighted package edge with removal markers. */
733745 private String renderPackageEdge (DefaultWeightedEdge edge , String repoUrl , CodebaseGraphDTO codebaseGraphDTO ) {
734746 StringBuilder edgesToCut = new StringBuilder ();
735747 String [] vertexes = extractVertexes (edge );
@@ -756,6 +768,7 @@ private String renderPackageEdge(DefaultWeightedEdge edge, String repoUrl, Codeb
756768 .toString ();
757769 }
758770
771+ /** Links a class label to its source file when a source-path mapping is available. */
759772 String hyperlinkClass (String className , String repoUrl , CodebaseGraphDTO codebaseGraphDTO ) {
760773 String path = codebaseGraphDTO .getClassToSourceFilePathMapping ().get (className );
761774 if (path == null || path .isBlank ()) {
@@ -783,6 +796,7 @@ static String escapeHtmlAttribute(String value) {
783796 return escapeHtmlLabel (value ).replace ("\" " , """ ).replace ("'" , "'" );
784797 }
785798
799+ /** Returns column headings for the class-cycle summary table. */
786800 private String [] getClassCycleSummaryTableHeadings () {
787801 return new String [] {"Cycle Name" , "Priority" , "Class Count" , "Relationship Count" };
788802 }
@@ -798,6 +812,7 @@ String[] getRankedCycleSummaryData(RankedCycle rankedCycle) {
798812 };
799813 }
800814
815+ /** Renders the visualization and relationship table for one class cycle. */
801816 private String renderSingleCycle (RankedCycle cycle , String repoUrl , CodebaseGraphDTO codebaseGraphDTO ) {
802817 StringBuilder stringBuilder = new StringBuilder ();
803818
@@ -878,18 +893,22 @@ private String renderSingleCycle(RankedCycle cycle, String repoUrl, CodebaseGrap
878893 return stringBuilder .toString ();
879894 }
880895
896+ /** Extension hook for rendering class-graph visuals. */
881897 public String renderClassGraphVisuals (String repoUrl , CodebaseGraphDTO codebaseGraphDTO ) {
882898 return "" ; // empty on purpose
883899 }
884900
901+ /** Extension hook for rendering package-graph visuals. */
885902 public String renderPackageGraphVisuals (String repoUrl , CodebaseGraphDTO codebaseGraphDTO ) {
886903 return "" ; // empty on purpose
887904 }
888905
906+ /** Extension hook for rendering a class-cycle visualization. */
889907 public String renderClassCycleVisuals (RankedCycle cycle , String repoUrl , CodebaseGraphDTO codebaseGraphDTO ) {
890908 return "" ; // empty on purpose
891909 }
892910
911+ /** Renders a table cell, right-aligning numeric and date-like values. */
893912 String drawTableCell (String rowData ) {
894913 if (isNumber (rowData ) || isDateTime (rowData )) {
895914 return "<td align=\" right\" >" + rowData + "</td>\n " ;
@@ -898,30 +917,37 @@ String drawTableCell(String rowData) {
898917 }
899918 }
900919
920+ /** Reports whether a table value is a signed integer or decimal number. */
901921 boolean isNumber (String rowData ) {
902922 return rowData .matches ("-?\\ d+(\\ .\\ d+)?" );
903923 }
904924
925+ /** Reports whether a table value uses the localized date-time delimiter. */
905926 boolean isDateTime (String rowData ) {
906927 return rowData .contains (", " );
907928 }
908929
930+ /** Extension hook for rendering the HTML title element. */
909931 public String printTitle (String projectName , String projectVersion ) {
910932 return "" ; // empty on purpose
911933 }
912934
935+ /** Extension hook for rendering additional HTML head content. */
913936 public String printHead () {
914937 return "" ; // empty on purpose
915938 }
916939
940+ /** Extension hook for rendering script elements. */
917941 String printScripts () {
918942 return "" ; // empty on purpose
919943 }
920944
945+ /** Returns the opening body tag used by the report page. */
921946 public String printOpenBodyTag () {
922947 return " <body class=\" composite\" >\n " ;
923948 }
924949
950+ /** Returns the opening banner and breadcrumb markup. */
925951 public String printBreadcrumbs () {
926952 return """
927953 <div id="banner">
@@ -931,6 +957,7 @@ public String printBreadcrumbs() {
931957 """ ;
932958 }
933959
960+ /** Renders the project heading with links to RefactorFirst and the analyzed repository. */
934961 public String printProjectHeader (String projectName , String projectVersion , String projectBaseDir )
935962 throws Exception {
936963 String repoUrl = getRepoUrl (projectBaseDir );
@@ -945,6 +972,7 @@ public String printProjectHeader(String projectName, String projectVersion, Stri
945972 + projectVersion + "</a></h1>\n " ;
946973 }
947974
975+ /** Renders the report footer with the current publication timestamp. */
948976 public String printProjectFooter () {
949977 return " <div class=\" clear\" >\n " + " <hr/>\n " + " </div>\n "
950978 + "<span id=\" publishDate\" >Last Published: "
@@ -953,6 +981,7 @@ public String printProjectFooter() {
953981 + " <hr/>\n " + " </div>\n " + "</span>" ;
954982 }
955983
984+ /** Renders links for common RefactorFirst GitHub actions. */
956985 String renderGithubButtons () {
957986 return """
958987 <div align="center">
@@ -965,6 +994,7 @@ String renderGithubButtons() {
965994 </div>""" ;
966995 }
967996
997+ /** Returns the base filename for the generated report. */
968998 String getOutputName () {
969999 // This report will generate simple-report.html when invoked in a project with `mvn site`
9701000 return "refactor-first-report" ;
@@ -1099,6 +1129,7 @@ public String renderDisharmonyInfo(
10991129 return sb .toString ();
11001130 }
11011131
1132+ /** Removes package qualifiers and verbose generic bounds from a method signature. */
11021133 String getSimpleMethodSignature (String sig ) {
11031134 if (sig == null ) {
11041135 return null ;
@@ -1149,6 +1180,7 @@ String getSimpleMethodSignature(String sig) {
11491180 // upWaitQueue(com.tonikelope.megabasterd.Transference) ↔
11501181 // TransferenceManager.downWaitQueue(com.tonikelope.megabasterd.Transference)
11511182 // should become upWaitQueue(Transference) ↔ TransferenceManager.downWaitQueue(Transference)
1183+ /** Simplifies fully qualified parameter types in a duplication-partner description. */
11521184 String simplifyDuplicatePartners (String duplicationPartners ) {
11531185 if (duplicationPartners == null ) {
11541186 return null ;
@@ -1175,10 +1207,12 @@ String simplifyDuplicatePartners(String duplicationPartners) {
11751207 return String .join (" ↔ " , simplifiedParts );
11761208 }
11771209
1210+ /** Extension hook for rendering a chart for one disharmony category. */
11781211 String renderDisharmonyChart (String anchorId , String title , List <RankedDisharmony > ranked , int maxPriority ) {
11791212 return "" ; // empty on purpose; overridden in HtmlReport
11801213 }
11811214
1215+ /** Returns the simple class name from a fully qualified class name. */
11821216 String getClassName (String fqn ) {
11831217 // handle no package
11841218 if (!fqn .contains ("." )) {
@@ -1189,6 +1223,7 @@ String getClassName(String fqn) {
11891223 return fqn .substring (lastIndex + 1 );
11901224 }
11911225
1226+ /** Extracts the source and target vertex labels from an edge's string representation. */
11921227 static String [] extractVertexes (DefaultWeightedEdge edge ) {
11931228 return edge .toString ().replace ("(" , "" ).replace (")" , "" ).split (":" );
11941229 }
@@ -1201,6 +1236,7 @@ static final class DisharmonySpec {
12011236 final String problem ;
12021237 final String solution ;
12031238
1239+ /** Creates the display metadata for one supported disharmony category. */
12041240 DisharmonySpec (
12051241 String type , String anchorId , String title , boolean methodLevel , String problem , String solution ) {
12061242 this .type = type ;
@@ -1211,26 +1247,32 @@ static final class DisharmonySpec {
12111247 this .solution = solution ;
12121248 }
12131249
1250+ /** Returns the disharmony type identifier. */
12141251 String type () {
12151252 return type ;
12161253 }
12171254
1255+ /** Returns the HTML anchor identifier. */
12181256 String anchorId () {
12191257 return anchorId ;
12201258 }
12211259
1260+ /** Returns the display title. */
12221261 String title () {
12231262 return title ;
12241263 }
12251264
1265+ /** Reports whether the disharmony describes methods rather than classes. */
12261266 boolean methodLevel () {
12271267 return methodLevel ;
12281268 }
12291269
1270+ /** Returns the problem description. */
12301271 String problem () {
12311272 return problem ;
12321273 }
12331274
1275+ /** Returns the recommended remediation. */
12341276 String solution () {
12351277 return solution ;
12361278 }
0 commit comments