-
Notifications
You must be signed in to change notification settings - Fork 2
Handled Bad Smells
array.toString()
is not the best way to print an array. Use Arrays.toString(array)
instead.
[https://rules.sonarsource.com/java/RSPEC-2116]
Checking if a collection is empty should be done by Collection.isEmpty()
.
Checking if a string is empty should be done by String#isEmpty
instead of String.equals("")
The expected annotation value should be removed from test methods, and replaced with JUnit 5 assertThrows
.
The JUnit 4 @Test
annotation should be replaced with JUnit 5 @Test
annotation.
AssertThat
in Junit 4 is deprecated. Use AssertThat
in Hamcrest instead.
The JUnit4 assertion should be replaced with JUnit5 Assertions.
The JUnit 4 @After
annotation should be replaced with JUnit 5 @AfterEach
annotation.
The JUnit 4 @AfterClass
annotation should be replaced with JUnit 5 @AfterAll
annotation.
The JUnit 4 @Before
annotation should be replaced with JUnit 5 @BeforeEach
annotation.
The JUnit 4 @BeforeClass
annotation should be replaced with JUnit 5 @BeforeAll
annotation.
The JUnit 4 @Ignore
annotation should be replaced with JUnit 5 @Disabled
annotation.
Lambda is used instead of executable reference [https://rules.sonarsource.com/java/RSPEC-1612]
Static methods should be access via the class name, not the instance variable.
A protected member is used in a final class. Final classes are not allowed to be extended.
Primitive types have default values and setting them to the same value is redundant.
Inner classes should be static if possible
Primitive types are converted to String using concationation with ""``String.valueOf(primitive)
is the preferred way to convert a primitive to a String.
StringBuilder
offers a lot of methods directly and toString
is not everytime needed
@TempDir
can be used as a method parameter removing fields from test classes
ThreadLocal
with initialValue override shall be replaced by ThreadLocal.withInitialValue
[https://rules.sonarsource.com/java/RSPEC-4065]