From 6a4eac1f86b028f70c121aeed017dc77e3cbf8be Mon Sep 17 00:00:00 2001 From: Guillaume Toison <86775455+gtoison@users.noreply.github.com> Date: Tue, 30 Aug 2022 00:59:52 +0100 Subject: [PATCH] fix: add missing BugPattern links (#196) The default linkType in the BugPattern annotation is AUTOGENERATED and this generates incorrect links such as https://errorprone.info/bugpattern/Slf4jSignOnlyFormat Co-authored-by: gtoison --- .../jp/skypencil/errorprone/slf4j/DoNotPublishSlf4jLogger.java | 3 +++ .../skypencil/errorprone/slf4j/DoNotUseStaticSlf4jLogger.java | 3 +++ .../jp/skypencil/errorprone/slf4j/FormatShouldBeConst.java | 3 +++ .../java/jp/skypencil/errorprone/slf4j/IllegalPassedClass.java | 3 +++ .../jp/skypencil/errorprone/slf4j/ManuallyProvidedMessage.java | 3 +++ .../jp/skypencil/errorprone/slf4j/PlaceholderMismatch.java | 3 +++ .../jp/skypencil/errorprone/slf4j/PreferFinalSlf4jLogger.java | 3 +++ .../java/jp/skypencil/errorprone/slf4j/SignOnlyFormat.java | 3 +++ 8 files changed, 24 insertions(+) diff --git a/src/main/java/jp/skypencil/errorprone/slf4j/DoNotPublishSlf4jLogger.java b/src/main/java/jp/skypencil/errorprone/slf4j/DoNotPublishSlf4jLogger.java index 6f917eb4..2caeb820 100644 --- a/src/main/java/jp/skypencil/errorprone/slf4j/DoNotPublishSlf4jLogger.java +++ b/src/main/java/jp/skypencil/errorprone/slf4j/DoNotPublishSlf4jLogger.java @@ -8,6 +8,7 @@ import com.google.auto.service.AutoService; import com.google.errorprone.BugPattern; import com.google.errorprone.VisitorState; +import com.google.errorprone.BugPattern.LinkType; import com.google.errorprone.bugpatterns.BugChecker; import com.google.errorprone.bugpatterns.BugChecker.VariableTreeMatcher; import com.google.errorprone.fixes.SuggestedFix; @@ -21,6 +22,8 @@ name = "Slf4jLoggerShouldBePrivate", summary = "Do not publish Logger field, it should be private", tags = {"SLF4J"}, + link = "https://github.com/KengoTODA/findbugs-slf4j#slf4j_logger_should_be_private", + linkType = LinkType.CUSTOM, severity = WARNING) @AutoService(BugChecker.class) public class DoNotPublishSlf4jLogger extends BugChecker implements VariableTreeMatcher { diff --git a/src/main/java/jp/skypencil/errorprone/slf4j/DoNotUseStaticSlf4jLogger.java b/src/main/java/jp/skypencil/errorprone/slf4j/DoNotUseStaticSlf4jLogger.java index 15147271..eae912e8 100644 --- a/src/main/java/jp/skypencil/errorprone/slf4j/DoNotUseStaticSlf4jLogger.java +++ b/src/main/java/jp/skypencil/errorprone/slf4j/DoNotUseStaticSlf4jLogger.java @@ -9,6 +9,7 @@ import com.google.common.base.CaseFormat; import com.google.errorprone.BugPattern; import com.google.errorprone.VisitorState; +import com.google.errorprone.BugPattern.LinkType; import com.google.errorprone.bugpatterns.BugChecker; import com.google.errorprone.bugpatterns.BugChecker.VariableTreeMatcher; import com.google.errorprone.fixes.SuggestedFix; @@ -24,6 +25,8 @@ name = "Slf4jLoggerShouldBeNonStatic", summary = "Do not use static Logger field, use non-static one instead", tags = {"SLF4J"}, + link = "https://github.com/KengoTODA/findbugs-slf4j#slf4j_logger_should_be_non_static", + linkType = LinkType.CUSTOM, severity = SUGGESTION) @AutoService(BugChecker.class) public class DoNotUseStaticSlf4jLogger extends BugChecker implements VariableTreeMatcher { diff --git a/src/main/java/jp/skypencil/errorprone/slf4j/FormatShouldBeConst.java b/src/main/java/jp/skypencil/errorprone/slf4j/FormatShouldBeConst.java index 7deced2a..7f2bd5b2 100644 --- a/src/main/java/jp/skypencil/errorprone/slf4j/FormatShouldBeConst.java +++ b/src/main/java/jp/skypencil/errorprone/slf4j/FormatShouldBeConst.java @@ -5,6 +5,7 @@ import com.google.auto.service.AutoService; import com.google.errorprone.BugPattern; import com.google.errorprone.VisitorState; +import com.google.errorprone.BugPattern.LinkType; import com.google.errorprone.bugpatterns.BugChecker; import com.google.errorprone.bugpatterns.BugChecker.MethodInvocationTreeMatcher; import com.google.errorprone.matchers.CompileTimeConstantExpressionMatcher; @@ -18,6 +19,8 @@ name = "Slf4jFormatShouldBeConst", summary = "Format of SLF4J logging should be constant value", tags = {"SLF4J"}, + link = "https://github.com/KengoTODA/findbugs-slf4j#slf4j_format_should_be_const", + linkType = LinkType.CUSTOM, severity = ERROR) @AutoService(BugChecker.class) public class FormatShouldBeConst extends BugChecker implements MethodInvocationTreeMatcher { diff --git a/src/main/java/jp/skypencil/errorprone/slf4j/IllegalPassedClass.java b/src/main/java/jp/skypencil/errorprone/slf4j/IllegalPassedClass.java index a3772bc4..c4739bde 100644 --- a/src/main/java/jp/skypencil/errorprone/slf4j/IllegalPassedClass.java +++ b/src/main/java/jp/skypencil/errorprone/slf4j/IllegalPassedClass.java @@ -6,6 +6,7 @@ import com.google.errorprone.BugPattern; import com.google.errorprone.ErrorProneVersion; import com.google.errorprone.VisitorState; +import com.google.errorprone.BugPattern.LinkType; import com.google.errorprone.bugpatterns.BugChecker; import com.google.errorprone.bugpatterns.BugChecker.MethodInvocationTreeMatcher; import com.google.errorprone.fixes.SuggestedFix; @@ -33,6 +34,8 @@ name = "Slf4jIllegalPassedClass", summary = "LoggerFactory.getLogger(Class) should get the class that defines variable", tags = {"SLF4J"}, + link = "https://github.com/KengoTODA/findbugs-slf4j#slf4j_illegal_passed_class", + linkType = LinkType.CUSTOM, severity = WARNING) @AutoService(BugChecker.class) public class IllegalPassedClass extends BugChecker implements MethodInvocationTreeMatcher { diff --git a/src/main/java/jp/skypencil/errorprone/slf4j/ManuallyProvidedMessage.java b/src/main/java/jp/skypencil/errorprone/slf4j/ManuallyProvidedMessage.java index 53f74d25..6ebe50b2 100644 --- a/src/main/java/jp/skypencil/errorprone/slf4j/ManuallyProvidedMessage.java +++ b/src/main/java/jp/skypencil/errorprone/slf4j/ManuallyProvidedMessage.java @@ -5,6 +5,7 @@ import com.google.auto.service.AutoService; import com.google.errorprone.BugPattern; import com.google.errorprone.VisitorState; +import com.google.errorprone.BugPattern.LinkType; import com.google.errorprone.bugpatterns.BugChecker; import com.google.errorprone.bugpatterns.BugChecker.MethodInvocationTreeMatcher; import com.google.errorprone.matchers.Description; @@ -21,6 +22,8 @@ summary = "Do not log message returned from Throwable#getMessage and Throwable#getLocalizedMessage", tags = {"SLF4J"}, + link = "https://github.com/KengoTODA/findbugs-slf4j#slf4j_manually_provided_message", + linkType = LinkType.CUSTOM, severity = ERROR) @AutoService(BugChecker.class) public class ManuallyProvidedMessage extends BugChecker implements MethodInvocationTreeMatcher { diff --git a/src/main/java/jp/skypencil/errorprone/slf4j/PlaceholderMismatch.java b/src/main/java/jp/skypencil/errorprone/slf4j/PlaceholderMismatch.java index b1672dff..8b08a639 100644 --- a/src/main/java/jp/skypencil/errorprone/slf4j/PlaceholderMismatch.java +++ b/src/main/java/jp/skypencil/errorprone/slf4j/PlaceholderMismatch.java @@ -6,6 +6,7 @@ import com.google.auto.service.AutoService; import com.google.errorprone.BugPattern; import com.google.errorprone.VisitorState; +import com.google.errorprone.BugPattern.LinkType; import com.google.errorprone.bugpatterns.BugChecker; import com.google.errorprone.bugpatterns.BugChecker.MethodInvocationTreeMatcher; import com.google.errorprone.matchers.Description; @@ -20,6 +21,8 @@ name = "Slf4jPlaceholderMismatch", summary = "Count of placeholder does not match with count of parameter", tags = {"SLF4J"}, + link = "https://github.com/KengoTODA/findbugs-slf4j#slf4j_place_holder_mismatch", + linkType = LinkType.CUSTOM, severity = ERROR) @AutoService(BugChecker.class) public class PlaceholderMismatch extends BugChecker implements MethodInvocationTreeMatcher { diff --git a/src/main/java/jp/skypencil/errorprone/slf4j/PreferFinalSlf4jLogger.java b/src/main/java/jp/skypencil/errorprone/slf4j/PreferFinalSlf4jLogger.java index 19260e65..e24f3c40 100644 --- a/src/main/java/jp/skypencil/errorprone/slf4j/PreferFinalSlf4jLogger.java +++ b/src/main/java/jp/skypencil/errorprone/slf4j/PreferFinalSlf4jLogger.java @@ -8,6 +8,7 @@ import com.google.auto.service.AutoService; import com.google.errorprone.BugPattern; import com.google.errorprone.VisitorState; +import com.google.errorprone.BugPattern.LinkType; import com.google.errorprone.bugpatterns.BugChecker; import com.google.errorprone.bugpatterns.BugChecker.VariableTreeMatcher; import com.google.errorprone.fixes.SuggestedFixes; @@ -20,6 +21,8 @@ name = "Slf4jLoggerShouldBeFinal", summary = "Logger field should be final", tags = {"SLF4J"}, + link = "https://github.com/KengoTODA/findbugs-slf4j#slf4j_logger_should_be_final", + linkType = LinkType.CUSTOM, severity = WARNING) @AutoService(BugChecker.class) public class PreferFinalSlf4jLogger extends BugChecker implements VariableTreeMatcher { diff --git a/src/main/java/jp/skypencil/errorprone/slf4j/SignOnlyFormat.java b/src/main/java/jp/skypencil/errorprone/slf4j/SignOnlyFormat.java index f3d9dbba..0f25b35f 100644 --- a/src/main/java/jp/skypencil/errorprone/slf4j/SignOnlyFormat.java +++ b/src/main/java/jp/skypencil/errorprone/slf4j/SignOnlyFormat.java @@ -5,6 +5,7 @@ import com.google.auto.service.AutoService; import com.google.errorprone.BugPattern; import com.google.errorprone.VisitorState; +import com.google.errorprone.BugPattern.LinkType; import com.google.errorprone.bugpatterns.BugChecker; import com.google.errorprone.bugpatterns.BugChecker.MethodInvocationTreeMatcher; import com.google.errorprone.matchers.CompileTimeConstantExpressionMatcher; @@ -18,6 +19,8 @@ name = "Slf4jSignOnlyFormat", summary = "To make log readable, log format should contain not only sign but also texts", tags = {"SLF4J"}, + link = "https://github.com/KengoTODA/findbugs-slf4j#slf4j_sign_only_format", + linkType = LinkType.CUSTOM, severity = ERROR) @AutoService(BugChecker.class) public class SignOnlyFormat extends BugChecker implements MethodInvocationTreeMatcher {