Skip to content

Commit 22f3b0f

Browse files
authored
Merge pull request #73 from jhertout/quality/fix_some_sonarsource_smells
Quality : fix some SonarSource smells
2 parents 81faacf + f515b02 commit 22f3b0f

16 files changed

+22
-45
lines changed

android-plugin/src/main/java/io/ecocode/java/checks/environment/batch/JobCoalesceRule.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
package io.ecocode.java.checks.environment.batch;
1919

20-
import com.google.common.collect.ImmutableList;
2120
import org.sonar.check.Rule;
2221
import org.sonar.plugins.java.api.IssuableSubscriptionVisitor;
2322
import org.sonar.plugins.java.api.semantic.MethodMatchers;
@@ -58,7 +57,7 @@ public JobCoalesceRule() {
5857

5958
@Override
6059
public List<Tree.Kind> nodesToVisit() {
61-
return ImmutableList.of(Tree.Kind.METHOD_INVOCATION);
60+
return List.of(Tree.Kind.METHOD_INVOCATION);
6261
}
6362

6463
@Override

android-plugin/src/main/java/io/ecocode/java/checks/environment/batch/SensorCoalesceRule.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
package io.ecocode.java.checks.environment.batch;
1919

20-
import com.google.common.collect.ImmutableList;
2120
import io.ecocode.java.checks.helpers.CheckArgumentComplexTypeUtils;
2221
import org.sonar.check.Rule;
2322
import org.sonar.plugins.java.api.IssuableSubscriptionVisitor;
@@ -47,7 +46,7 @@ public SensorCoalesceRule() {
4746

4847
@Override
4948
public List<Tree.Kind> nodesToVisit() {
50-
return ImmutableList.of(Tree.Kind.METHOD_INVOCATION);
49+
return List.of(Tree.Kind.METHOD_INVOCATION);
5150
}
5251

5352
@Override

android-plugin/src/main/java/io/ecocode/java/checks/environment/bottleneck/InternetInTheLoopRule.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
package io.ecocode.java.checks.environment.bottleneck;
1919

20-
import com.google.common.collect.ImmutableList;
2120
import org.sonar.check.Rule;
2221
import org.sonar.plugins.java.api.IssuableSubscriptionVisitor;
2322
import org.sonar.plugins.java.api.semantic.MethodMatchers;
@@ -42,7 +41,7 @@ public class InternetInTheLoopRule extends IssuableSubscriptionVisitor {
4241

4342
@Override
4443
public List<Tree.Kind> nodesToVisit() {
45-
return ImmutableList.of(Tree.Kind.METHOD_INVOCATION);
44+
return List.of(Tree.Kind.METHOD_INVOCATION);
4645
}
4746

4847
@Override

android-plugin/src/main/java/io/ecocode/java/checks/environment/bottleneck/UncompressedDataTransmissionRule.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
import org.sonar.plugins.java.api.tree.Tree;
3333
import org.sonar.plugins.java.api.tree.VariableTree;
3434

35-
import com.google.common.collect.ImmutableList;
36-
3735
import io.ecocode.java.checks.helpers.CheckArgumentComplexTypeUtils;
3836
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
3937

@@ -54,7 +52,7 @@ public class UncompressedDataTransmissionRule extends IssuableSubscriptionVisito
5452

5553
@Override
5654
public List<Tree.Kind> nodesToVisit() {
57-
return ImmutableList.of(Tree.Kind.VARIABLE);
55+
return List.of(Tree.Kind.VARIABLE);
5856
}
5957

6058
@Override

android-plugin/src/main/java/io/ecocode/java/checks/environment/idleness/DurableWakeLockRule.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
package io.ecocode.java.checks.environment.idleness;
1919

20-
import com.google.common.collect.ImmutableList;
2120
import org.sonar.check.Rule;
2221
import org.sonar.plugins.java.api.IssuableSubscriptionVisitor;
2322
import org.sonar.plugins.java.api.semantic.MethodMatchers;
@@ -41,7 +40,7 @@ public class DurableWakeLockRule extends IssuableSubscriptionVisitor {
4140

4241
@Override
4342
public List<Tree.Kind> nodesToVisit() {
44-
return ImmutableList.of(Tree.Kind.METHOD_INVOCATION);
43+
return List.of(Tree.Kind.METHOD_INVOCATION);
4544
}
4645

4746
@Override

android-plugin/src/main/java/io/ecocode/java/checks/environment/idleness/KeepVoiceAwakeRule.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
package io.ecocode.java.checks.environment.idleness;
1919

20-
import com.google.common.collect.ImmutableList;
2120
import io.ecocode.java.checks.helpers.CheckArgumentComplexTypeUtils;
2221
import org.sonar.api.utils.log.Logger;
2322
import org.sonar.api.utils.log.Loggers;
@@ -57,7 +56,7 @@ public class KeepVoiceAwakeRule extends IssuableSubscriptionVisitor {
5756

5857
@Override
5958
public List<Tree.Kind> nodesToVisit() {
60-
return ImmutableList.of(Tree.Kind.NEW_CLASS, Tree.Kind.METHOD_INVOCATION);
59+
return List.of(Tree.Kind.NEW_CLASS, Tree.Kind.METHOD_INVOCATION);
6160
}
6261

6362
@Override

android-plugin/src/main/java/io/ecocode/java/checks/environment/optimized_api/FusedLocationRule.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
package io.ecocode.java.checks.environment.optimized_api;
1919

20-
import com.google.common.collect.ImmutableList;
2120
import io.ecocode.java.checks.helpers.TreeHelper;
2221
import org.sonar.check.Rule;
2322
import org.sonar.plugins.java.api.IssuableSubscriptionVisitor;
@@ -47,7 +46,7 @@ public class FusedLocationRule extends IssuableSubscriptionVisitor {
4746

4847
@Override
4948
public List<Tree.Kind> nodesToVisit() {
50-
return ImmutableList.of(Tree.Kind.IMPORT);
49+
return List.of(Tree.Kind.IMPORT);
5150
}
5251

5352
@Override

android-plugin/src/main/java/io/ecocode/java/checks/environment/power/ChargeAwarenessRule.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.sonar.plugins.java.api.tree.NewClassTree;
3232
import org.sonar.plugins.java.api.tree.Tree;
3333

34-
import com.google.common.collect.ImmutableList;
3534
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
3635

3736
/**
@@ -58,7 +57,7 @@ public class ChargeAwarenessRule extends IssuableSubscriptionVisitor {
5857

5958
@Override
6059
public List<Tree.Kind> nodesToVisit() {
61-
return ImmutableList.of(Tree.Kind.NEW_CLASS, Tree.Kind.METHOD_INVOCATION);
60+
return List.of(Tree.Kind.NEW_CLASS, Tree.Kind.METHOD_INVOCATION);
6261
}
6362

6463
@Override

android-plugin/src/main/java/io/ecocode/java/checks/environment/power/SaveModeAwarenessRule.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
package io.ecocode.java.checks.environment.power;
1919

20-
import com.google.common.collect.ImmutableList;
2120
import org.sonar.api.utils.log.Logger;
2221
import org.sonar.api.utils.log.Loggers;
2322
import org.sonar.check.Rule;
@@ -48,7 +47,7 @@ public class SaveModeAwarenessRule extends IssuableSubscriptionVisitor {
4847

4948
@Override
5049
public List<Tree.Kind> nodesToVisit() {
51-
return ImmutableList.of(Tree.Kind.NEW_CLASS, Tree.Kind.METHOD_INVOCATION);
50+
return List.of(Tree.Kind.NEW_CLASS, Tree.Kind.METHOD_INVOCATION);
5251
}
5352

5453
@Override
@@ -72,10 +71,8 @@ public void visitNode(Tree tree) {
7271
if ((addActionMatcher.matches(mit) || createIntentFilterMatcher.matches(mit))
7372
&& !mit.arguments().isEmpty()) {
7473
mit.arguments().get(0).asConstant().ifPresentOrElse(o -> {
75-
if (o instanceof String) {
76-
if (o.equals(ACTION_BATTERY_CHANGED)) {
77-
reportIssue(mit.arguments().get(0), ADVICE_MESSAGE);
78-
}
74+
if (o instanceof String && o.equals(ACTION_BATTERY_CHANGED)) {
75+
reportIssue(mit.arguments().get(0), ADVICE_MESSAGE);
7976
}
8077
}, () -> {
8178
if (isPowerSaveModeMatcher.matches(mit)) {

android-plugin/src/main/java/io/ecocode/java/checks/environment/sobriety/BrightnessOverrideRule.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
package io.ecocode.java.checks.environment.sobriety;
1919

20-
import com.google.common.collect.ImmutableList;
2120
import org.sonar.check.Rule;
2221
import org.sonar.plugins.java.api.IssuableSubscriptionVisitor;
2322
import org.sonar.plugins.java.api.tree.*;
@@ -41,7 +40,7 @@ public class BrightnessOverrideRule extends IssuableSubscriptionVisitor {
4140

4241
@Override
4342
public List<Tree.Kind> nodesToVisit() {
44-
return ImmutableList.of(Tree.Kind.ASSIGNMENT);
43+
return List.of(Tree.Kind.ASSIGNMENT);
4544
}
4645

4746
@Override

0 commit comments

Comments
 (0)