BugPatternLink

SUGGESTION

LikelyError

View source code on GitHub

Summary

Error Prone Support checks must reference their online documentation

Suppression

Suppress false positives by adding the suppression annotation @SuppressWarnings("BugPatternLink") to the enclosing element.

Disable this pattern completely by adding -Xep:BugPatternLink:OFF as compiler argument. Learn more.

Samples

Replacement

Shows the difference in example code before and after the bug pattern is applied.

 package tech.picnic.errorprone;
 
+import static com.google.errorprone.BugPattern.LinkType.CUSTOM;
+import static tech.picnic.errorprone.utils.Documentation.BUG_PATTERNS_BASE_URL;
+
 import com.google.errorprone.BugPattern;
 
 @BugPattern(
+    link = BUG_PATTERNS_BASE_URL + "A",
+    linkType = CUSTOM,
     summary = "Error Prone Support class lacking link",
     severity = BugPattern.SeverityLevel.ERROR)
 class A {}
 
 package tech.picnic.errorprone;
 
 import static com.google.errorprone.BugPattern.LinkType.CUSTOM;
 import static com.google.errorprone.BugPattern.SeverityLevel.ERROR;
+import static tech.picnic.errorprone.utils.Documentation.BUG_PATTERNS_BASE_URL;
 
 import com.google.errorprone.BugPattern;
 
 @BugPattern(
     summary = "Error Prone Support class with incorrect link",
-    link = "Not the right link",
+    link = BUG_PATTERNS_BASE_URL + "B",
     linkType = CUSTOM,
     severity = ERROR)
 class B {}
 

Identification

Shows code lines which will (not) be flagged by this bug pattern.
A //BUG: Diagnostic contains: comment is placed above any violating line.

package tech.picnic.errorprone;

import com.google.errorprone.BugPattern;

// BUG: Diagnostic contains:
@BugPattern(
    summary = "Error Prone Support class lacking link",
    severity = BugPattern.SeverityLevel.ERROR)
class G {}
package tech.picnic.errorprone;

import com.google.errorprone.BugPattern;
import tech.picnic.errorprone.utils.Documentation;

// BUG: Diagnostic contains:
@BugPattern(
    summary = "Error Prone Support class with incorrect link",
    link = Documentation.BUG_PATTERNS_BASE_URL + "NotH",
    linkType = BugPattern.LinkType.CUSTOM,
    severity = BugPattern.SeverityLevel.ERROR)
class H {}
package tech.picnic.errorprone;

import com.google.errorprone.BugPattern;

// BUG: Diagnostic contains:
@BugPattern(
    summary = "Error Prone Support class with non-canonical link",
    link = "https://error-prone.picnic.tech/bugpatterns/I",
    linkType = BugPattern.LinkType.CUSTOM,
    severity = BugPattern.SeverityLevel.ERROR)
class I {}
package tech.picnic.errorprone;

import com.google.errorprone.BugPattern;

// BUG: Diagnostic contains:
@BugPattern(
    summary = "Error Prone Support class in with non-canonical link",
    link = "https://error-prone.picnic.tech/bugpatterns/" + "J",
    linkType = BugPattern.LinkType.CUSTOM,
    severity = BugPattern.SeverityLevel.ERROR)
class J {}

Copyright © 2017-2024 Picnic Technologies BV