diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..256e65e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "sonarlint.connectedMode.project": { + "connectionId": "http-localhost-9000", + "projectKey": "robbiebise_test-java_AYUMz9uSsTqRf_H8TmDL" + } +} \ No newline at end of file diff --git a/main/Main.class b/main/Main.class index c7d0b2d..7458e3a 100644 Binary files a/main/Main.class and b/main/Main.class differ diff --git a/main/Main.java b/main/Main.java index 3110f38..802f223 100644 --- a/main/Main.java +++ b/main/Main.java @@ -9,9 +9,28 @@ public static void main(String[] arguments) { a = "asdf"; if (a != null) {out.println(a);} //TODO: something elsee + //TODO: another task + for (;true;) { + out.println("bad"); + OldStuff oldStuff = new OldStuff(); + oldStuff.oldMethod(); + } - OldStuff oldStuff = new OldStuff(); - oldStuff.oldMethod(); + for (;true;) { + out.println("bad"); + OldStuff oldStuff = new OldStuff(); + oldStuff.oldMethod(); + } } + + void removeFrom(List list) { + // expected: iterate over all the elements of the list + for (int i = 0; i < list.size(); i++) { + if (list.get(i).isEmpty()) { + // actual: remaining elements are shifted, so the one immediately following will be skipped + list.remove(i); // Noncompliant + } + } + } } diff --git a/main/OldStuff.class b/main/OldStuff.class index c2e70b2..baeaa10 100644 Binary files a/main/OldStuff.class and b/main/OldStuff.class differ diff --git a/main/OldStuff.java b/main/OldStuff.java index 0d8e10d..68436aa 100644 --- a/main/OldStuff.java +++ b/main/OldStuff.java @@ -2,9 +2,31 @@ import static java.lang.System.out; -// @Deprecated +abstract class MyClass{ + +} + +class AbstractLikeClass { + +} + public class OldStuff { public void oldMethod(){ out.println("old!"); } -} \ No newline at end of file + + private String color = "red"; + + private void doSomething(){ + synchronized(color) { // Noncompliant; lock is actually on object instance "red" referred to by the color variable + //... + color = "green"; // other threads now allowed into this block + // ... + } + synchronized(new Object()) { // Noncompliant this is a no-op. + // ... + } + } +} + +