Skip to content

Commit ac7ed18

Browse files
committed
use platform-specific line separator for hint messages
The synthetic class hint message was using hardcoded \n line separators, which caused test failures on Windows CI. Windows uses \r\n as line separator, but the test framework splits violation messages using System.lineSeparator(). This mismatch prevented proper message parsing and matching in integration tests. Changed SYNTHETIC_CLASS_HINT_MESSAGE from a static constant with hardcoded \n to a dynamic method getSyntheticClassHintMessage() that uses System.lineSeparator(). This ensures the hint message uses the correct platform-specific line separator, allowing tests to pass on all platforms (macOS, Linux, and Windows). Signed-off-by: chadongmin <cdm2883@naver.com>
1 parent fc28063 commit ac7ed18

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

archunit/src/main/java/com/tngtech/archunit/lang/conditions/ArchConditions.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,13 +1308,15 @@ public static <T extends HasDescription & HasSourceCodeLocation> ConditionByPred
13081308
.describeEventsBy((predicateDescription, satisfied) -> (satisfied ? "has " : "does not have ") + predicateDescription);
13091309
}
13101310

1311-
private static final String SYNTHETIC_CLASS_HINT_MESSAGE =
1312-
"\n\nHint: The failing class appears to be a synthetic or anonymous class " +
1313-
"generated by the compiler (e.g., from lambdas, switch expressions, or inner classes). " +
1314-
"To exclude these from your rule, consider adding:\n" +
1315-
" .that().doNotHaveModifier(JavaModifier.SYNTHETIC)\n" +
1316-
"or:\n" +
1317-
" .that().areNotAnonymousClasses()";
1311+
private static String getSyntheticClassHintMessage() {
1312+
String lineSeparator = System.lineSeparator();
1313+
return lineSeparator + lineSeparator + "Hint: The failing class appears to be a synthetic or anonymous class " +
1314+
"generated by the compiler (e.g., from lambdas, switch expressions, or inner classes). " +
1315+
"To exclude these from your rule, consider adding:" + lineSeparator +
1316+
" .that().doNotHaveModifier(JavaModifier.SYNTHETIC)" + lineSeparator +
1317+
"or:" + lineSeparator +
1318+
" .that().areNotAnonymousClasses()";
1319+
}
13181320

13191321
/**
13201322
* Like {@link #have(DescribedPredicate)}, but adds a helpful hint when the condition fails on synthetic or anonymous classes.
@@ -1332,7 +1334,7 @@ public void check(JavaClass javaClass, ConditionEvents events) {
13321334
String message;
13331335
if (!satisfied && isSyntheticOrAnonymous(javaClass)) {
13341336
message = javaClass.getDescription() + " " + baseMessage +
1335-
" in " + javaClass.getSourceCodeLocation() + SYNTHETIC_CLASS_HINT_MESSAGE;
1337+
" in " + javaClass.getSourceCodeLocation() + getSyntheticClassHintMessage();
13361338
} else {
13371339
message = javaClass.getDescription() + " " + baseMessage +
13381340
" in " + javaClass.getSourceCodeLocation();

0 commit comments

Comments
 (0)