From 6119e1158df222129a9dac633fd7e75c6a62a433 Mon Sep 17 00:00:00 2001 From: Carter Kozak Date: Tue, 7 Jun 2022 10:40:18 -0400 Subject: [PATCH 1/2] Fix class hierarchy safe-logging error message agreement Previously the safety referenced in the message did not agree with the failure. --- .../baseline/errorprone/IllegalSafeLoggingArgument.java | 3 +-- .../baseline/errorprone/IllegalSafeLoggingArgumentTest.java | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/IllegalSafeLoggingArgument.java b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/IllegalSafeLoggingArgument.java index d68671954..df72f2ea8 100644 --- a/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/IllegalSafeLoggingArgument.java +++ b/baseline-error-prone/src/main/java/com/palantir/baseline/errorprone/IllegalSafeLoggingArgument.java @@ -354,8 +354,7 @@ public Description matchClass(ClassTree tree, VisitorState state) { } return buildDescription(tree) .setMessage(String.format( - "Dangerous type: annotated '%s' but ancestors declare '%s'.", - directSafety, SafetyAnnotations.getSafety(tree, state))) + "Dangerous type: annotated '%s' but ancestors declare '%s'.", directSafety, ancestorSafety)) .build(); } } diff --git a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/IllegalSafeLoggingArgumentTest.java b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/IllegalSafeLoggingArgumentTest.java index 3943393e4..5a05154b6 100644 --- a/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/IllegalSafeLoggingArgumentTest.java +++ b/baseline-error-prone/src/test/java/com/palantir/baseline/errorprone/IllegalSafeLoggingArgumentTest.java @@ -1768,7 +1768,8 @@ public void testSubclassWithLenientSafety() { "import com.palantir.logsafe.*;", "class Test {", " @Unsafe interface UnsafeClass {}", - " // BUG: Diagnostic contains: Dangerous type: annotated 'SAFE' but ancestors declare 'SAFE'.", + " // BUG: Diagnostic contains: " + + "Dangerous type: annotated 'SAFE' but ancestors declare 'UNSAFE'.", " @Safe interface SafeSubclass extends UnsafeClass {}", "}") .doTest(); From 1e00f78f4018800ba54d462b01dac4007f17a98a Mon Sep 17 00:00:00 2001 From: svc-changelog Date: Tue, 7 Jun 2022 14:43:36 +0000 Subject: [PATCH 2/2] Add generated changelog entries --- changelog/@unreleased/pr-2295.v2.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelog/@unreleased/pr-2295.v2.yml diff --git a/changelog/@unreleased/pr-2295.v2.yml b/changelog/@unreleased/pr-2295.v2.yml new file mode 100644 index 000000000..46e5b19a7 --- /dev/null +++ b/changelog/@unreleased/pr-2295.v2.yml @@ -0,0 +1,5 @@ +type: fix +fix: + description: Fix class hierarchy safe-logging error message agreement + links: + - https://github.com/palantir/gradle-baseline/pull/2295