Skip to content

Commit 1129cbe

Browse files
committed
feat: improve test coverage report
improve the test coverage report with a lightweight dashboard-style UI - add coverage summary cards for classes and methods - add method coverage breakdown by access modifier - show covered, partial, missing, and optional methods distinctly - display matching test methods for covered methods - exclude private methods from required test coverage - make class details expandable for easier inspection - add responsive styling for smaller screens - add project attribution and MIT license footer
1 parent fd3b6a5 commit 1129cbe

4 files changed

Lines changed: 677 additions & 71 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ dist/
88

99
*.patch
1010
*.diff
11+
test_coverage_report.html

‎checkstyle/src/main/java/fun/ninth/inventory/checkstyle/MethodInventoryCheck.java‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ public void visitToken(DetailAST detailAST) {
2929
}
3030
case TokenTypes.METHOD_DEF: {
3131
String method = Objects.requireNonNull(detailAST.findFirstToken(TokenTypes.IDENT)).getText();
32-
System.out.printf("[DEBUG] [Method Inventory Check] %s %s %s%n", currentClass, currentPackage, method);
32+
DetailAST modifiers = detailAST.findFirstToken(TokenTypes.MODIFIERS);
33+
String accessModifier = getAccessModifier(modifiers);
34+
System.out.printf("%s,%s,%s,%s%n", currentPackage, currentClass, method, accessModifier);
3335
break;
3436
}
3537
}
@@ -50,6 +52,22 @@ public int[] getDefaultTokens() {
5052
return new int[] { TokenTypes.PACKAGE_DEF, TokenTypes.CLASS_DEF, TokenTypes.METHOD_DEF };
5153
}
5254

55+
private String getAccessModifier(DetailAST modifiers) {
56+
if (modifiers == null) {
57+
return "package-private";
58+
}
59+
if (modifiers.findFirstToken(TokenTypes.LITERAL_PUBLIC) != null) {
60+
return "public";
61+
}
62+
if (modifiers.findFirstToken(TokenTypes.LITERAL_PROTECTED) != null) {
63+
return "protected";
64+
}
65+
if (modifiers.findFirstToken(TokenTypes.LITERAL_PRIVATE) != null) {
66+
return "private";
67+
}
68+
return "package-private";
69+
}
70+
5371
private String getFullIdentifier(DetailAST detailAST) {
5472
return switch (detailAST.getType()) {
5573
case TokenTypes.IDENT -> detailAST.getText();

0 commit comments

Comments
 (0)