Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sonarlint.connectedMode.project": {
"connectionId": "http-localhost-9000",
"projectKey": "robbiebise_test-java_AYUMz9uSsTqRf_H8TmDL"
}
}
Binary file modified main/Main.class
Binary file not shown.
23 changes: 21 additions & 2 deletions main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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
}
}
}
}

Binary file modified main/OldStuff.class
Binary file not shown.
26 changes: 24 additions & 2 deletions main/OldStuff.java
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
}
}

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.
// ...
}
}
}