Skip to content

Commit

Permalink
fix(renaming): added deprecated annotation on renamed rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Gilles Grousset committed Dec 24, 2024
1 parent 0bd7245 commit e76f984
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
import org.greencodeinitiative.creedengo.ios.pbxproj.antlr.generated.PbxprojParser;

import org.sonar.check.Rule;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

@Rule(key = "GCI547")
@DeprecatedRuleKey(repositoryKey = "ecocode-ios", ruleKey = "EC547")
public class DisabledDarkModeCheck extends PbxprojRuleCheck {

private static final String DEFAULT_ISSUE_MESSAGE = "The app should handle dark mode.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.TerminalNodeImpl;
import org.sonar.check.Rule;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

import static org.greencodeinitiative.creedengo.ios.swift.checks.CheckHelper.isEndOfFile;
import static org.greencodeinitiative.creedengo.ios.swift.checks.CheckHelper.isExpressionPresent;

@Rule(key = "GCI512")
@DeprecatedRuleKey(repositoryKey = "ecocode-ios", ruleKey = "EC512")
public class CameraLeakCheck extends SwiftRuleCheck {
private static final String DEFAULT_ISSUE_MESSAGE = "Any started capture session should be stopped.";
private boolean captureSessionStarted = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.TerminalNodeImpl;
import org.sonar.check.Rule;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

import static org.greencodeinitiative.creedengo.ios.swift.checks.CheckHelper.*;

@Rule(key = "GCI524")
@DeprecatedRuleKey(repositoryKey = "ecocode-ios", ruleKey = "EC524")
public class ThriftyGeolocation extends SwiftRuleCheck {
private static final String DEFAULT_ISSUE_MESSAGE = "Adapt location accuracy and type to applications needs.";
private Swift5Parser.Import_declarationContext importTree = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
import org.greencodeinitiative.creedengo.ios.swift.antlr.generated.Swift5Parser;
import org.antlr.v4.runtime.tree.ParseTree;
import org.sonar.check.Rule;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

import static org.greencodeinitiative.creedengo.ios.swift.checks.CheckHelper.isExpressionPresent;

/**
* Check the use of "UIApplication.shared.isIdleTimerDisabled" and triggers when set to true.
*/
@Rule(key = "GCI505")
@DeprecatedRuleKey(repositoryKey = "ecocode-ios", ruleKey = "EC505")
public class IdleTimerDisabledCheck extends SwiftRuleCheck {
private static final String DEFAULT_ISSUE_MESSAGE = "Do not disable idle timer, unless absolutely necessary.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
import org.greencodeinitiative.creedengo.ios.swift.antlr.generated.Swift5Parser;
import org.antlr.v4.runtime.tree.ParseTree;
import org.sonar.check.Rule;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

/**
* Check the presence of the class "Timer".
*/
@Rule(key = "GCI509")
@DeprecatedRuleKey(repositoryKey = "ecocode-ios", ruleKey = "EC509")
public class RigidAlarmCheck extends SwiftRuleCheck {
private static final String DEFAULT_ISSUE_MESSAGE = "Setting a tolerance for timers will allow them to fire later than the scheduled fire date.";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.TerminalNodeImpl;
import org.sonar.check.Rule;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

import java.util.Arrays;
import java.util.List;

import static org.greencodeinitiative.creedengo.ios.swift.checks.CheckHelper.*;

@Rule(key="GCI534")
@DeprecatedRuleKey(repositoryKey = "ecocode-ios", ruleKey = "EC534")
public class MotionSensorUpdateRateCheck extends SwiftRuleCheck {
private static final String DEFAULT_ISSUE_MESSAGE = "Set appropriate motion sensor update rates for the application's needs";
private Swift5Parser.Import_declarationContext importTree = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.greencodeinitiative.creedengo.ios.swift.antlr.generated.Swift5Parser;
import org.antlr.v4.runtime.tree.ParseTree;
import org.sonar.check.Rule;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

import java.util.List;

Expand All @@ -30,6 +31,7 @@
* If found, reports a (positive) issue.
*/
@Rule(key = "GCI519")
@DeprecatedRuleKey(repositoryKey = "ecocode-ios", ruleKey = "EC519")
public class ChargeAwarenessCheck extends SwiftRuleCheck {
private static final String DEFAULT_ISSUE_MESSAGE = "Monitoring power changes and customizing behavior depending on battery level is a good practice";
private static final String PROPERTY_BATTERY_LEVEL = "UIDevice.current.batteryLevel";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
import org.greencodeinitiative.creedengo.ios.swift.antlr.generated.Swift5Parser;
import org.antlr.v4.runtime.tree.ParseTree;
import org.sonar.check.Rule;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

import java.util.List;

@Rule(key = "GCI520")
@DeprecatedRuleKey(repositoryKey = "ecocode-ios", ruleKey = "EC520")
public class SaveModeAwarenessCheck extends SwiftRuleCheck {
private static final String DEFAULT_ISSUE_MESSAGE = "Taking into account when the device is entering or exiting the power save mode is a good practice";
private static final String PROCESS_INFO = "ProcessInfo.processInfo.isLowPowerModeEnabled";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.greencodeinitiative.creedengo.ios.swift.antlr.generated.Swift5Parser;
import org.antlr.v4.runtime.tree.ParseTree;
import org.sonar.check.Rule;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

import java.util.Arrays;
import java.util.List;
Expand All @@ -32,6 +33,7 @@
* Check the use of "UIScreen.main.brightness" and triggers when set.
*/
@Rule(key = "GCI603")
@DeprecatedRuleKey(repositoryKey = "ecocode-ios", ruleKey = "EC603")
public class AnimationFreeCheck extends SwiftRuleCheck {

private static final String DEFAULT_ISSUE_MESSAGE = "Usage of Animations must absolutely be avoided";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.TerminalNodeImpl;
import org.sonar.check.Rule;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

import static org.greencodeinitiative.creedengo.ios.swift.checks.CheckHelper.*;

@Rule(key = "GCI515")
@DeprecatedRuleKey(repositoryKey = "ecocode-ios", ruleKey = "EC515")
public class AudioRecorderLeakCheck extends SwiftRuleCheck {
private static final String DEFAULT_ISSUE_MESSAGE = "Any audio recording started should be stopped.";
Swift5Parser.ExpressionContext id = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
import org.greencodeinitiative.creedengo.ios.swift.antlr.generated.Swift5Parser;
import org.antlr.v4.runtime.tree.ParseTree;
import org.sonar.check.Rule;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

import static org.greencodeinitiative.creedengo.ios.swift.checks.CheckHelper.isExpressionPresent;

/**
* Check the use of "UIScreen.main.brightness" and triggers when set.
*/
@Rule(key = "GCI522")
@DeprecatedRuleKey(repositoryKey = "ecocode-ios", ruleKey = "EC522")
public class BrightnessOverrideCheck extends SwiftRuleCheck {
private static final String DEFAULT_ISSUE_MESSAGE = "Do not force Brightness in your code, unless absolutely necessary";
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@
import org.greencodeinitiative.creedengo.ios.swift.antlr.generated.Swift5Parser;
import org.antlr.v4.runtime.tree.ParseTree;
import org.sonar.check.Rule;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

import java.util.Objects;

import static org.greencodeinitiative.creedengo.ios.swift.checks.CheckHelper.*;

@Rule(key = "GCI528")
@DeprecatedRuleKey(repositoryKey = "ecocode-ios", ruleKey = "EC528")
public class FeedbackGeneratorUsageCheck extends SwiftRuleCheck {
private static final String DEFAULT_ISSUE_MESSAGE = "Avoid using the device vibrator to use less energy.";
public static final String UI_KIT = "UIKit";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@
import org.greencodeinitiative.creedengo.ios.swift.antlr.generated.Swift5Parser;
import org.antlr.v4.runtime.tree.ParseTree;
import org.sonar.check.Rule;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

import static org.greencodeinitiative.creedengo.ios.swift.checks.CheckHelper.isEndOfFile;
import static org.greencodeinitiative.creedengo.ios.swift.checks.CheckHelper.isFunctionCalled;


@Rule(key = "GCI513")
@DeprecatedRuleKey(repositoryKey = "ecocode-ios", ruleKey = "EC513")
public class LocationLeakCheck extends SwiftRuleCheck {
public static final String START_UPDATING_LOCATION_METHOD = "startUpdatingLocation";
public static final String STOP_UPDATING_LOCATION_METHOD = "stopUpdatingLocation";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.greencodeinitiative.creedengo.ios.swift.antlr.generated.Swift5Parser;
import org.antlr.v4.runtime.tree.ParseTree;
import org.sonar.check.Rule;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

import static org.greencodeinitiative.creedengo.ios.swift.checks.CheckHelper.isExpressionPresent;

Expand All @@ -29,6 +30,7 @@
* Check the use of "CLLocationManager#pausesLocationUpdatesAutomatically" and triggers when set to false.
*/
@Rule(key = "GCI533")
@DeprecatedRuleKey(repositoryKey = "ecocode-ios", ruleKey = "EC533")
public class LocationUpdatesDisabledCheck extends SwiftRuleCheck {
private static final String DEFAULT_ISSUE_MESSAGE = "Do not disable location updates pause, unless absolutely necessary";
public static final String LOCATION_UPDATES_DISABLE_EXPRESSION = ".pausesLocationUpdatesAutomatically=false";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.TerminalNodeImpl;
import org.sonar.check.Rule;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

import static org.greencodeinitiative.creedengo.ios.swift.checks.CheckHelper.isEndOfFile;
import static org.greencodeinitiative.creedengo.ios.swift.checks.CheckHelper.isFunctionCalled;

@Rule(key = "GCI514")
@DeprecatedRuleKey(repositoryKey = "ecocode-ios", ruleKey = "EC514")
public class MotionSensorLeakCheck extends SwiftRuleCheck {
private static final String DEFAULT_ISSUE_MESSAGE = "Any motion sensor started should be stopped.";
private boolean motionSensorStarted = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.greencodeinitiative.creedengo.ios.swift.antlr.generated.Swift5Parser;
import org.antlr.v4.runtime.tree.ParseTree;
import org.sonar.check.Rule;
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;

import static org.greencodeinitiative.creedengo.ios.swift.checks.CheckHelper.isExpressionPresent;
import static org.greencodeinitiative.creedengo.ios.swift.checks.CheckHelper.isFunctionCalled;
Expand All @@ -29,6 +30,7 @@
* Check the use of "AVCaptureTorchMode.on", "setTorchModeOn(level: Float)", or "torchMode = .on" and triggers when set to true.
*/
@Rule(key = "GCI530")
@DeprecatedRuleKey(repositoryKey = "ecocode-ios", ruleKey = "EC530")
public class TorchFreeCheck extends SwiftRuleCheck {
private static final String DEFAULT_ISSUE_MESSAGE = "Usage of `AVCaptureDevice#torchMode` or `AVCaptureDevice#setTorchModeOn(level:)` must absolutely be avoided";

Expand Down

0 comments on commit e76f984

Please sign in to comment.