Skip to content

Commit

Permalink
fix(EC528): removed unused logger
Browse files Browse the repository at this point in the history
  • Loading branch information
rgoussu-exalt committed May 30, 2024
1 parent ffcd2a1 commit 45405f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,17 @@
*/
package io.ecocode.ios.swift.checks.sobriety;

import io.ecocode.ios.swift.EcoCodeSwiftVisitor;
import io.ecocode.ios.swift.SwiftRuleCheck;
import io.ecocode.ios.swift.antlr.generated.Swift5Parser;
import io.ecocode.ios.swift.checks.CheckHelper;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.TerminalNodeImpl;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.check.Rule;

import java.util.Objects;

@Rule(key = "EC528")
public class FeedbackGeneratorUsageCheck extends SwiftRuleCheck {
private static final Logger LOGGER = Loggers.get(EcoCodeSwiftVisitor.class);
private static final String DEFAULT_ISSUE_MESSAGE = "Avoid using the device vibrator to use less energy.";
public static final String UI_KIT = "UIKit";
protected boolean isUIKitImported;
Expand All @@ -46,12 +42,14 @@ public void apply(ParseTree tree) {

isUIKitImported = isUIKitImported || CheckHelper.isImportExisting(tree, UI_KIT);

isFeedbackGeneratorInstantiated = isFeedbackGeneratorInstantiated || (isUIKitImported &&
tree instanceof Swift5Parser.ExpressionContext &&
(tree.getText().contains("UIImpactFeedbackGenerator")));
isFeedbackGeneratorInstantiated = isFeedbackGeneratorInstantiated ||
(isUIKitImported &&
tree instanceof Swift5Parser.ExpressionContext &&
(tree.getText().contains("UIImpactFeedbackGenerator")));

isImpactMethodCalled = isImpactMethodCalled || (isFeedbackGeneratorInstantiated &&
(tree.getText().contains(".impactOccurred(")));
isImpactMethodCalled = isImpactMethodCalled ||
(isFeedbackGeneratorInstantiated &&
(tree.getText().contains(".impactOccurred(")));

if (Objects.isNull(id) &&
tree instanceof Swift5Parser.ExpressionContext &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void testMetadata() {

@Test
public void testRegisteredRules() {
assertThat(repository.rules()).hasSize(14);
assertThat(repository.rules()).hasSize(15);
}

@Test
Expand Down

0 comments on commit 45405f6

Please sign in to comment.