Skip to content

Commit

Permalink
refact: changed used rule ids to match EC5XXX
Browse files Browse the repository at this point in the history
  • Loading branch information
Gilles Grousset committed Mar 16, 2024
1 parent 5361744 commit edb9f99
Show file tree
Hide file tree
Showing 17 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import static io.ecocode.ios.swift.checks.CheckHelper.isImportExisting;

@Rule(key = "EC19")
@Rule(key = "EC522")
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 @@ -25,7 +25,7 @@
/**
* Check the use of "UIApplication.shared.isIdleTimerDisabled" and triggers when set to true.
*/
@Rule(key = "EC14")
@Rule(key = "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 @@ -25,7 +25,7 @@
/**
* Check the presence of the class "Timer".
*/
@Rule(key = "EC15")
@Rule(key = "EC506")
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 @@ -28,7 +28,7 @@

import static io.ecocode.ios.swift.checks.CheckHelper.isImportExisting;

@Rule(key="EC20")
@Rule(key="EC547")
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 @@ -29,7 +29,7 @@
* or `UIDevice.batteryLevelDidChangeNotification` or `UIDevice.batteryStateDidChangeNotification`.
* If found, reports a (positive) issue.
*/
@Rule(key = "EC16")
@Rule(key = "EC602")
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 @@ -24,7 +24,7 @@

import java.util.List;

@Rule(key = "EC17")
@Rule(key = "EC543")
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 @@ -25,7 +25,7 @@
/**
* Check the use of "UIScreen.main.brightness" and triggers when set.
*/
@Rule(key = "EC21")
@Rule(key = "EC523")
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 @@ -26,7 +26,7 @@
/**
* Check the use of "CLLocationManager#pausesLocationUpdatesAutomatically" and triggers when set to false.
*/
@Rule(key = "EC18")
@Rule(key = "EC521")
public class LocationUpdatesDisabledCheck extends SwiftRuleCheck {
private static final String DEFAULT_ISSUE_MESSAGE = "Do not disable location updates pause, unless absolutely necessary";
@Override
Expand Down
16 changes: 8 additions & 8 deletions swift-lang/src/main/resources/ecocode_swift_profile.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "ecoCode",
"ruleKeys": [
"EC14",
"EC15",
"EC16",
"EC17",
"EC18",
"EC19",
"EC20",
"EC21",
"EC505",
"EC506",
"EC602",
"EC543",
"EC521",
"EC522",
"EC547",
"EC523",
"EC23",
"ESOB007"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void Geo_trigger() {
assertThat(context.allIssues()).hasSize(1);
Optional<Issue> issue = context.allIssues().stream().findFirst();
issue.ifPresent(i -> {
assertThat(i.ruleKey().rule()).isEqualTo("EC19");
assertThat(i.ruleKey().rule()).isEqualTo("EC522");

assertThat(i.ruleKey().repository()).isEqualTo("ecoCode-swift");
IssueLocation location = i.primaryLocation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void idleTimerDisabled_trigger() {
assertThat(context.allIssues()).hasSize(1);
Optional<Issue> issue = context.allIssues().stream().findFirst();
issue.ifPresent(i -> {
assertThat(i.ruleKey().rule()).isEqualTo("EC14");
assertThat(i.ruleKey().rule()).isEqualTo("EC505");
assertThat(i.ruleKey().repository()).isEqualTo("ecoCode-swift");
IssueLocation location = i.primaryLocation();
assertThat(location.textRange().start().line()).isEqualTo(11);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void rigidAlarmCheck_trigger() {
assertThat(context.allIssues()).hasSize(1);
Optional<Issue> issue = context.allIssues().stream().findFirst();
issue.ifPresent(i -> {
assertThat(i.ruleKey().rule()).isEqualTo("EC15");
assertThat(i.ruleKey().rule()).isEqualTo("EC506");
assertThat(i.ruleKey().repository()).isEqualTo("ecoCode-swift");
IssueLocation location = i.primaryLocation();
assertThat(location.textRange().start().line()).isEqualTo(11);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void motionSensorRate_trigger() {
assertThat(context.allIssues()).hasSize(1);
Optional<Issue> issue = context.allIssues().stream().findFirst();
issue.ifPresent(i -> {
assertThat(i.ruleKey().rule()).isEqualTo("EC20");
assertThat(i.ruleKey().rule()).isEqualTo("EC547");
assertThat(i.ruleKey().repository()).isEqualTo("ecoCode-swift");
IssueLocation location = i.primaryLocation();
assertThat(location.textRange().start().line()).isEqualTo(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private void chargeAwareness_trigger(String filePath, int lineNumber) {
assertThat(context.allIssues()).hasSize(1);
Optional<Issue> issue = context.allIssues().stream().findFirst();
issue.ifPresent(i -> {
assertThat(i.ruleKey().rule()).isEqualTo("EC16");
assertThat(i.ruleKey().rule()).isEqualTo("EC602");
assertThat(i.ruleKey().repository()).isEqualTo("ecoCode-swift");
IssueLocation location = i.primaryLocation();
assertThat(location.textRange().start().line()).isEqualTo(lineNumber);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void saveModeAwareness_trigger(String filePath, int lineNumber) {
assertThat(context.allIssues()).hasSize(1);
Optional<Issue> issue = context.allIssues().stream().findFirst();
issue.ifPresent(i -> {
assertThat(i.ruleKey().rule()).isEqualTo("EC17");
assertThat(i.ruleKey().rule()).isEqualTo("EC543");
assertThat(i.ruleKey().repository()).isEqualTo("ecoCode-swift");
IssueLocation location = i.primaryLocation();
assertThat(location.textRange().start().line()).isEqualTo(lineNumber);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void brightnessOverrideTrigger() {
assertThat(context.allIssues()).hasSize(1);
Optional<Issue> issue = context.allIssues().stream().findFirst();
issue.ifPresent(i -> {
assertThat(i.ruleKey().rule()).isEqualTo("EC21");
assertThat(i.ruleKey().rule()).isEqualTo("EC523");
assertThat(i.ruleKey().repository()).isEqualTo("ecoCode-swift");
IssueLocation location = i.primaryLocation();
assertThat(location.textRange().start().line()).isEqualTo(11);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void locationUpdatesPausesDisabled_trigger() {
assertThat(context.allIssues()).hasSize(1);
Optional<Issue> issue = context.allIssues().stream().findFirst();
issue.ifPresent(i -> {
assertThat(i.ruleKey().rule()).isEqualTo("EC18");
assertThat(i.ruleKey().rule()).isEqualTo("EC521");
assertThat(i.ruleKey().repository()).isEqualTo("ecoCode-swift");
IssueLocation location = i.primaryLocation();
assertThat(location.textRange().start().line()).isEqualTo(12);
Expand Down

0 comments on commit edb9f99

Please sign in to comment.