Skip to content

Commit c1f580e

Browse files
committed
refactor: Changes rule keys for XML rules to prefix each one by EC
Modifications: * Change android/xml rule key: EBAT001 -> EC540 * Change android/xml rule key: EIDL003 -> EC541 * Change android/xml rule key: EIDL005 -> EC542 * Change android/xml rule key: EPOW002 -> EC543 * Change android/xml rule key: EPOW003 -> EC544 * Change android/xml rule key: EPOW005 -> EC545 * Change android/xml rule key: EPOW007 -> EC546 * Change android/xml rule key: ESOB003 -> EC547 * Change android/xml rule key: ESOB004 -> EC548
1 parent 1f3e6e2 commit c1f580e

32 files changed

+51
-33
lines changed

android-plugin/src/main/java/io/ecocode/xml/Xml.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
package io.ecocode.xml;
2121

2222
public interface Xml { //NOSONAR - we use the interface for constant without inheriting it
23-
String REPOSITORY_NAME = "ecoCode";
23+
String REPOSITORY_NAME = "ecoCode (Android)";
2424
String PROFILE_NAME = "ecoCode";
2525
String KEY = "xml";
26-
String REPOSITORY_KEY = "ecoCode-xml";
27-
String XML_RESOURCE_PATH = "io/ecocode/xml/rules";
26+
String REPOSITORY_KEY = "ecocode-android-xml";
27+
String RULES_SPECIFICATIONS_XML_PATH = "io/ecocode/rules/xml";
2828
String PROFILE_PATH = "io/ecocode/xml/rules/ecocode_xml_profile.json";
2929
}

android-plugin/src/main/java/io/ecocode/xml/XmlRulesDefinition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public final class XmlRulesDefinition implements RulesDefinition {
3333
public void define(Context context) {
3434
NewRepository repository = context.createRepository(Xml.REPOSITORY_KEY, Xml.KEY).setName(Xml.REPOSITORY_NAME);
3535
SonarRuntime sonarRuntime = SonarRuntimeImpl.forSonarQube(Version.create(9, 8), SonarQubeSide.SCANNER, SonarEdition.DEVELOPER);
36-
RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(Xml.XML_RESOURCE_PATH, Xml.PROFILE_PATH,sonarRuntime);
36+
RuleMetadataLoader ruleMetadataLoader = new RuleMetadataLoader(Xml.RULES_SPECIFICATIONS_XML_PATH, Xml.PROFILE_PATH,sonarRuntime);
3737

3838
// add the new checks
3939
ruleMetadataLoader.addRulesByAnnotatedClass(repository, XmlCheckList.getXmlChecks());

android-plugin/src/main/java/io/ecocode/xml/checks/batch/ServiceBootTimeXmlRule.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@
2121

2222
import io.ecocode.xml.checks.XPathSimpleCheck;
2323
import org.sonar.check.Rule;
24+
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
2425

2526
/**
2627
* Checks manifest intent-filter statement: if the action is BOOT_COMPLETED, report a bad practice
2728
*/
28-
@Rule(key = "EBAT001", name = "ecoServiceBootTimeXml")
29+
@Rule(key = "EC540")
30+
@DeprecatedRuleKey(repositoryKey = "ecoCode-xml", ruleKey = "EBAT001")
2931
public class ServiceBootTimeXmlRule extends XPathSimpleCheck {
3032

3133
private static final String SERVICE_BOOT_TIME_ATTRIBUTE = "//manifest/application/receiver/intent-filter/action/@name[. = \"android.intent.action.BOOT_COMPLETED\"]";

android-plugin/src/main/java/io/ecocode/xml/checks/idleness/KeepCpuOnXmlRule.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121

2222
import io.ecocode.xml.checks.helpers.CheckPermissionsRule;
2323
import org.sonar.check.Rule;
24+
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
2425

2526
/**
2627
* Checks manifest uses-permissions statement.
2728
* if the permissions "android.permission.WAKE_LOCK" is found, report an issue.
2829
*/
29-
@Rule(key = "EIDL005", name = "ecocodeKeepCpuOnXml")
30+
@Rule(key = "EC542")
31+
@DeprecatedRuleKey(repositoryKey = "ecoCode-xml", ruleKey = "EIDL005")
3032
public class KeepCpuOnXmlRule extends CheckPermissionsRule {
3133

3234
private static final String PERMISSION_NAME = "android.permission.WAKE_LOCK";
@@ -35,4 +37,4 @@ public class KeepCpuOnXmlRule extends CheckPermissionsRule {
3537
public KeepCpuOnXmlRule() {
3638
super(PERMISSION_NAME, ERROR_MESSAGE);
3739
}
38-
}
40+
}

android-plugin/src/main/java/io/ecocode/xml/checks/idleness/KeepScreenOnXmlRule.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121

2222
import io.ecocode.xml.checks.XPathSimpleCheck;
2323
import org.sonar.check.Rule;
24+
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
2425

25-
@Rule(key = "EIDL003", name = "ecoKeepScreenOnXml")
26+
@Rule(key = "EC541")
27+
@DeprecatedRuleKey(repositoryKey = "ecoCode-xml", ruleKey = "EIDL003")
2628
public class KeepScreenOnXmlRule extends XPathSimpleCheck {
2729

2830
private static final String KEEP_SCREEN_ON_XML_ATTRIBUTE = "//*[contains(@keepScreenOn, 'true')]/@keepScreenOn";

android-plugin/src/main/java/io/ecocode/xml/checks/power/ChargeAwarenessXmlRule.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121

2222
import io.ecocode.xml.checks.XPathSimpleCheck;
2323
import org.sonar.check.Rule;
24+
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
2425

2526
/**
2627
* Checks manifest intent-filter statement: if the action is ACTION_POWER_CONNECTED, ACTION_POWER_DISCONNECTED,
2728
* BATTERY_OKAY or BATTERY_LOW report a good practice.
2829
*/
29-
@Rule(key = "EPOW005", name = "ecocodeBatteryAwarenessXml")
30+
@Rule(key = "EC545")
31+
@DeprecatedRuleKey(repositoryKey = "ecoCode-xml", ruleKey = "EPOW005")
3032
public class ChargeAwarenessXmlRule extends XPathSimpleCheck {
3133

3234
private String xPathActionPowerConnected = "//manifest/application/receiver/intent-filter/action/@name[.=\"android.intent.action.ACTION_POWER_CONNECTED\"]";

android-plugin/src/main/java/io/ecocode/xml/checks/power/CompagnionInBackgroundXmlRule.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121

2222
import io.ecocode.xml.checks.helpers.CheckPermissionsRule;
2323
import org.sonar.check.Rule;
24+
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
2425

2526
/**
2627
* Checks manifest uses-permissions statement:
2728
* if the permission "android.permission.REQUEST_COMPANION_RUN_IN_BACKGROUND" is found, report an issue.
2829
*/
29-
@Rule(key = "EPOW002", name = "ecocodeCompagnionInBackgroundXml")
30+
@Rule(key = "EC543")
31+
@DeprecatedRuleKey(repositoryKey = "ecoCode-xml", ruleKey = "EPOW002")
3032
public class CompagnionInBackgroundXmlRule extends CheckPermissionsRule {
3133

3234
private static final String PERMISSION_NAME = "android.permission.REQUEST_COMPANION_RUN_IN_BACKGROUND";

android-plugin/src/main/java/io/ecocode/xml/checks/power/IgnoreBatteryOptimizationsXmlRule.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121

2222
import io.ecocode.xml.checks.helpers.CheckPermissionsRule;
2323
import org.sonar.check.Rule;
24+
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
2425

2526
/**
2627
* Checks manifest uses-permissions statement:
2728
* if the permission "android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" is found, report an issue.
2829
*/
29-
@Rule(key = "EPOW003", name = "ecocodeIgnoreBatteryOptimizations")
30+
@Rule(key = "EC544")
31+
@DeprecatedRuleKey(repositoryKey = "ecoCode-xml", ruleKey = "EPOW003")
3032
public class IgnoreBatteryOptimizationsXmlRule extends CheckPermissionsRule {
3133

3234
private static final String PERMISSION_NAME = "android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS";

android-plugin/src/main/java/io/ecocode/xml/checks/power/SaveModeAwarenessXmlRule.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121

2222
import io.ecocode.xml.checks.XPathSimpleCheck;
2323
import org.sonar.check.Rule;
24+
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
2425

2526
/**
2627
* Checks manifest uses-permissions statement:
2728
* if the permission "android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" is found, report an issue.
2829
*/
29-
@Rule(key = "EPOW007", name = "ecocodeSaveModeAwarenessXml")
30+
@Rule(key = "EC546")
31+
@DeprecatedRuleKey(repositoryKey = "ecoCode-xml", ruleKey = "EPOW007")
3032
public class SaveModeAwarenessXmlRule extends XPathSimpleCheck {
3133

3234
private static final String ACTION_POWER_CHANGED_XPATH = "//manifest/application/receiver/intent-filter/action/@name[.=\"android.intent.action.BATTERY_CHANGED\"]";
@@ -41,4 +43,4 @@ protected String getMessage() {
4143
protected String getXPathExpressionString() {
4244
return ACTION_POWER_CHANGED_XPATH;
4345
}
44-
}
46+
}

android-plugin/src/main/java/io/ecocode/xml/checks/sobriety/DarkUIBrightColorsXmlRule.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import io.ecocode.xml.checks.XPathCheck;
2323
import org.sonar.check.Rule;
24+
import org.sonarsource.analyzer.commons.annotations.DeprecatedRuleKey;
2425
import org.w3c.dom.Node;
2526

2627
/**
@@ -36,7 +37,8 @@
3637
* <li>If the value is an hexa value >= to a given brightness threshold throw an issue</li>
3738
* </ul>
3839
*/
39-
@Rule(key = "ESOB003", name = "ecocodeCheckColorXml")
40+
@Rule(key = "EC547")
41+
@DeprecatedRuleKey(repositoryKey = "ecoCode-xml", ruleKey = "ESOB003")
4042
public class DarkUIBrightColorsXmlRule extends XPathCheck {
4143

4244
private static final String[] ATTRIBUTES_TO_CHECK = {

0 commit comments

Comments
 (0)