csrma
csrma
In the following code, SpotBugs correctly detects the infinite recursion, which means that SpotBugs can detect even conditional infinite recursions. ```java class InfiniteRecursionBug { public static void infiniteLoopMethod() { boolean...
In the following code, the `myField` field is always set to null and read from the `showBug()` method. This correctly results in the `UWF_NULL_FIELD` error. ``` class NullFieldExample { private...
In the following code, the `static final` variable references an array which can be accessed and modified. However, this is not detected by SpotBugs for `MS_MUTABLE_ARRAY`. ``` class MutableArrayBug {...
In the following code, the `mutableStaticField` variable is mutable and `public static`. I expected this to be flagged by SpotBugs for `MS_PKGPROTECT` but it does not. ``` class MutableStaticFieldExample {...
The following code increments the field `counter` in an assertion statement. This should be detected by SpotBugs as "side effects in assertion" but it is missed. ``` class AssertionWithSideEffect {...
In the following code, `if (offset < 0)` check makes sure that the `offset` value is negative, and then still accesses the `numbers` array, which will certainly result in ArrayIndexOutOfBoundsException....
A random value between 0 and 1 is generated using `randomValue = random.nextDouble()` and then coerced to integer using `(int) randomValue`. However, SpotBugs does not raise the `RV_01_TO_INT` flag for...
The following code runs indefinitely as there is no stop condition in the loop. However, SpotBugs is not able to detect this. I can confirm that it also does not...
In the following code, a hardcoded password is returned from a method unconditionally. So this is **always** same as putting a hardcoded string in `DriverManager.getConnection`. However, in this case the...
SpotBugs detects the `SING_SINGLETON_GETTER_NOT_SYNCHRONIZED` in the following code. ``` class Singleton { private static Singleton instance; private Singleton() {} public static Singleton getInstance() { if (instance == null) { int...