Skip to content

Apache Lucene open-source search software

1.9 KB
Raw Blame
---
id: WildcardImport
valid:
  - import foo.bar.Baz;
  - import static foo.bar.Baz;
invalid:
  - import foo.bar.*;
  - import static foo.bar.*;
---
id: ComparingThisWithNull
valid:
  - if (this == that) {}
  - if (that == null) {}
  - if (null == null) {}
  - if (this == this) {}
invalid:
  - if (this == null) {}
  - if (null == this) {}
  - |
    x = this == null ? 1 : 0;
  - |
    x = null == this ? 1 : 0;
---
id: SubstringOfZero
valid:
  - x.substring(1)
  - x.substring(0, 1)
  - x.foobar(0)
invalid:
  - x.substring(0)
  - x.y().substring(0)
---
id: JUnit4ClassAnnotationNonStatic
valid:
  - |
    @Before
    void t() {}
  - |
    @BeforeClass
    static void t() {}
invalid:
  - |
    @BeforeClass
    void t() {}
  - |
    @BeforeClass
    @SomethingElse
    void t() {}
---
id: JUnit4EmptyMethods
valid:
  - |
    void t() {}
  - |
    @Before
    void t() {
      int x;
    }
  - |
    @Before
    void t() {
      // comment
    }
  - |
    @Before
    @Override
    void t() {}
invalid:
  - |
    @Before
    void t() {}
  - |
    @BeforeClass
    @Foo()
    public static void t() {
    }
---
id: PackageInfo
valid:
  - |
    package foo.bar.baz;
  - |
    /** javadoc */
    package foo.bar.baz;
  - |
    import x.y.Z; // javadocs
    /** javadoc {@link Z} */
    package foo.bar.baz;
invalid:
  - |
    class Foo {}
  - |
    interface Bar {}
---
id: IncorrectMainMethod
valid:
  - |
    public static void main() {}
  - |
    public void foo() {}
invalid:
  - |
    public void main() {}
  - |
    public static int main() {}
---
id: ThreeLetterTimeZoneID
invalid:
  - TimeZone.getTimeZone("EST")
valid:
  - TimeZone.getTimeZone("UTC")
  - TimeZone.getTimeZone("America/New_York")
---
id: StringCharset
invalid:
  - |
    new String(bytes, "UTF-8")
  - |
    "abc".getBytes("UTF-16LE")
valid:
  - |
    new String(bytes, "GB2312")
  - |
    new String(bytes, StandardCharsets.UTF_8)