-
-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Remove unused local variable declarations #4028
refactor: Remove unused local variable declarations #4028
Conversation
It appears as if removing those local variables caused some imports to no longer be used:
|
Reproduce with `logifix --in-place --accept=S1128 src/main/`
Fixed in Logifix v0.3.0. Running diff --git a/src/main/java/spoon/pattern/internal/node/ElementNode.java b/src/main/java/spoon/pattern/internal/node/ElementNode.java
@@ -14,7 +14,6 @@ import spoon.metamodel.MetamodelProperty;
import spoon.pattern.Quantifier;
import spoon.pattern.internal.DefaultGenerator;
import spoon.pattern.internal.ResultHolder;
-import spoon.pattern.internal.matcher.Matchers;
import spoon.pattern.internal.matcher.TobeMatched;
import spoon.pattern.internal.parameter.ParameterInfo;
import spoon.reflect.declaration.CtElement;
@@ -122,7 +121,6 @@ public class ElementNode extends AbstractPrimitiveMatcher {
List<MapEntryNode> constantMatchers = new ArrayList<>(map.size());
//collect Entries with variable matcher keys
List<MapEntryNode> variableMatchers = new ArrayList<>();
- Matchers last = null;
for (Map.Entry<?, ?> entry : map.entrySet()) {
MapEntryNode mem = new MapEntryNode(
create(entry.getKey(), patternElementToSubstRequests),
diff --git a/src/main/java/spoon/reflect/visitor/CommentHelper.java b/src/main/java/spoon/reflect/visitor/CommentHelper.java
@@ -13,7 +13,6 @@ import spoon.reflect.code.CtJavaDocTag;
import spoon.support.Internal;
import java.util.Collection;
-import java.util.List;
import java.util.function.Function;
import java.util.regex.Pattern;
@@ -96,7 +95,6 @@ public class CommentHelper {
}
}
if (comment instanceof CtJavaDoc) {
- List<CtJavaDocTag> tags = null;
Collection<CtJavaDocTag> javaDocTags = ((CtJavaDoc) comment).getTags();
if (javaDocTags != null && javaDocTags.isEmpty() == false) {
printer.write(transfo.apply("")).writeln();
diff --git a/src/main/java/spoon/reflect/visitor/ImportScannerImpl.java b/src/main/java/spoon/reflect/visitor/ImportScannerImpl.java
@@ -772,7 +772,6 @@ public class ImportScannerImpl extends CtScanner implements ImportScanner {
if (parent != null) {
CtBlock block = (CtBlock) parent;
- boolean innerClass = false;
// now we have the first container block, we want to check if we're not in an inner class
while (parent != null && !(parent instanceof CtClass)) {
diff --git a/src/main/java/spoon/support/reflect/declaration/CtElementImpl.java b/src/main/java/spoon/support/reflect/declaration/CtElementImpl.java
@@ -19,7 +19,6 @@ import spoon.reflect.declaration.CtAnnotation;
import spoon.reflect.declaration.CtCompilationUnit;
import spoon.reflect.declaration.CtElement;
import spoon.reflect.declaration.CtNamedElement;
-import spoon.reflect.declaration.CtShadowable;
import spoon.reflect.declaration.CtType;
import spoon.reflect.declaration.ParentNotInitializedException;
import spoon.reflect.factory.Factory;
@@ -170,9 +169,6 @@ public abstract class CtElementImpl implements CtElement, Serializable {
@Override
public List<CtAnnotation<? extends Annotation>> getAnnotations() {
- if (this instanceof CtShadowable) {
- CtShadowable shadowable = (CtShadowable) this;
- }
return unmodifiableList(annotations);
} |
LGTM, 👍 for Logifix. |
Thanks @lyxell, that's good evaluation data for Logifix. |
This pull request fixes 4 violations of Sonar rule S1481 (Unused local variables should be removed).
This patch was generated automatically using Logifix.