jxlint-impl 0.1.0 - Lint Report

Tue Jun 27 15:21:27 EDT 2017

jxlint-impl

Verified rules

  • Functions starting with 'test' are tests
  • SLF4J loggers should not use String.format

Violations

Violation Name Category Number of Violations
Functions starting with 'test' are tests Probably An Accident 2
SLF4J loggers should not use String.format Probably An Accident 1
There are 1 warning, 2 errors, and 0 fatal errors (3 total).

Probably An Accident

public void testThisShouldFail does not have @Test annotation
public void testThisShouldFailToo does not have @Test annotation
logger.debug(String.format("This is %s", bad))

Rule Descriptions

Functions starting with 'test' are tests Probably An Accident
Rule Name Functions starting with 'test' are tests
Summary Functions in tests starting with 'test' are annotated with @Test
Severity ERROR
Category Probably An Accident
Enabled by default? Yes

This rule is only applicable to JUnit 4+ applications.

In a class ending with Test.java, functions that start with the pattern 'public void test' should probably be annotated with @Test.

For example:

@Test
public void testThatOneIsEqualToTwo() {
    assertThat(1).isEqualTo(2);
}

public void testThatThisRuleIsAmazing() {
    someString = computeSomeString();

    assertThat(someString).isEqualTo("someOtherString");
}

In this case, testThatThisRuleIsAmazing won't get executed because it is not annotated with @Test.

SLF4J loggers should not use String.format Probably An Accident
Rule Name SLF4J loggers should not use String.format
Summary SLF4J loggers should use parametrized logging, not String.format
Severity WARNING
Category Probably An Accident
Enabled by default? Yes

Java files that make use of SLF4J should generally favor parametrized logging over String.format logging

For example:

logger.info(String.format("Found %s", someVariable));

Could more easily be written as

logger.info("Found {}", someVariable);

Note: the implementation does not fully parse symbols, so it approximates by looking for SLF4J imports and usages of LoggerFactory.getLogger.