All Classes and Interfaces
Class
Description
Enables common behavior to JavaParser-based rules
Most
AJavaparserAstMutator will trigger over an ExpressionA single-node (i.e.
Most
AJavaparserNodeMutator will trigger over an StatementDeprecated.
Deprecated.
Turns 'i = i + 3;` into `i += 3;`
Turns '1F + 0.1F` into `(double) 1F + 0.1F`
Turns 'Arrays.asList("1", 2).stream()' into 'Arrays.stream("1", 2)'
Helps preparing rules
Migrate from 'm.size() == 0’ to ’m.isEmpty()'.
Deprecated.
Turns 'boolean b = (x > 1 ) ? true : callback.doIt() || true' into 'if (x > 1) { ...
Turns '!!someBoolean()' into 'someBoolean()'
Turns `throws RuntimeException` into ``
Helps mutating
BinaryExprTurns 'float f = 2/3;` into `float f = (float)2/3;`
This mutator will apply all
IMutator fixing a CheckStyle rules.Turns 's.indexOf(subString) >= 0' into 'c.contains(subString)' in String
Turns `list.isEmpty() ? Optional.empty() : Optional.of(list.get(0))` into `list.stream().findFirst()`
Turns 'd == Double.NaN' into 'Double.isNaN(d)'
This mutator make it easy to composite multiple
IJavaparserAstMutators in a single one.cases inspired from #description
Turns '{}' into ''
Prevent relying .equals on
Enum typesThis mutator will apply all
IMutator fixing ErrorProne rules.An exception thrown when a mutation fails.
See
TestForEachAddToStreamCollectToCollectionCasesTurns `for(User user : users) { if(!isImportantCustomer(user)) { break; } attachDiscount(user); }`
into `users.stream().takeWhile(user -> isImportantCustomer(user)).forEach(user -> applyDiscount(user));`
Turns `String key = ""; for (String value : values) { if (value.length() > 4) { key = value; break; } }`
into `String key = values.stream().filter(value -> value.length() > 4).findFirst().orElse("");`
See TestForEachIfToIfStreamAnyMatchCases
Turns `for (String string : stringList) {System.out.println(string);}`
into `stringList.forEach(s -> System.out.println(s));`
Turns 'ImmutableMap.of("k1", 0, "k2", 1)` into `ImmutableMap.builder().put("k1", 0).put("k2", 1).build()`
Turns 'Strings.repeat("abc", 3)` into `"abc".repeat(3)`
This mutator will apply all
IMutator improving Guava usage.Turns 's == null || s.isEmpty()` into `Strings.isNullOrEmpty(s)`
Deprecated.
An
IMutator which can edit a JavaParser NodeAn
IMutator which can edit a JavaParser NodeHelps working with
ImportDeclarationThis will turn qualified names into imports.
Helpers knowing what could be the impact of given rule
Formatter for Java
This class is dedicated to refactoring.
CleanThat as an
IEngineStep.This mutator will apply all
IMutator fixing ErrorProne rules.Migrate from JUnit4 to JUnit5/Jupiter.
Helps crafting
LambdaExprTurns `.stream(s -> s.size())` into `.stream(String::size)`
Turns '.stream(s -> {return s.subString(0, 2)})' into '.stream(s -> s.subString(0, 2))'
Switch o.equals("someString") to "someString".equals(o)
Turns 'int i = 10;' into 'var i = 10'.
Turns `for (int i = 0 ; i < 10 ; i ++) {System.out.println(string);}`
into `IntStream.range(0, 10).forEach(j -> System.out.println(j));`
Helps working with
MethodCallExprOrder modifiers according the the Java specification.
Helps working with
NameExprNodeAndSymbolSolver<T extends com.github.javaparser.ast.Node>
As we may process cloned
Node, and such Node has no CompilationUnit, we need to transport the
SymbolSolver manually.Turns `if (s != null) {...}` into `Optional.ofNullable(s).ifPresent(...)`
BEWARE This case of application should be restricted, as a simple null-check is often simpler than an
`Optional.ofNullable`, especially if the `thenStmt` does not depends on the nullable variable.
Turns 'Object.equals(1, 5)` into `1 == 5`
Turns 'Object.hashCode(1)` into `Integer.hashCode(1)`
Make easier processing on code-tree
Turns `optional.map(name -> name)` into `optional`
Turns '!o.isEmpty()' into 'o.isPresent()'
This may return an
Optional result, or a rejection flag.Turns `o.ifPresent(s -> { String subString = s.substring(1); System.out.println(subString); });`
into `o.map(s -> s.substring(1)).ifPresent(subString -> { System.out.println(subString); });`
Turns `o.ifPresent(s -> { String subString = s.substring(1); System.out.println(subString); });`
into `o.map(s -> s.substring(1)).ifPresent(subString -> { System.out.println(subString); });`
This mutator will apply all
IMutator fixing a PMD rules.Turns `new Double(d)` into `Double.valueOf(d)`
Turns `!strings.stream().anyMatch(p)` into `strings.stream().noneMatch(p)`
Turns 'c.removeAll(c)' into 'c.clear()' in Collection
Turns 'SomeClassWithConstructor(){super(); someMethod();}` into `SomeClassWithConstructor(){someMethod();}`.
Deprecated.
Helps working with
ResolvedTypeThis mutator will apply all
IMutator considered safe (e.g.This mutator will apply all
IMutator considered not-trivial.This mutator will apply all
IMutator considered safe (e.g.Turns `!(a == 2)` into `a != 2`
Turns `boolean b=false; if(X) b=true;` into `boolean b=X;`
BEWARE: One may argue this is a relevant change only if the boolean is not written after its initialization, hence if
the boolean can be turned into a `final` variable.
Deprecated.
This mutator will apply all
IMutator fixing a Sonar rule.This mutator will apply all
IMutator fixing SpotBugs rules.Turns 's.filter(p).findAny().isPresent()' into 's.anyMatch(predicate)'
Turns `s.flatMap(r -> r.stream().filter(c -> c.isEmpty()))`
into `s.flatMap(r -> r.stream()).filter(c -> c.isEmpty())`
Turns `stream.forEach(value -> { value.forEach(user -> { System.out.println(user); }); });`
into `stream.flatMap(value -> value.stream()).forEach(user -> { System.out.println(user); });`
Turns `stream.map(name -> name)`
into `stream`
Helps building mutators around
StreamTurns `strings.forEach(s -> { if (s.length() >= 1) { System.out.println(s); }
into `strings.filter(s -> s.length() >= 1).forEach(s -> { System.out.println(s); });`
Deprecated.
Turns `intStream.forEach(j -> { int c = s.charAt(j); sb.append(c); });`
into `intStream.map(j -> s.charAt(j)).forEach(c -> sb.append(c))`
Turns `new String("StringLiteral")` into `"StringLiteral"`
Turns 's.indexOf(subString) >= 0' into 'c.contains(subString)' in String
Turns `s.replaceAll("abc", "")` into `s.replace("abc", "")`
Turns `"someString".toString()` into `"someString"`
Turns 'myThread.run()` into `myThread.start()`
Turns `Integer i = Integer.valueOf(2)` into `Integer i = 2`
Turns `String i = Integer.valueOf(2).toString()` into `Integer i = Integer.toString(2)`
This will remove unnecessary fully qualified type reference, typically because given type if imported.
Remove unnecessary imports by analyzing
ImportDeclaration and used tokens in current `.java` file.Turns '.stream((s) -> s.subString(0, 2))' into '.stream(s -> s.subString(0, 2))'
Turns 'public static final someMethod();' into 'someMethod();' in interfaces
Turns `int i = 0;;` into `int i = 0;`
This mutator includes all
IMutator considered unsafe as the produced code may be invalid due to generics.Migrate from 'm.size() == 0’ to ’m.isEmpty()'.
Deprecated.
Deprecated.
Turns 'var i = 10;' into 'int i = 10;'.
Turns 's.indexOf("s")’ into ’s.indexOf('s')'.
Turns `Charset.forName("UTF-8")` into `StandardCharsets.UTF_8`
Migrate from 'm.length() == 0’ to ’m.isEmpty()'.
Turns '"a\r\n" + "b\r\n"’ into ’"""aEOLbEOL"""'
Turns 'int i = 1234567’ into ’int i = 1_234_567'
Helps working with
VariableDeclarationExpr