UnqualifiedSuggestedFixImport

WARNING

FragileCode

View source code on GitHub

Summary

Avoid direct invocation of SuggestedFix#add{,Static}Import

Suppression

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

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

Samples

Replacement

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

Identification

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

import com.google.errorprone.fixes.SuggestedFix;

class A {
  void m() {
    System.out.println("foo");
    addImport("bar");
    addStaticImport("baz");

    SuggestedFix.Builder builder = SuggestedFix.builder();
    // BUG: Diagnostic matches: IMPORT
    builder.addImport("java.lang.String");
    // BUG: Diagnostic matches: STATIC_IMPORT
    builder.addStaticImport("java.lang.String.toString");
    builder.build();
  }

  private void addImport(String s) {}

  private void addStaticImport(String s) {}
}

Copyright © 2017-2024 Picnic Technologies BV