Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public J.VariableDeclarations visitVariableDeclarations(J.VariableDeclarations m
return mv;
}

// ignores anonymous class fields, contributed code for issue #181
// ignores anonymous class fields, contributed code for issue #181
if (this.getCursorToParentScope(this.getCursor()).getValue() instanceof J.NewClass) {
return mv;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ void addSerialAnnotation() {
java(
"""
import java.io.Serializable;

class Example implements Serializable {
private static final long serialVersionUID = 1L;
}
""",
"""
import java.io.Serial;
import java.io.Serializable;

class Example implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
Expand All @@ -66,14 +66,14 @@ void shouldAddToNewFieldWhenChained() {
java(
"""
import java.io.Serializable;

class Example implements Serializable {
}
""",
"""
import java.io.Serial;
import java.io.Serializable;

class Example implements Serializable {
@Serial
private static final long serialVersionUID = 1;
Expand All @@ -91,7 +91,7 @@ void shouldNoopIfAlreadyPresent() {
"""
import java.io.Serializable;
import java.io.Serial;

class Example implements Serializable {
String var1 = "first variable";
@Serial
Expand Down Expand Up @@ -124,7 +124,7 @@ void shouldNotAnnotateOnJava11() {
java(
"""
import java.io.Serializable;

class Example implements Serializable {
private static final long serialVersionUID = 1L;
}
Expand All @@ -141,14 +141,14 @@ void shouldNotAnnotateOtherFields() {
java(
"""
import java.io.Serializable;

class Example implements Serializable {
static final long serialVersionUID = 1L;
private final long serialVersionUID = 1L;
private static long serialVersionUID = 1L;
private static final int serialVersionUID = 1L;
private static final long foo = 1L;

void doSomething() {
long serialVersionUID = 1L;
}
Expand All @@ -165,7 +165,7 @@ void shouldAnnotatedFieldsInInnerClasses() {
java(
"""
import java.io.Serializable;

class Outer implements Serializable {
private static final long serialVersionUID = 1;
static class Inner implements Serializable {
Expand All @@ -176,7 +176,7 @@ static class Inner implements Serializable {
"""
import java.io.Serial;
import java.io.Serializable;

class Outer implements Serializable {
@Serial
private static final long serialVersionUID = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void usesGet() {
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicBoolean;

class A {
boolean areEqual(AtomicInteger a1, AtomicInteger a2) {
return a1.get() == a2.get();
Expand All @@ -64,7 +64,7 @@ void equalsArgNotAtomicType() {
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicBoolean;

class A {
boolean areEqual(Integer a1, Integer a2) {
return a1.equals(a2);
Expand All @@ -85,7 +85,7 @@ void usesEquals() {
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicBoolean;

class A {
boolean areEqual(AtomicInteger i1, AtomicInteger i2) {
return i1.equals(i2);
Expand All @@ -102,7 +102,7 @@ boolean areEqual(AtomicBoolean b1, AtomicBoolean b2) {
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicBoolean;

class A {
boolean areEqual(AtomicInteger i1, AtomicInteger i2) {
return i1.get() == i2.get();
Expand All @@ -127,7 +127,7 @@ void typeExtendsAtomic() {
"""
package abc;
import java.util.concurrent.atomic.AtomicLong;

public class AtomicLongWithEquals extends AtomicLong {
public AtomicLongWithEquals(long i) {
super(i);
Expand All @@ -139,7 +139,7 @@ public AtomicLongWithEquals(long i) {
java(
"""
package abc;

class A {
boolean doSomething(AtomicLongWithEquals i1, AtomicLongWithEquals i2) {
return i1.equals(i2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void bigDecimalRoundingChangeRoundingMode() {
java(
"""
import java.math.BigDecimal;

class A {
void divide() {
BigDecimal bd = BigDecimal.valueOf(10);
Expand All @@ -74,7 +74,7 @@ void divide() {
"""
import java.math.BigDecimal;
import java.math.RoundingMode;

class A {
void divide() {
BigDecimal bd = BigDecimal.valueOf(10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ void bufferedReaderCreation() {
import java.io.FileWriter;
import java.io.File;
import java.io.IOException;

public class BufferedWriterCreationTest {
public void createBufferedWriter(File f) throws IOException {
try (BufferedWriter writer = new BufferedWriter(new FileWriter(f))) {

}
}
}
Expand All @@ -55,11 +55,11 @@ public void createBufferedWriter(File f) throws IOException {
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

public class BufferedWriterCreationTest {
public void createBufferedWriter(File f) throws IOException {
try (BufferedWriter writer = Files.newBufferedWriter(f.toPath())) {

}
}
}
Expand All @@ -78,11 +78,11 @@ void bufferedReaderCreationAppend() {
import java.io.FileWriter;
import java.io.File;
import java.io.IOException;

public class BufferedWriterCreationTest {
public void createBufferedWriter(File f) throws IOException {
try (BufferedWriter writer = new BufferedWriter(new FileWriter(f, true))) {

}
}
}
Expand All @@ -93,11 +93,11 @@ public void createBufferedWriter(File f) throws IOException {
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;

public class BufferedWriterCreationTest {
public void createBufferedWriter(File f) throws IOException {
try (BufferedWriter writer = Files.newBufferedWriter(f.toPath(), StandardOpenOption.APPEND)) {

}
}
}
Expand All @@ -116,11 +116,11 @@ void bufferedReaderStringCreation() {
import java.io.FileWriter;
import java.io.File;
import java.io.IOException;

public class BufferedWriterCreationTest {
public void createBufferedWriter(String f) throws IOException {
try (BufferedWriter writer = new BufferedWriter(new FileWriter(f))) {

}
}
}
Expand All @@ -130,11 +130,11 @@ public void createBufferedWriter(String f) throws IOException {
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

public class BufferedWriterCreationTest {
public void createBufferedWriter(String f) throws IOException {
try (BufferedWriter writer = Files.newBufferedWriter(new File(f).toPath())) {

}
}
}
Expand All @@ -153,11 +153,11 @@ void bufferedReaderStringCreationAppend() {
import java.io.FileWriter;
import java.io.File;
import java.io.IOException;

public class BufferedWriterCreationTest {
public void createBufferedWriter(String f) throws IOException {
try (BufferedWriter writer = new BufferedWriter(new FileWriter(f, false))) {

}
}
}
Expand All @@ -168,11 +168,11 @@ public void createBufferedWriter(String f) throws IOException {
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;

public class BufferedWriterCreationTest {
public void createBufferedWriter(String f) throws IOException {
try (BufferedWriter writer = Files.newBufferedWriter(new File(f).toPath(), StandardOpenOption.CREATE)) {

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ public boolean equals(Test t) {
public boolean equals(Object i) {
return false;
}

public boolean equals(Object i, Test t) {
return false;
}
Expand All @@ -287,7 +287,7 @@ void ignoreIfNoExistingEqualsMethod() {
java(
"""
class A {}

class B {
B() {}
public void placeholder(B t) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void test() {
""",
"""
import java.nio.charset.StandardCharsets;

public class Test {
void test() {
String s = "hi";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class Test {

int[] l = null;
int[] m = new int[0];

private final Long n = null;
}
""",
Expand All @@ -179,16 +179,16 @@ class Test {
private long e = 2L;
private int f;
private char g;

private boolean h;
private boolean i = true;

private Object j = new Object();
private Object k;

int[] l;
int[] m = new int[0];

private final Long n = null;
}
"""
Expand Down
Loading