├── .github └── workflows │ └── build.yml ├── .gitignore ├── COPYING ├── LICENCE.md ├── README.md ├── docs ├── README.md ├── resources │ ├── challenge-logo.png │ ├── logo-large.png │ └── screenshot.PNG └── rules │ ├── README.md │ ├── web-matrix.md │ └── web-rules.md ├── hackathon ├── README.md ├── coding-tips.md ├── starter-pack.md └── work-packages.md ├── sonarqube-plugin-greenit └── python-plugin │ └── src │ ├── main │ └── resources │ │ └── fr │ │ └── cnumr │ │ └── l10n │ │ └── python │ │ └── rules │ │ └── python │ │ ├── 64.html │ │ └── 64.json │ └── test │ ├── java │ └── fr │ │ └── cnumr │ │ └── python │ │ └── checks │ │ └── AvoidSQLRequestInLoopCheckTest.java │ └── resources │ └── checks │ └── AvoidSQLRequestInLoopCheck.py └── src ├── .gitignore ├── .gitkeep ├── 0_init_reinit.sh ├── 1_compile.sh ├── 2_build.sh ├── 3_start.sh ├── 4_stop.sh ├── INSTALL.md ├── README.md ├── android-plugin ├── CONTRIBUTING.md ├── Dockerfile ├── LICENSE.txt ├── NOTICE.txt ├── README.md ├── docker-compose.yml ├── docs │ ├── ekko-sonar.png │ ├── logo.png │ ├── logoCCNR.png │ ├── logoNA.png │ ├── logoSnapp.png │ └── logoUnivPau.png ├── images │ └── creed-4-sur-5.png ├── pom.xml └── src │ ├── main │ ├── java │ │ ├── io │ │ │ └── ecocode │ │ │ │ ├── EcoCodeRulesPlugin.java │ │ │ │ ├── java │ │ │ │ ├── Java.java │ │ │ │ ├── JavaCheckList.java │ │ │ │ ├── JavaEcoCodeProfile.java │ │ │ │ ├── JavaFileCheckRegistrar.java │ │ │ │ ├── JavaRulesDefinition.java │ │ │ │ └── checks │ │ │ │ │ ├── batch │ │ │ │ │ ├── JobCoalesceRule.java │ │ │ │ │ └── SensorCoalesceRule.java │ │ │ │ │ ├── bottleneck │ │ │ │ │ ├── InternetInTheLoopRule.java │ │ │ │ │ ├── UncompressedDataTransmissionRule.java │ │ │ │ │ └── WifiMulticastLockRule.java │ │ │ │ │ ├── helpers │ │ │ │ │ ├── CheckArgumentComplexTypeUtils.java │ │ │ │ │ ├── ConstructorBeforeMethodCheck.java │ │ │ │ │ ├── OpeningClosingMethodCheck.java │ │ │ │ │ ├── SpecificMethodCheck.java │ │ │ │ │ ├── TreeHelper.java │ │ │ │ │ └── constant │ │ │ │ │ │ ├── ArgumentValueOnMethodCheck.java │ │ │ │ │ │ ├── ConstantOnMethodCheck.java │ │ │ │ │ │ ├── FlagOnMethodCheck.java │ │ │ │ │ │ └── MethodSpecs.java │ │ │ │ │ ├── idleness │ │ │ │ │ ├── ContinuousRenderingRule.java │ │ │ │ │ ├── DurableWakeLockRule.java │ │ │ │ │ ├── KeepCpuOnRule.java │ │ │ │ │ ├── KeepScreenOnAddFlagsRule.java │ │ │ │ │ ├── KeepScreenOnSetFlagsRule.java │ │ │ │ │ ├── KeepVoiceAwakeRule.java │ │ │ │ │ └── RigidAlarmRule.java │ │ │ │ │ ├── leakage │ │ │ │ │ ├── CameraLeakRule.java │ │ │ │ │ ├── LocationLeakRule.java │ │ │ │ │ ├── MediaLeakMediaPlayerRule.java │ │ │ │ │ ├── MediaLeakMediaRecorderRule.java │ │ │ │ │ └── SensorManagerLeakRule.java │ │ │ │ │ ├── optimized_api │ │ │ │ │ ├── BluetoothLowEnergyRule.java │ │ │ │ │ └── FusedLocationRule.java │ │ │ │ │ ├── power │ │ │ │ │ ├── ChargeAwarenessRule.java │ │ │ │ │ └── SaveModeAwarenessRule.java │ │ │ │ │ └── sobriety │ │ │ │ │ ├── BrightnessOverrideRule.java │ │ │ │ │ ├── HighFrameRateRule.java │ │ │ │ │ ├── ThriftyBluetoothLowEnergyRequestConnectionPriorityRule.java │ │ │ │ │ ├── ThriftyBluetoothLowEnergySetAdvertiseModeRule.java │ │ │ │ │ ├── ThriftyGeolocationCriteriaRule.java │ │ │ │ │ ├── ThriftyGeolocationMinDistanceRule.java │ │ │ │ │ ├── ThriftyGeolocationMinTimeRule.java │ │ │ │ │ ├── ThriftyMotionSensorRule.java │ │ │ │ │ ├── ThriftyNotificationRule.java │ │ │ │ │ ├── TorchFreeRule.java │ │ │ │ │ └── VibrationFreeRule.java │ │ │ │ └── xml │ │ │ │ ├── Xml.java │ │ │ │ ├── XmlCheckList.java │ │ │ │ ├── XmlEcoCodeProfile.java │ │ │ │ ├── XmlRulesDefinition.java │ │ │ │ ├── XmlSensor.java │ │ │ │ └── checks │ │ │ │ ├── XPathCheck.java │ │ │ │ ├── XPathSimpleCheck.java │ │ │ │ ├── batch │ │ │ │ └── ServiceBootTimeXmlRule.java │ │ │ │ ├── helpers │ │ │ │ └── CheckPermissionsRule.java │ │ │ │ ├── idleness │ │ │ │ ├── KeepCpuOnXmlRule.java │ │ │ │ └── KeepScreenOnXmlRule.java │ │ │ │ ├── power │ │ │ │ ├── ChargeAwarenessXmlRule.java │ │ │ │ ├── CompagnionInBackgroundXmlRule.java │ │ │ │ ├── IgnoreBatteryOptimizationsXmlRule.java │ │ │ │ └── SaveModeAwarenessXmlRule.java │ │ │ │ └── sobriety │ │ │ │ ├── DarkUIBrightColorsXmlRule.java │ │ │ │ └── DarkUIThemeXmlRule.java │ │ └── org │ │ │ └── sonar │ │ │ └── plugins │ │ │ └── groovy │ │ │ ├── GroovyPlugin.java │ │ │ ├── GroovySensor.java │ │ │ ├── GroovySonarWayProfile.java │ │ │ ├── cobertura │ │ │ ├── CoberturaReportParser.java │ │ │ ├── CoberturaSensor.java │ │ │ └── package-info.java │ │ │ ├── codenarc │ │ │ ├── CodeNarcProfileExporter.java │ │ │ ├── CodeNarcRulesDefinition.java │ │ │ ├── CodeNarcSensor.java │ │ │ ├── CodeNarcSourceAnalyzer.java │ │ │ ├── CodeNarcXMLParser.java │ │ │ └── package-info.java │ │ │ ├── foundation │ │ │ ├── Groovy.java │ │ │ ├── GroovyFileSystem.java │ │ │ ├── GroovyHighlighterAndTokenizer.java │ │ │ └── package-info.java │ │ │ ├── gmetrics │ │ │ ├── GMetricsSourceAnalyzer.java │ │ │ └── package-info.java │ │ │ ├── jacoco │ │ │ ├── ExecutionDataVisitor.java │ │ │ ├── JaCoCoAnalyzer.java │ │ │ ├── JaCoCoConfiguration.java │ │ │ ├── JaCoCoExtensions.java │ │ │ ├── JaCoCoReportMerger.java │ │ │ ├── JaCoCoReportReader.java │ │ │ ├── JaCoCoSensor.java │ │ │ └── package-info.java │ │ │ ├── package-info.java │ │ │ ├── surefire │ │ │ ├── GroovySurefireParser.java │ │ │ ├── GroovySurefireSensor.java │ │ │ ├── api │ │ │ │ ├── SurefireUtils.java │ │ │ │ └── package-info.java │ │ │ ├── data │ │ │ │ ├── SurefireStaxHandler.java │ │ │ │ ├── UnitTestClassReport.java │ │ │ │ ├── UnitTestIndex.java │ │ │ │ ├── UnitTestResult.java │ │ │ │ └── package-info.java │ │ │ └── package-info.java │ │ │ └── utils │ │ │ ├── StaxParser.java │ │ │ └── package-info.java │ └── resources │ │ ├── io │ │ └── ecocode │ │ │ └── xml │ │ │ └── rules │ │ │ ├── EBAT001.html │ │ │ ├── EBAT001.json │ │ │ ├── EIDL003.html │ │ │ ├── EIDL003.json │ │ │ ├── EIDL005.html │ │ │ ├── EIDL005.json │ │ │ ├── EPOW002.html │ │ │ ├── EPOW002.json │ │ │ ├── EPOW003.html │ │ │ ├── EPOW003.json │ │ │ ├── EPOW005.html │ │ │ ├── EPOW005.json │ │ │ ├── EPOW007.html │ │ │ ├── EPOW007.json │ │ │ ├── ESOB003.html │ │ │ ├── ESOB003.json │ │ │ ├── ESOB004.html │ │ │ ├── ESOB004.json │ │ │ ├── README.md │ │ │ └── ecocode_xml_profile.json │ │ └── org │ │ └── sonar │ │ ├── l10n │ │ └── java │ │ │ └── rules │ │ │ └── squid │ │ │ ├── EBAT002_java.html │ │ │ ├── EBAT002_java.json │ │ │ ├── EBAT003_java.html │ │ │ ├── EBAT003_java.json │ │ │ ├── EBOT001_java.html │ │ │ ├── EBOT001_java.json │ │ │ ├── EBOT002_java.html │ │ │ ├── EBOT002_java.json │ │ │ ├── EBOT003_java.html │ │ │ ├── EBOT003_java.json │ │ │ ├── EIDL001_java.html │ │ │ ├── EIDL001_java.json │ │ │ ├── EIDL002_java.html │ │ │ ├── EIDL002_java.json │ │ │ ├── EIDL004_java.html │ │ │ ├── EIDL004_java.json │ │ │ ├── EIDL006_java.html │ │ │ ├── EIDL006_java.json │ │ │ ├── EIDL007_java.html │ │ │ ├── EIDL007_java.json │ │ │ ├── EIDL008_java.html │ │ │ ├── EIDL008_java.json │ │ │ ├── EIDL009_java.html │ │ │ ├── EIDL009_java.json │ │ │ ├── ELEA002_java.html │ │ │ ├── ELEA002_java.json │ │ │ ├── ELEA003_java.html │ │ │ ├── ELEA003_java.json │ │ │ ├── ELEA004_java.html │ │ │ ├── ELEA004_java.json │ │ │ ├── ELEA005_java.html │ │ │ ├── ELEA005_java.json │ │ │ ├── ELEA006_java.html │ │ │ ├── ELEA006_java.json │ │ │ ├── EOPT001_java.html │ │ │ ├── EOPT001_java.json │ │ │ ├── EOPT002_java.html │ │ │ ├── EOPT002_java.json │ │ │ ├── EPOW004_java.html │ │ │ ├── EPOW004_java.json │ │ │ ├── EPOW006_java.html │ │ │ ├── EPOW006_java.json │ │ │ ├── ESOB001_java.html │ │ │ ├── ESOB001_java.json │ │ │ ├── ESOB002_java.html │ │ │ ├── ESOB002_java.json │ │ │ ├── ESOB005_java.html │ │ │ ├── ESOB005_java.json │ │ │ ├── ESOB006_java.html │ │ │ ├── ESOB006_java.json │ │ │ ├── ESOB007_java.html │ │ │ ├── ESOB007_java.json │ │ │ ├── ESOB008_java.html │ │ │ ├── ESOB008_java.json │ │ │ ├── ESOB010_java.html │ │ │ ├── ESOB010_java.json │ │ │ ├── ESOB011_java.html │ │ │ ├── ESOB011_java.json │ │ │ ├── ESOB012_java.html │ │ │ ├── ESOB012_java.json │ │ │ ├── ESOB013_java.html │ │ │ ├── ESOB013_java.json │ │ │ ├── ESOB014_java.html │ │ │ ├── ESOB014_java.json │ │ │ ├── README.md │ │ │ └── ecocode_java_profile.json │ │ └── plugins │ │ └── groovy │ │ ├── cost.csv │ │ ├── profile-default.txt │ │ └── rules.xml │ └── test │ ├── files │ ├── batch │ │ ├── JobCoalesceCheckAlarmManager.java │ │ ├── JobCoalesceCheckSyncAdapter.java │ │ └── SensorCoalesceCheck.java │ ├── bottleneck │ │ ├── InternetInTheLoopCheck.java │ │ ├── UncompressedDataTransmissionCheck.java │ │ ├── WifiMulticastLockCheck.java │ │ └── WifiMulticastLockNoIssueCheck.java │ ├── idleness │ │ ├── ContinuousRenderingCheck.java │ │ ├── DurableWakeLockCheck.java │ │ ├── KeepCpuOnCheck.java │ │ ├── KeepScreenOnAddFlagsCheck.java │ │ ├── KeepScreenOnSetFlagsCheck.java │ │ ├── KeepVoiceAwakeCheck.java │ │ ├── KeepVoiceAwakeNotPresentCheck.java │ │ ├── KeepVoiceAwakeToFalseCheck.java │ │ └── RigidAlarmCheck.java │ ├── leakage │ │ ├── CameraLeakCheckIssue.java │ │ ├── CameraLeakCheckNoIssue.java │ │ ├── LocationLeakCheckIssue.java │ │ ├── LocationLealCheckNoIssue.java │ │ ├── MediaLeakMediaPlayerCheckIssue.java │ │ ├── MediaLeakMediaPlayerCheckNoIssue.java │ │ ├── MediaLeakMediaRecorderCheckIssue.java │ │ ├── MediaLeakMediaRecorderCheckNoIssue.java │ │ ├── SensorManagerLeakCheckIssue.java │ │ └── SensorManagerLeakCheckNoIssue.java │ ├── optimized_api │ │ ├── BluetoothLowEnergyCheckBothBleBc.java │ │ ├── BluetoothLowEnergyCheckOnlyBc.java │ │ ├── BluetoothLowEnergyCheckOnlyBle.java │ │ ├── BluetoothLowEnergyCheckWildcard.java │ │ ├── FusedLocationCheck.java │ │ └── FusedLocationCheckNoIssue.java │ ├── power │ │ ├── ChargeAwarenessCheck.java │ │ ├── SaveModeAwarenessCheckIntentFilter.java │ │ └── SaveModeAwarenessCheckPowerManager.java │ └── sobriety │ │ ├── BrightnessOverrideCheck.java │ │ ├── HighFrameRateCheck.java │ │ ├── ThriftyBluetoothLowEnergyRequestConnectionPriorityCheck.java │ │ ├── ThriftyBluetoothLowEnergySetAdvertiseModeCheck.java │ │ ├── ThriftyGeolocationCheck.java │ │ ├── ThriftyGeolocationCriteriaCheckNoCriteria.java │ │ ├── ThriftyGeolocationCriteriaCheckNoIssue.java │ │ ├── ThriftyGeolocationCriteriaCheckOnlyRequest.java │ │ ├── ThriftyGeolocationCriteriaCheckWrongCriteria.java │ │ ├── ThriftyMotionSensorCheck.java │ │ ├── ThriftyNotificationCheckBuilder.java │ │ ├── ThriftyNotificationCheckChannel.java │ │ ├── TorchFreeCheck.java │ │ ├── VibrationFreeCheckActivity.java │ │ └── VibrationFreeCheckContext.java │ ├── java │ ├── io │ │ └── ecocode │ │ │ ├── java │ │ │ ├── JavaEcoCodeProfileTest.java │ │ │ ├── JavaRulesDefinitionTest.java │ │ │ └── checks │ │ │ │ ├── batch │ │ │ │ ├── JobCoalesceRuleTest.java │ │ │ │ └── SensorCoalesceRuleTest.java │ │ │ │ ├── bottleneck │ │ │ │ ├── InternetInTheLoopRuleTest.java │ │ │ │ ├── UncompressedDataTransmissionRulesTest.java │ │ │ │ └── WifiMulticastLockRuleTest.java │ │ │ │ ├── idleness │ │ │ │ ├── ContinuousRenderingTest.java │ │ │ │ ├── DurableWakeLockRuleTest.java │ │ │ │ ├── KeepCpuOnRuleTest.java │ │ │ │ ├── KeepScreenOnAddFlagsRuleTest.java │ │ │ │ ├── KeepScreenOnSetFlagsRuleTest.java │ │ │ │ ├── KeepVoiceAwakeTest.java │ │ │ │ └── RigidAlarmRuleTest.java │ │ │ │ ├── leakage │ │ │ │ ├── CameraLeakRuleTest.java │ │ │ │ ├── LocationLeakRuleTest.java │ │ │ │ ├── MediaLeakMediaPlayerRuleTest.java │ │ │ │ ├── MediaLeakMediaRecorderRuleTest.java │ │ │ │ └── SensorManagerLeakRuleTest.java │ │ │ │ ├── optimized_api │ │ │ │ ├── BluetoothLowEnergyRuleTest.java │ │ │ │ └── FusedLocationCheckTest.java │ │ │ │ ├── power │ │ │ │ ├── ChargeAwarenessRuleTest.java │ │ │ │ └── SaveModeAwarenessRuleTest.java │ │ │ │ └── sobriety │ │ │ │ ├── BrightnessOverrideRuleTest.java │ │ │ │ ├── HighFrameRateCheckTest.java │ │ │ │ ├── ThriftyBluetoothLowEnergyRequestConnectionPriorityRuleTest.java │ │ │ │ ├── ThriftyBluetoothLowEnergySetAdvertiseModeRuleTest.java │ │ │ │ ├── ThriftyGeolocationCheckTest.java │ │ │ │ ├── ThriftyGeolocationCriteriaTest.java │ │ │ │ ├── ThriftyMotionSensorRuleTest.java │ │ │ │ ├── ThriftyNotificationRuleTest.java │ │ │ │ ├── TorchFreeRuleTest.java │ │ │ │ └── VibrationFreeRuleTest.java │ │ │ └── xml │ │ │ ├── XmlEcoCodeProfileTest.java │ │ │ ├── XmlRulesDefinitionTest.java │ │ │ └── checks │ │ │ ├── batch │ │ │ └── ServiceBootTimeXmlRuleTest.java │ │ │ ├── idleness │ │ │ ├── KeepCpuOnXmlRuleTest.java │ │ │ └── KeepScreenOnXmlRuleTest.java │ │ │ ├── power │ │ │ ├── ChargeAwarenessXmlRuleTest.java │ │ │ ├── CompagnionInBackgroundXmlRuleTest.java │ │ │ ├── IgnoreBatteryOptimizationsXmlRuleTest.java │ │ │ └── SaveModeAwarenessXmlRuleTest.java │ │ │ └── sobriety │ │ │ ├── DarkUIBrightColorsXmlRuleTest.java │ │ │ └── DarkUIThemeXmlRuleTest.java │ └── org │ │ └── sonar │ │ └── plugins │ │ └── groovy │ │ ├── GroovyPluginTest.java │ │ ├── GroovySensorTest.java │ │ ├── GroovySonarWayProfileTest.java │ │ ├── TestUtils.java │ │ ├── cobertura │ │ └── CoberturaSensorTest.java │ │ ├── codenarc │ │ ├── ActiveRulesBuilderWrapper.java │ │ ├── CodeNarcProfileExporterTest.java │ │ ├── CodeNarcRulesDefinitionTest.java │ │ ├── CodeNarcSensorTest.java │ │ └── CodeNarcXMLParserTest.java │ │ ├── foundation │ │ ├── GroovyFileSystemTest.java │ │ ├── GroovyHighlighterAndTokenizerTest.java │ │ └── GroovyTest.java │ │ ├── jacoco │ │ ├── ExecutionDataVisitorTest.java │ │ ├── JaCoCoConfigurationTest.java │ │ ├── JaCoCoExtensionsTest.java │ │ ├── JaCoCoItSensorTest.java │ │ └── JaCoCoReportReaderTest.java │ │ ├── surefire │ │ ├── GroovySurefireParserTest.java │ │ ├── GroovySurefireSensorTest.java │ │ ├── api │ │ │ └── SurefireUtilsTest.java │ │ └── data │ │ │ └── UnitTestResultTest.java │ │ └── utils │ │ └── StaxParserTest.java │ └── resources │ ├── checks │ ├── ChargeAwarenessXmlRule │ │ └── ChargeAwarenessXmlCheck.xml │ ├── CompagnionInBackgroundXmlRule │ │ └── CompagnionInBackgroundXmlCheck.xml │ ├── DarkUIBrightColorsXmlRule │ │ ├── DarkUIBrightColorsXmlCheck.xml │ │ └── DarkUIBrightColorsXmlCheckResources.xml │ ├── DarkUIThemeXmlRule │ │ ├── DarkUIThemeXmlCheckManifest.xml │ │ └── DarkUIThemeXmlCheckStyle.xml │ ├── IgnoreBatteryOptimizationsXmlRule │ │ ├── IgnoreBatteryOptimizationsXmlCheckNoReport.xml │ │ └── IgnoreBatteryOptimizationsXmlCheckReport.xml │ ├── KeepCpuOnXmlRule │ │ ├── KeepCpuOnXmlCheckNoReport.xml │ │ └── KeepCpuOnXmlCheckReport.xml │ ├── KeepScreenOnXmlRule │ │ ├── KeepScreenOnXmlCheckFalse.xml │ │ └── KeepScreenOnXmlCheckTrue.xml │ ├── SaveModeAwarenessXmlRule │ │ └── SaveModeAwarenessXmlCheck.xml │ └── ServiceBootTimeXmlRule │ │ └── ServiceBootTimeXmlCheck.xml │ └── org │ └── sonar │ └── plugins │ └── groovy │ ├── cobertura │ └── coverage.xml │ ├── codenarc │ ├── exportProfile │ │ ├── exportEscapedParameters.xml │ │ ├── exportFixedRules.xml │ │ ├── exportNullParameters.xml │ │ ├── exportParameters.xml │ │ └── exportProfile.xml │ └── parsing │ │ ├── Sample.groovy │ │ ├── line-number-not-specified.xml │ │ └── sample.xml │ ├── foundation │ ├── Error.groovy │ └── Greet.groovy │ ├── gmetrics │ └── Greeting.groovy │ ├── jacoco │ ├── Hello$InnerClass.class.toCopy │ ├── Hello.class.toCopy │ ├── JaCoCoSensor_0_7_4 │ │ ├── jacoco-ut.exec │ │ └── readme.txt │ ├── JaCoCoSensor_0_7_5 │ │ ├── jacoco-ut.exec │ │ └── readme.txt │ └── JaCoCo_incompatible_merge │ │ ├── jacoco-0.7.4.exec │ │ ├── jacoco-0.7.5.exec │ │ ├── jacoco-it-0.7.4.exec │ │ └── jacoco-it-0.7.5.exec │ └── surefire │ ├── SurefireParserTest │ ├── innerClasses │ │ └── TEST-org.apache.commons.collections.TestAllPackages.xml │ ├── multipleReports │ │ ├── TEST-ch.hortis.sonar.mvn.SonarMojoTest.xml │ │ ├── TEST-ch.hortis.sonar.mvn.mc.CheckstyleCollectorTest.xml │ │ ├── TEST-ch.hortis.sonar.mvn.mc.CloverCollectorTest.xml │ │ ├── TEST-ch.hortis.sonar.mvn.mc.JDependsCollectorTest.xml │ │ ├── TEST-ch.hortis.sonar.mvn.mc.JavaNCSSCollectorTest.xml │ │ ├── TEST-ch.hortis.sonar.mvn.mc.MetricsCollectorRegistryTest.xml │ │ └── TESTS-AllTests.xml │ ├── negativeTestTime │ │ └── TEST-java.xml │ ├── nestedInnerClasses │ │ ├── TEST-org.sonar.plugins.surefire.NestedTest$Inner1$Run.xml │ │ └── TEST-org.sonar.plugins.surefire.NestedTest$Inner2$Run.xml │ ├── noTests │ │ └── TEST-noTests.xml │ └── onlyTestSuiteReport │ │ └── TESTS-AllTests.xml │ ├── SurefireSensorTest │ ├── doNotSaveInnerClasses │ │ └── TEST-org.apache.commons.collections.TestAllPackages.xml │ ├── ignoreSuiteAsInnerClass │ │ ├── TEST-org.apache.shindig.protocol.TestHandler$Input.xml │ │ └── TEST-org.apache.shindig.protocol.TestHandler.xml │ ├── many-results │ │ ├── TEST-ch.hortis.sonar.mvn.SonarMojoTest.xml │ │ ├── TEST-ch.hortis.sonar.mvn.mc.CheckstyleCollectorTest.xml │ │ ├── TEST-ch.hortis.sonar.mvn.mc.CloverCollectorTest.xml │ │ ├── TEST-ch.hortis.sonar.mvn.mc.JDependsCollectorTest.xml │ │ ├── TEST-ch.hortis.sonar.mvn.mc.JavaNCSSCollectorTest.xml │ │ └── TEST-ch.hortis.sonar.mvn.mc.MetricsCollectorRegistryTest.xml │ ├── measuresShouldNotIncludeSkippedTests │ │ └── TEST-FooTest.xml │ ├── noSuccessRatioIfNoTests │ │ └── TEST-FooTest.xml │ ├── roundingTests │ │ └── TEST-Rounding.xml │ ├── shouldHandleMultipleSuitesInSameFile │ │ └── TESTS-MutlipleSuites.xml │ ├── shouldHandleTestSuiteDetails │ │ ├── ExtensionsFinderTest-expected-result.xml │ │ ├── ExtensionsFinderTest2-expected-result.xml │ │ ├── ExtensionsFinderTest3-expected-result.xml │ │ └── TEST-org.sonar.core.ExtensionsFinderTestSuite.xml │ ├── shouldManageClassesWithDefaultPackage │ │ └── TEST-NoPackagesTest.xml │ ├── shouldSaveErrorsAndFailuresInXML │ │ ├── TEST-org.sonar.core.ExtensionsFinderTest.xml │ │ └── expected-test-details.xml │ └── successRatioIsZeroWhenAllTestsFail │ │ └── TEST-FooTest.xml │ └── api │ └── SurefireUtilsTest │ └── shouldGetReportsFromProperty │ └── pom.xml ├── codenarc-converter ├── CodeNarc │ ├── .gitattributes │ ├── .gitignore │ ├── .groovylintrc.json │ ├── .travis.yml │ ├── CHANGELOG.md │ ├── LICENSE.txt │ ├── NOTICE.txt │ ├── README.md │ ├── build.gradle │ ├── codenarc.groovy │ ├── docker │ │ ├── Dockerfile │ │ ├── README.md │ │ └── build.gradle.template │ ├── docs │ │ ├── CNAME │ │ ├── SampleCodeNarcHtmlReport.html │ │ ├── SampleCodeNarcJsonReport.json │ │ ├── SampleCodeNarcSortableHtmlReport.html │ │ ├── SampleCodeNarcTextReport.txt │ │ ├── SampleCodeNarcXmlReport.xml │ │ ├── StarterRuleSet-AllRules.groovy.txt │ │ ├── StarterRuleSet-AllRulesByCategory.groovy.txt │ │ ├── _config.yml │ │ ├── _data │ │ │ └── navigation.yml │ │ ├── _layouts │ │ │ └── default.html │ │ ├── c.sh │ │ ├── codenarc-ant-task.md │ │ ├── codenarc-baseline-xml-report-writer.md │ │ ├── codenarc-command-line.md │ │ ├── codenarc-config-for-frameworks.md │ │ ├── codenarc-configuring-rules.md │ │ ├── codenarc-creating-rule.md │ │ ├── codenarc-creating-ruleset.md │ │ ├── codenarc-developer-guide.md │ │ ├── codenarc-docker.md │ │ ├── codenarc-enhanced-classpath-rules.md │ │ ├── codenarc-html-report-writer.md │ │ ├── codenarc-json-report-writer.md │ │ ├── codenarc-other-tools-frameworks.md │ │ ├── codenarc-rule-index-by-name.md │ │ ├── codenarc-rule-index.md │ │ ├── codenarc-rules-basic.md │ │ ├── codenarc-rules-braces.md │ │ ├── codenarc-rules-comments.md │ │ ├── codenarc-rules-concurrency.md │ │ ├── codenarc-rules-convention.md │ │ ├── codenarc-rules-design.md │ │ ├── codenarc-rules-dry.md │ │ ├── codenarc-rules-ecocode.md │ │ ├── codenarc-rules-enhanced.md │ │ ├── codenarc-rules-exceptions.md │ │ ├── codenarc-rules-formatting.md │ │ ├── codenarc-rules-generic.md │ │ ├── codenarc-rules-grails.md │ │ ├── codenarc-rules-groovyism.md │ │ ├── codenarc-rules-imports.md │ │ ├── codenarc-rules-jdbc.md │ │ ├── codenarc-rules-junit.md │ │ ├── codenarc-rules-logging.md │ │ ├── codenarc-rules-naming.md │ │ ├── codenarc-rules-security.md │ │ ├── codenarc-rules-serialization.md │ │ ├── codenarc-rules-size.md │ │ ├── codenarc-rules-unnecessary.md │ │ ├── codenarc-rules-unused.md │ │ ├── codenarc-run-as-a-test.md │ │ ├── codenarc-sortable-html-report-writer.md │ │ ├── codenarc-text-report-writer.md │ │ ├── codenarc-xml-report-writer.md │ │ ├── css │ │ │ └── main.css │ │ ├── images │ │ │ ├── codenarc-logo.png │ │ │ └── forkme_right_red_aa0000.png │ │ └── index.md │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── integration-test │ │ ├── build.gradle │ │ └── src │ │ │ └── test │ │ │ └── groovy │ │ │ └── org │ │ │ └── codenarc │ │ │ └── gradle │ │ │ └── GradlePluginCompilationClasspathTest.groovy │ ├── settings.gradle │ ├── src │ │ ├── assembly │ │ │ └── assembly.xml │ │ ├── main │ │ │ ├── groovy │ │ │ │ └── org │ │ │ │ │ └── codenarc │ │ │ │ │ ├── AnalysisContext.groovy │ │ │ │ │ ├── CodeNarc.groovy │ │ │ │ │ ├── CodeNarcRunner.groovy │ │ │ │ │ ├── analyzer │ │ │ │ │ ├── AbstractSourceAnalyzer.groovy │ │ │ │ │ ├── AnalyzerException.groovy │ │ │ │ │ ├── FilesystemSourceAnalyzer.groovy │ │ │ │ │ ├── SourceAnalyzer.groovy │ │ │ │ │ ├── StringSourceAnalyzer.groovy │ │ │ │ │ └── SuppressionAnalyzer.java │ │ │ │ │ ├── ant │ │ │ │ │ ├── CodeNarcTask.groovy │ │ │ │ │ ├── Report.groovy │ │ │ │ │ └── ReportOption.groovy │ │ │ │ │ ├── plugin │ │ │ │ │ ├── AbstractCodeNarcPlugin.groovy │ │ │ │ │ ├── CodeNarcPlugin.groovy │ │ │ │ │ ├── FileViolations.groovy │ │ │ │ │ ├── baseline │ │ │ │ │ │ └── BaselineResultsPlugin.groovy │ │ │ │ │ └── disablerules │ │ │ │ │ │ ├── DisableRulesInCommentsPlugin.groovy │ │ │ │ │ │ └── LookupTable.groovy │ │ │ │ │ ├── report │ │ │ │ │ ├── AbstractHtmlReportWriter.groovy │ │ │ │ │ ├── AbstractReportWriter.groovy │ │ │ │ │ ├── BaselineViolation.groovy │ │ │ │ │ ├── BaselineXmlReportParser.groovy │ │ │ │ │ ├── BaselineXmlReportWriter.groovy │ │ │ │ │ ├── CompactTextReportWriter.groovy │ │ │ │ │ ├── HtmlReportWriter.groovy │ │ │ │ │ ├── IdeTextReportWriter.groovy │ │ │ │ │ ├── InlineXmlReportWriter.groovy │ │ │ │ │ ├── JsonReportWriter.groovy │ │ │ │ │ ├── ReportWriter.groovy │ │ │ │ │ ├── ReportWriterFactory.groovy │ │ │ │ │ ├── SortableHtmlReportWriter.groovy │ │ │ │ │ ├── TextReportWriter.groovy │ │ │ │ │ ├── XmlReportUtil.groovy │ │ │ │ │ └── XmlReportWriter.groovy │ │ │ │ │ ├── results │ │ │ │ │ ├── DirectoryResults.groovy │ │ │ │ │ ├── FileResults.groovy │ │ │ │ │ ├── Results.groovy │ │ │ │ │ └── VirtualResults.groovy │ │ │ │ │ ├── rule │ │ │ │ │ ├── AbstractConstructorCallAstVisitor.groovy │ │ │ │ │ ├── AbstractRuleTestCase.groovy │ │ │ │ │ ├── AstVisitor.groovy │ │ │ │ │ ├── ClassReferenceAstVisitor.groovy │ │ │ │ │ ├── ConstructorsSkippingFieldReferenceAstVisitor.groovy │ │ │ │ │ ├── FieldReferenceAstVisitor.groovy │ │ │ │ │ ├── InlineViolationsParser.groovy │ │ │ │ │ ├── NullReturnTracker.groovy │ │ │ │ │ ├── StubRule.groovy │ │ │ │ │ ├── Violation.groovy │ │ │ │ │ ├── basic │ │ │ │ │ │ ├── AbstractFinallyAstVisitor.groovy │ │ │ │ │ │ ├── AssertWithinFinallyBlockRule.groovy │ │ │ │ │ │ ├── AssignmentInConditionalRule.groovy │ │ │ │ │ │ ├── BigDecimalInstantiationRule.groovy │ │ │ │ │ │ ├── BitwiseOperatorInConditionalRule.groovy │ │ │ │ │ │ ├── BooleanGetBooleanRule.groovy │ │ │ │ │ │ ├── BrokenNullCheckRule.groovy │ │ │ │ │ │ ├── BrokenOddnessCheckRule.groovy │ │ │ │ │ │ ├── ClassForNameRule.groovy │ │ │ │ │ │ ├── ComparisonOfTwoConstantsRule.groovy │ │ │ │ │ │ ├── ComparisonWithSelfRule.groovy │ │ │ │ │ │ ├── ConstantAssertExpressionRule.groovy │ │ │ │ │ │ ├── ConstantIfExpressionRule.groovy │ │ │ │ │ │ ├── ConstantTernaryExpressionRule.groovy │ │ │ │ │ │ ├── DeadCodeRule.groovy │ │ │ │ │ │ ├── DoubleNegativeRule.groovy │ │ │ │ │ │ ├── DuplicateCaseStatementRule.groovy │ │ │ │ │ │ ├── DuplicateMapKeyRule.groovy │ │ │ │ │ │ ├── DuplicateSetValueRule.groovy │ │ │ │ │ │ ├── EmptyCatchBlockRule.groovy │ │ │ │ │ │ ├── EmptyClassRule.groovy │ │ │ │ │ │ ├── EmptyElseBlockRule.groovy │ │ │ │ │ │ ├── EmptyFinallyBlockRule.groovy │ │ │ │ │ │ ├── EmptyForStatementRule.groovy │ │ │ │ │ │ ├── EmptyIfStatementRule.groovy │ │ │ │ │ │ ├── EmptyInstanceInitializerRule.groovy │ │ │ │ │ │ ├── EmptyMethodRule.groovy │ │ │ │ │ │ ├── EmptyStaticInitializerRule.groovy │ │ │ │ │ │ ├── EmptySwitchStatementRule.groovy │ │ │ │ │ │ ├── EmptySynchronizedStatementRule.groovy │ │ │ │ │ │ ├── EmptyTryBlockRule.groovy │ │ │ │ │ │ ├── EmptyWhileStatementRule.groovy │ │ │ │ │ │ ├── EqualsAndHashCodeRule.groovy │ │ │ │ │ │ ├── EqualsOverloadedRule.groovy │ │ │ │ │ │ ├── ExplicitGarbageCollectionRule.groovy │ │ │ │ │ │ ├── ForLoopShouldBeWhileLoopRule.groovy │ │ │ │ │ │ ├── HardCodedWindowsFileSeparatorRule.groovy │ │ │ │ │ │ ├── HardCodedWindowsRootDirectoryRule.groovy │ │ │ │ │ │ ├── IntegerGetIntegerRule.groovy │ │ │ │ │ │ ├── MultipleUnaryOperatorsRule.groovy │ │ │ │ │ │ ├── ParameterAssignmentInFilterClosureRule.groovy │ │ │ │ │ │ ├── RandomDoubleCoercedToZeroRule.groovy │ │ │ │ │ │ ├── RemoveAllOnSelfRule.groovy │ │ │ │ │ │ ├── ReturnFromFinallyRule.groovy │ │ │ │ │ │ └── ThrowExceptionFromFinallyRule.groovy │ │ │ │ │ ├── braces │ │ │ │ │ │ ├── ElseBlockBracesRule.groovy │ │ │ │ │ │ ├── ForStatementBracesRule.groovy │ │ │ │ │ │ ├── IfStatementBracesRule.groovy │ │ │ │ │ │ └── WhileStatementBracesRule.groovy │ │ │ │ │ ├── comments │ │ │ │ │ │ ├── AbstractJavadocEmptyTagRule.groovy │ │ │ │ │ │ ├── AbstractJavadocMissingDescriptionRule.groovy │ │ │ │ │ │ ├── ClassJavadocRule.groovy │ │ │ │ │ │ ├── CommentsUtil.groovy │ │ │ │ │ │ ├── JavadocConsecutiveEmptyLinesRule.groovy │ │ │ │ │ │ ├── JavadocEmptyAuthorTagRule.groovy │ │ │ │ │ │ ├── JavadocEmptyExceptionTagRule.groovy │ │ │ │ │ │ ├── JavadocEmptyFirstLineRule.groovy │ │ │ │ │ │ ├── JavadocEmptyLastLineRule.groovy │ │ │ │ │ │ ├── JavadocEmptyParamTagRule.groovy │ │ │ │ │ │ ├── JavadocEmptyReturnTagRule.groovy │ │ │ │ │ │ ├── JavadocEmptySeeTagRule.groovy │ │ │ │ │ │ ├── JavadocEmptySinceTagRule.groovy │ │ │ │ │ │ ├── JavadocEmptyThrowsTagRule.groovy │ │ │ │ │ │ ├── JavadocEmptyVersionTagRule.groovy │ │ │ │ │ │ ├── JavadocMissingExceptionDescriptionRule.groovy │ │ │ │ │ │ ├── JavadocMissingParamDescriptionRule.groovy │ │ │ │ │ │ └── JavadocMissingThrowsDescriptionRule.groovy │ │ │ │ │ ├── concurrency │ │ │ │ │ │ ├── BusyWaitRule.groovy │ │ │ │ │ │ ├── DoubleCheckedLockingRule.groovy │ │ │ │ │ │ ├── InconsistentPropertyLockingRule.groovy │ │ │ │ │ │ ├── InconsistentPropertySynchronizationRule.groovy │ │ │ │ │ │ ├── NestedSynchronizationRule.groovy │ │ │ │ │ │ ├── StaticCalendarFieldRule.groovy │ │ │ │ │ │ ├── StaticConnectionRule.groovy │ │ │ │ │ │ ├── StaticDateFormatFieldRule.groovy │ │ │ │ │ │ ├── StaticMatcherFieldRule.groovy │ │ │ │ │ │ ├── StaticSimpleDateFormatFieldRule.groovy │ │ │ │ │ │ ├── SynchronizedMethodRule.groovy │ │ │ │ │ │ ├── SynchronizedOnBoxedPrimitiveRule.groovy │ │ │ │ │ │ ├── SynchronizedOnGetClassRule.groovy │ │ │ │ │ │ ├── SynchronizedOnReentrantLockRule.groovy │ │ │ │ │ │ ├── SynchronizedOnStringRule.groovy │ │ │ │ │ │ ├── SynchronizedOnThisRule.groovy │ │ │ │ │ │ ├── SynchronizedReadObjectMethodRule.groovy │ │ │ │ │ │ ├── SystemRunFinalizersOnExitRule.groovy │ │ │ │ │ │ ├── ThisReferenceEscapesConstructorRule.groovy │ │ │ │ │ │ ├── ThreadGroupRule.groovy │ │ │ │ │ │ ├── ThreadLocalNotStaticFinalRule.groovy │ │ │ │ │ │ ├── ThreadYieldRule.groovy │ │ │ │ │ │ ├── UseOfNotifyMethodRule.groovy │ │ │ │ │ │ ├── VolatileArrayFieldRule.groovy │ │ │ │ │ │ ├── VolatileLongOrDoubleFieldRule.groovy │ │ │ │ │ │ └── WaitOutsideOfWhileLoopRule.groovy │ │ │ │ │ ├── convention │ │ │ │ │ │ ├── CompileStaticRule.groovy │ │ │ │ │ │ ├── ConfusingTernaryRule.groovy │ │ │ │ │ │ ├── CouldBeElvisRule.groovy │ │ │ │ │ │ ├── CouldBeSwitchStatementRule.groovy │ │ │ │ │ │ ├── FieldTypeRequiredRule.groovy │ │ │ │ │ │ ├── HashtableIsObsoleteRule.groovy │ │ │ │ │ │ ├── IfStatementCouldBeTernaryRule.groovy │ │ │ │ │ │ ├── ImplicitClosureParameterRule.groovy │ │ │ │ │ │ ├── ImplicitReturnStatementRule.groovy │ │ │ │ │ │ ├── InvertedConditionRule.groovy │ │ │ │ │ │ ├── InvertedIfElseRule.groovy │ │ │ │ │ │ ├── LongLiteralWithLowerCaseLRule.groovy │ │ │ │ │ │ ├── MethodParameterTypeRequired.groovy │ │ │ │ │ │ ├── MethodReturnTypeRequiredRule.groovy │ │ │ │ │ │ ├── NoDefRule.groovy │ │ │ │ │ │ ├── NoDoubleRule.groovy │ │ │ │ │ │ ├── NoFloatRule.groovy │ │ │ │ │ │ ├── NoJavaUtilDateRule.groovy │ │ │ │ │ │ ├── NoTabCharacterRule.groovy │ │ │ │ │ │ ├── ParameterReassignmentRule.groovy │ │ │ │ │ │ ├── PublicMethodsBeforeNonPublicMethodsRule.groovy │ │ │ │ │ │ ├── StaticFieldsBeforeInstanceFieldsRule.groovy │ │ │ │ │ │ ├── StaticMethodsBeforeInstanceMethodsRule.groovy │ │ │ │ │ │ ├── TernaryCouldBeElvisRule.groovy │ │ │ │ │ │ ├── TrailingCommaRule.groovy │ │ │ │ │ │ ├── VariableTypeRequiredRule.groovy │ │ │ │ │ │ └── VectorIsObsoleteRule.groovy │ │ │ │ │ ├── design │ │ │ │ │ │ ├── AbstractClassWithPublicConstructorRule.groovy │ │ │ │ │ │ ├── AbstractClassWithoutAbstractMethodRule.groovy │ │ │ │ │ │ ├── AssignmentToStaticFieldFromInstanceMethodRule.groovy │ │ │ │ │ │ ├── BooleanMethodReturnsNullRule.groovy │ │ │ │ │ │ ├── BuilderMethodWithSideEffectsRule.groovy │ │ │ │ │ │ ├── CloneWithoutCloneableRule.groovy │ │ │ │ │ │ ├── CloneableWithoutCloneRule.groovy │ │ │ │ │ │ ├── CloseWithoutCloseableRule.groovy │ │ │ │ │ │ ├── CompareToWithoutComparableRule.groovy │ │ │ │ │ │ ├── ConstantsOnlyInterfaceRule.groovy │ │ │ │ │ │ ├── EmptyMethodInAbstractClassRule.groovy │ │ │ │ │ │ ├── FinalClassWithProtectedMemberRule.groovy │ │ │ │ │ │ ├── ImplementationAsTypeRule.groovy │ │ │ │ │ │ ├── InstanceofRule.groovy │ │ │ │ │ │ ├── LocaleSetDefaultRule.groovy │ │ │ │ │ │ ├── NestedForLoopRule.groovy │ │ │ │ │ │ ├── OptionalCollectionReturnTypeRule.groovy │ │ │ │ │ │ ├── OptionalFieldRule.groovy │ │ │ │ │ │ ├── OptionalMethodParameterRule.groovy │ │ │ │ │ │ ├── PrivateFieldCouldBeFinalRule.groovy │ │ │ │ │ │ ├── PublicInstanceFieldRule.groovy │ │ │ │ │ │ ├── ReturnsNullInsteadOfEmptyArrayRule.groovy │ │ │ │ │ │ ├── ReturnsNullInsteadOfEmptyCollectionRule.groovy │ │ │ │ │ │ ├── SimpleDateFormatMissingLocaleRule.groovy │ │ │ │ │ │ ├── StatelessSingletonRule.groovy │ │ │ │ │ │ └── ToStringReturnsNullRule.groovy │ │ │ │ │ ├── dry │ │ │ │ │ │ ├── DryUtil.groovy │ │ │ │ │ │ ├── DuplicateListLiteral.groovy │ │ │ │ │ │ ├── DuplicateLiteralAstVisitor.groovy │ │ │ │ │ │ ├── DuplicateMapLiteral.groovy │ │ │ │ │ │ ├── DuplicateNumberLiteralRule.groovy │ │ │ │ │ │ └── DuplicateStringLiteralRule.groovy │ │ │ │ │ ├── ecocode │ │ │ │ │ │ ├── DisableObfuscationRule.groovy │ │ │ │ │ │ ├── FatAppRule.groovy │ │ │ │ │ │ └── SupportedVersionRangeRule.groovy │ │ │ │ │ ├── enhanced │ │ │ │ │ │ └── MissingOverrideAnnotationRule.groovy │ │ │ │ │ ├── exceptions │ │ │ │ │ │ ├── CatchArrayIndexOutOfBoundsExceptionRule.groovy │ │ │ │ │ │ ├── CatchErrorRule.groovy │ │ │ │ │ │ ├── CatchExceptionRule.groovy │ │ │ │ │ │ ├── CatchIllegalMonitorStateExceptionRule.groovy │ │ │ │ │ │ ├── CatchIndexOutOfBoundsExceptionRule.groovy │ │ │ │ │ │ ├── CatchNullPointerExceptionRule.groovy │ │ │ │ │ │ ├── CatchRuntimeExceptionRule.groovy │ │ │ │ │ │ ├── CatchThrowableRule.groovy │ │ │ │ │ │ ├── CommonCatchAstVisitor.groovy │ │ │ │ │ │ ├── CommonThrowAstVisitor.groovy │ │ │ │ │ │ ├── ConfusingClassNamedExceptionRule.groovy │ │ │ │ │ │ ├── ExceptionExtendsErrorRule.groovy │ │ │ │ │ │ ├── ExceptionExtendsThrowableRule.groovy │ │ │ │ │ │ ├── ExceptionNotThrownRule.groovy │ │ │ │ │ │ ├── MissingNewInThrowStatementRule.groovy │ │ │ │ │ │ ├── ReturnNullFromCatchBlockRule.groovy │ │ │ │ │ │ ├── SwallowThreadDeathRule.groovy │ │ │ │ │ │ ├── ThrowErrorRule.groovy │ │ │ │ │ │ ├── ThrowExceptionRule.groovy │ │ │ │ │ │ ├── ThrowNullPointerExceptionRule.groovy │ │ │ │ │ │ ├── ThrowRuntimeExceptionRule.groovy │ │ │ │ │ │ └── ThrowThrowableRule.groovy │ │ │ │ │ ├── formatting │ │ │ │ │ │ ├── AbstractSingleSpaceAfterKeywordAstVisitor.groovy │ │ │ │ │ │ ├── AbstractSpaceAroundBraceAstVisitor.groovy │ │ │ │ │ │ ├── BlankLineBeforePackageRule.groovy │ │ │ │ │ │ ├── BlockEndsWithBlankLineRule.groovy │ │ │ │ │ │ ├── BlockStartsWithBlankLineRule.groovy │ │ │ │ │ │ ├── BracesForClassRule.groovy │ │ │ │ │ │ ├── BracesForForLoopRule.groovy │ │ │ │ │ │ ├── BracesForIfElseRule.groovy │ │ │ │ │ │ ├── BracesForMethodRule.groovy │ │ │ │ │ │ ├── BracesForTryCatchFinallyRule.groovy │ │ │ │ │ │ ├── ClassEndsWithBlankLineRule.groovy │ │ │ │ │ │ ├── ClassStartsWithBlankLineRule.groovy │ │ │ │ │ │ ├── ClosureStatementOnOpeningLineOfMultipleLineClosureRule.groovy │ │ │ │ │ │ ├── ConsecutiveBlankLinesRule.groovy │ │ │ │ │ │ ├── FileEndsWithoutNewlineRule.groovy │ │ │ │ │ │ ├── IndentationRule.groovy │ │ │ │ │ │ ├── LineLengthRule.groovy │ │ │ │ │ │ ├── MissingBlankLineAfterImportsRule.groovy │ │ │ │ │ │ ├── MissingBlankLineAfterPackageRule.groovy │ │ │ │ │ │ ├── MissingBlankLineBeforeAnnotatedFieldRule.groovy │ │ │ │ │ │ ├── SpaceAfterCatchRule.groovy │ │ │ │ │ │ ├── SpaceAfterClosingBraceRule.groovy │ │ │ │ │ │ ├── SpaceAfterCommaRule.groovy │ │ │ │ │ │ ├── SpaceAfterForRule.groovy │ │ │ │ │ │ ├── SpaceAfterIfRule.groovy │ │ │ │ │ │ ├── SpaceAfterMethodCallNameRule.groovy │ │ │ │ │ │ ├── SpaceAfterMethodDeclarationNameRule.groovy │ │ │ │ │ │ ├── SpaceAfterNotOperatorRule.groovy │ │ │ │ │ │ ├── SpaceAfterOpeningBraceRule.groovy │ │ │ │ │ │ ├── SpaceAfterSemicolonRule.groovy │ │ │ │ │ │ ├── SpaceAfterSwitchRule.groovy │ │ │ │ │ │ ├── SpaceAfterWhileRule.groovy │ │ │ │ │ │ ├── SpaceAroundClosureArrowRule.groovy │ │ │ │ │ │ ├── SpaceAroundMapEntryColonRule.groovy │ │ │ │ │ │ ├── SpaceAroundOperatorRule.groovy │ │ │ │ │ │ ├── SpaceBeforeClosingBraceRule.groovy │ │ │ │ │ │ ├── SpaceBeforeOpeningBraceRule.groovy │ │ │ │ │ │ ├── SpaceInsideParenthesesRule.groovy │ │ │ │ │ │ └── TrailingWhitespaceRule.groovy │ │ │ │ │ ├── generic │ │ │ │ │ │ ├── IllegalClassMemberRule.groovy │ │ │ │ │ │ ├── IllegalClassReferenceRule.groovy │ │ │ │ │ │ ├── IllegalPackageReferenceRule.groovy │ │ │ │ │ │ ├── IllegalRegexRule.groovy │ │ │ │ │ │ ├── IllegalStringRule.groovy │ │ │ │ │ │ ├── IllegalSubclassRule.groovy │ │ │ │ │ │ ├── RequiredRegexRule.groovy │ │ │ │ │ │ ├── RequiredStringRule.groovy │ │ │ │ │ │ └── StatelessClassRule.groovy │ │ │ │ │ ├── grails │ │ │ │ │ │ ├── GrailsDomainGormMethodsRule.groovy │ │ │ │ │ │ ├── GrailsDomainHasEqualsRule.groovy │ │ │ │ │ │ ├── GrailsDomainHasToStringRule.groovy │ │ │ │ │ │ ├── GrailsDomainReservedSqlKeywordNameRule.groovy │ │ │ │ │ │ ├── GrailsDomainStringPropertyMaxSizeRule.groovy │ │ │ │ │ │ ├── GrailsDomainWithServiceReferenceRule.groovy │ │ │ │ │ │ ├── GrailsDuplicateConstraintRule.groovy │ │ │ │ │ │ ├── GrailsDuplicateMappingRule.groovy │ │ │ │ │ │ ├── GrailsMassAssignmentRule.groovy │ │ │ │ │ │ ├── GrailsPublicControllerMethodRule.groovy │ │ │ │ │ │ ├── GrailsServletContextReferenceRule.groovy │ │ │ │ │ │ ├── GrailsStatelessServiceRule.groovy │ │ │ │ │ │ └── GrailsUtil.groovy │ │ │ │ │ ├── groovyism │ │ │ │ │ │ ├── AssignCollectionSortRule.groovy │ │ │ │ │ │ ├── AssignCollectionUniqueRule.groovy │ │ │ │ │ │ ├── ClosureAsLastMethodParameterRule.groovy │ │ │ │ │ │ ├── CollectAllIsDeprecatedRule.groovy │ │ │ │ │ │ ├── ConfusingMultipleReturnsRule.groovy │ │ │ │ │ │ ├── ExplicitArrayListInstantiationRule.groovy │ │ │ │ │ │ ├── ExplicitCallToAndMethodRule.groovy │ │ │ │ │ │ ├── ExplicitCallToCompareToMethodRule.groovy │ │ │ │ │ │ ├── ExplicitCallToDivMethodRule.groovy │ │ │ │ │ │ ├── ExplicitCallToEqualsMethodRule.groovy │ │ │ │ │ │ ├── ExplicitCallToGetAtMethodRule.groovy │ │ │ │ │ │ ├── ExplicitCallToLeftShiftMethodRule.groovy │ │ │ │ │ │ ├── ExplicitCallToMethodAstVisitor.groovy │ │ │ │ │ │ ├── ExplicitCallToMinusMethodRule.groovy │ │ │ │ │ │ ├── ExplicitCallToModMethodRule.groovy │ │ │ │ │ │ ├── ExplicitCallToMultiplyMethodRule.groovy │ │ │ │ │ │ ├── ExplicitCallToOrMethodRule.groovy │ │ │ │ │ │ ├── ExplicitCallToPlusMethodRule.groovy │ │ │ │ │ │ ├── ExplicitCallToPowerMethodRule.groovy │ │ │ │ │ │ ├── ExplicitCallToPutAtMethodRule.groovy │ │ │ │ │ │ ├── ExplicitCallToRightShiftMethodRule.groovy │ │ │ │ │ │ ├── ExplicitCallToXorMethodRule.groovy │ │ │ │ │ │ ├── ExplicitHashMapInstantiationRule.groovy │ │ │ │ │ │ ├── ExplicitHashSetInstantiationRule.groovy │ │ │ │ │ │ ├── ExplicitLinkedHashMapInstantiationRule.groovy │ │ │ │ │ │ ├── ExplicitLinkedListInstantiationRule.groovy │ │ │ │ │ │ ├── ExplicitStackInstantiationRule.groovy │ │ │ │ │ │ ├── ExplicitTreeSetInstantiationRule.groovy │ │ │ │ │ │ ├── ExplicitTypeInstantiationAstVisitor.groovy │ │ │ │ │ │ ├── GStringAsMapKeyRule.groovy │ │ │ │ │ │ ├── GStringExpressionWithinStringRule.groovy │ │ │ │ │ │ ├── GetterMethodCouldBePropertyRule.groovy │ │ │ │ │ │ ├── GroovyLangImmutableRule.groovy │ │ │ │ │ │ ├── UseCollectManyRule.groovy │ │ │ │ │ │ └── UseCollectNestedRule.groovy │ │ │ │ │ ├── imports │ │ │ │ │ │ ├── AbstractImportRule.groovy │ │ │ │ │ │ ├── DuplicateImportRule.groovy │ │ │ │ │ │ ├── ImportFromSamePackageRule.groovy │ │ │ │ │ │ ├── ImportFromSunPackagesRule.groovy │ │ │ │ │ │ ├── MisorderedStaticImportsRule.groovy │ │ │ │ │ │ ├── NoWildcardImportsRule.groovy │ │ │ │ │ │ ├── UnnecessaryGroovyImportRule.groovy │ │ │ │ │ │ └── UnusedImportRule.groovy │ │ │ │ │ ├── jdbc │ │ │ │ │ │ ├── DirectConnectionManagementRule.groovy │ │ │ │ │ │ ├── JdbcConnectionReferenceRule.groovy │ │ │ │ │ │ ├── JdbcResultSetReferenceRule.groovy │ │ │ │ │ │ └── JdbcStatementReferenceRule.groovy │ │ │ │ │ ├── junit │ │ │ │ │ │ ├── ChainedTestRule.groovy │ │ │ │ │ │ ├── CoupledTestCaseRule.groovy │ │ │ │ │ │ ├── JUnitAssertAlwaysFailsRule.groovy │ │ │ │ │ │ ├── JUnitAssertAlwaysSucceedsRule.groovy │ │ │ │ │ │ ├── JUnitAssertEqualsConstantActualValueRule.groovy │ │ │ │ │ │ ├── JUnitFailWithoutMessageRule.groovy │ │ │ │ │ │ ├── JUnitLostTestRule.groovy │ │ │ │ │ │ ├── JUnitPublicFieldRule.groovy │ │ │ │ │ │ ├── JUnitPublicNonTestMethodRule.groovy │ │ │ │ │ │ ├── JUnitPublicPropertyRule.groovy │ │ │ │ │ │ ├── JUnitSetUpCallsSuperRule.groovy │ │ │ │ │ │ ├── JUnitStyleAssertionsRule.groovy │ │ │ │ │ │ ├── JUnitTearDownCallsSuperRule.groovy │ │ │ │ │ │ ├── JUnitTestMethodWithoutAssertRule.groovy │ │ │ │ │ │ ├── JUnitUnnecessarySetUpRule.groovy │ │ │ │ │ │ ├── JUnitUnnecessaryTearDownRule.groovy │ │ │ │ │ │ ├── JUnitUnnecessaryThrowsExceptionRule.groovy │ │ │ │ │ │ ├── JUnitUtil.groovy │ │ │ │ │ │ ├── SpockIgnoreRestUsedRule.groovy │ │ │ │ │ │ ├── UnnecessaryFailRule.groovy │ │ │ │ │ │ ├── UseAssertEqualsInsteadOfAssertTrueRule.groovy │ │ │ │ │ │ ├── UseAssertFalseInsteadOfNegationRule.groovy │ │ │ │ │ │ ├── UseAssertNullInsteadOfAssertEqualsRule.groovy │ │ │ │ │ │ ├── UseAssertSameInsteadOfAssertTrueRule.groovy │ │ │ │ │ │ ├── UseAssertTrueInsteadOfAssertEqualsRule.groovy │ │ │ │ │ │ └── UseAssertTrueInsteadOfNegationRule.groovy │ │ │ │ │ ├── logging │ │ │ │ │ │ ├── LogUtil.groovy │ │ │ │ │ │ ├── LoggerForDifferentClassRule.groovy │ │ │ │ │ │ ├── LoggerWithWrongModifiersRule.groovy │ │ │ │ │ │ ├── LoggingSwallowsStacktraceRule.groovy │ │ │ │ │ │ ├── MultipleLoggersRule.groovy │ │ │ │ │ │ ├── PrintStackTraceRule.groovy │ │ │ │ │ │ ├── PrintlnRule.groovy │ │ │ │ │ │ ├── SystemErrPrintRule.groovy │ │ │ │ │ │ └── SystemOutPrintRule.groovy │ │ │ │ │ ├── naming │ │ │ │ │ │ ├── AbstractClassNameRule.groovy │ │ │ │ │ │ ├── AbstractTypeNameAstVisitor.groovy │ │ │ │ │ │ ├── ClassNameRule.groovy │ │ │ │ │ │ ├── ClassNameSameAsFilenameRule.groovy │ │ │ │ │ │ ├── ClassNameSameAsSuperclassRule.groovy │ │ │ │ │ │ ├── ConfusingMethodNameRule.groovy │ │ │ │ │ │ ├── FactoryMethodNameRule.groovy │ │ │ │ │ │ ├── FieldNameRule.groovy │ │ │ │ │ │ ├── InterfaceNameRule.groovy │ │ │ │ │ │ ├── InterfaceNameSameAsSuperInterfaceRule.groovy │ │ │ │ │ │ ├── MethodNameRule.groovy │ │ │ │ │ │ ├── ObjectOverrideMisspelledMethodNameRule.groovy │ │ │ │ │ │ ├── PackageNameMatchesFilePathRule.groovy │ │ │ │ │ │ ├── PackageNameRule.groovy │ │ │ │ │ │ ├── ParameterNameRule.groovy │ │ │ │ │ │ ├── PropertyNameRule.groovy │ │ │ │ │ │ └── VariableNameRule.groovy │ │ │ │ │ ├── security │ │ │ │ │ │ ├── FileCreateTempFileRule.groovy │ │ │ │ │ │ ├── InsecureRandomRule.groovy │ │ │ │ │ │ ├── JavaIoPackageAccessRule.groovy │ │ │ │ │ │ ├── NonFinalPublicFieldRule.groovy │ │ │ │ │ │ ├── NonFinalSubclassOfSensitiveInterfaceRule.groovy │ │ │ │ │ │ ├── ObjectFinalizeRule.groovy │ │ │ │ │ │ ├── PublicFinalizeMethodRule.groovy │ │ │ │ │ │ ├── SystemExitRule.groovy │ │ │ │ │ │ ├── UnsafeArrayDeclarationRule.groovy │ │ │ │ │ │ └── UnsafeImplementationAsMapRule.groovy │ │ │ │ │ ├── serialization │ │ │ │ │ │ ├── EnumCustomSerializationIgnoredRule.groovy │ │ │ │ │ │ ├── SerialPersistentFieldsRule.groovy │ │ │ │ │ │ ├── SerialVersionUIDRule.groovy │ │ │ │ │ │ └── SerializableClassMustDefineSerialVersionUIDRule.groovy │ │ │ │ │ ├── size │ │ │ │ │ │ ├── AbcMetricRule.groovy │ │ │ │ │ │ ├── AbstractMethodMetricAstVisitor.groovy │ │ │ │ │ │ ├── ClassSizeRule.groovy │ │ │ │ │ │ ├── CrapMetricRule.groovy │ │ │ │ │ │ ├── CyclomaticComplexityRule.groovy │ │ │ │ │ │ ├── GMetricsSourceCodeAdapter.groovy │ │ │ │ │ │ ├── MethodCountRule.groovy │ │ │ │ │ │ ├── MethodSizeRule.groovy │ │ │ │ │ │ ├── NestedBlockDepthRule.groovy │ │ │ │ │ │ └── ParameterCountRule.groovy │ │ │ │ │ ├── unnecessary │ │ │ │ │ │ ├── AddEmptyStringRule.groovy │ │ │ │ │ │ ├── ConsecutiveLiteralAppendsRule.groovy │ │ │ │ │ │ ├── ConsecutiveStringConcatenationRule.groovy │ │ │ │ │ │ ├── UnnecessaryBigDecimalInstantiationRule.groovy │ │ │ │ │ │ ├── UnnecessaryBigIntegerInstantiationRule.groovy │ │ │ │ │ │ ├── UnnecessaryBooleanExpressionRule.groovy │ │ │ │ │ │ ├── UnnecessaryBooleanInstantiationRule.groovy │ │ │ │ │ │ ├── UnnecessaryCallForLastElementRule.groovy │ │ │ │ │ │ ├── UnnecessaryCallToSubstringRule.groovy │ │ │ │ │ │ ├── UnnecessaryCastRule.groovy │ │ │ │ │ │ ├── UnnecessaryCatchBlockRule.groovy │ │ │ │ │ │ ├── UnnecessaryCollectCallRule.groovy │ │ │ │ │ │ ├── UnnecessaryCollectionCallRule.groovy │ │ │ │ │ │ ├── UnnecessaryConstructorRule.groovy │ │ │ │ │ │ ├── UnnecessaryDefInFieldDeclarationRule.groovy │ │ │ │ │ │ ├── UnnecessaryDefInMethodDeclarationRule.groovy │ │ │ │ │ │ ├── UnnecessaryDefInVariableDeclarationRule.groovy │ │ │ │ │ │ ├── UnnecessaryDotClassRule.groovy │ │ │ │ │ │ ├── UnnecessaryDoubleInstantiationRule.groovy │ │ │ │ │ │ ├── UnnecessaryElseStatementRule.groovy │ │ │ │ │ │ ├── UnnecessaryFinalOnPrivateMethodRule.groovy │ │ │ │ │ │ ├── UnnecessaryFloatInstantiationRule.groovy │ │ │ │ │ │ ├── UnnecessaryGStringRule.groovy │ │ │ │ │ │ ├── UnnecessaryGetterRule.groovy │ │ │ │ │ │ ├── UnnecessaryIfStatementRule.groovy │ │ │ │ │ │ ├── UnnecessaryInstanceOfCheckRule.groovy │ │ │ │ │ │ ├── UnnecessaryInstantiationAstVisitor.groovy │ │ │ │ │ │ ├── UnnecessaryInstantiationToGetClassRule.groovy │ │ │ │ │ │ ├── UnnecessaryIntegerInstantiationRule.groovy │ │ │ │ │ │ ├── UnnecessaryLongInstantiationRule.groovy │ │ │ │ │ │ ├── UnnecessaryModOneRule.groovy │ │ │ │ │ │ ├── UnnecessaryNullCheckBeforeInstanceOfRule.groovy │ │ │ │ │ │ ├── UnnecessaryNullCheckRule.groovy │ │ │ │ │ │ ├── UnnecessaryObjectReferencesRule.groovy │ │ │ │ │ │ ├── UnnecessaryOverridingMethodRule.groovy │ │ │ │ │ │ ├── UnnecessaryPackageReferenceRule.groovy │ │ │ │ │ │ ├── UnnecessaryParenthesesForMethodCallWithClosureRule.groovy │ │ │ │ │ │ ├── UnnecessaryPublicModifierRule.groovy │ │ │ │ │ │ ├── UnnecessaryReturnKeywordRule.groovy │ │ │ │ │ │ ├── UnnecessarySafeNavigationOperatorRule.groovy │ │ │ │ │ │ ├── UnnecessarySelfAssignmentRule.groovy │ │ │ │ │ │ ├── UnnecessarySemicolonRule.groovy │ │ │ │ │ │ ├── UnnecessarySetterRule.groovy │ │ │ │ │ │ ├── UnnecessaryStringInstantiationRule.groovy │ │ │ │ │ │ ├── UnnecessarySubstringRule.groovy │ │ │ │ │ │ ├── UnnecessaryTernaryExpressionRule.groovy │ │ │ │ │ │ ├── UnnecessaryToStringRule.groovy │ │ │ │ │ │ └── UnnecessaryTransientModifierRule.groovy │ │ │ │ │ └── unused │ │ │ │ │ │ ├── AbstractLastStatementInBlockAstVisitor.groovy │ │ │ │ │ │ ├── ReferenceCollector.groovy │ │ │ │ │ │ ├── UnusedArrayRule.groovy │ │ │ │ │ │ ├── UnusedMethodParameterRule.groovy │ │ │ │ │ │ ├── UnusedObjectRule.groovy │ │ │ │ │ │ ├── UnusedPrivateFieldRule.groovy │ │ │ │ │ │ ├── UnusedPrivateMethodParameterRule.groovy │ │ │ │ │ │ ├── UnusedPrivateMethodRule.groovy │ │ │ │ │ │ └── UnusedVariableRule.groovy │ │ │ │ │ ├── ruleregistry │ │ │ │ │ ├── PropertiesFileRuleRegistry.groovy │ │ │ │ │ ├── RuleRegistry.groovy │ │ │ │ │ ├── RuleRegistryHolder.groovy │ │ │ │ │ └── RuleRegistryInitializer.groovy │ │ │ │ │ ├── ruleset │ │ │ │ │ ├── CompositeRuleSet.groovy │ │ │ │ │ ├── FilteredRuleSet.groovy │ │ │ │ │ ├── GroovyDslRuleSet.groovy │ │ │ │ │ ├── JsonFileRuleSet.groovy │ │ │ │ │ ├── JsonReaderRuleSet.groovy │ │ │ │ │ ├── ListRuleSet.groovy │ │ │ │ │ ├── MovedRules.groovy │ │ │ │ │ ├── PropertiesFileRuleSetConfigurer.groovy │ │ │ │ │ ├── RuleSet.groovy │ │ │ │ │ ├── RuleSetBuilder.groovy │ │ │ │ │ ├── RuleSetConfigurer.groovy │ │ │ │ │ ├── RuleSetUtil.groovy │ │ │ │ │ ├── RuleSets.groovy │ │ │ │ │ ├── XmlFileRuleSet.groovy │ │ │ │ │ └── XmlReaderRuleSet.groovy │ │ │ │ │ ├── source │ │ │ │ │ ├── AbstractSourceCode.groovy │ │ │ │ │ ├── CustomCompilerPhaseSourceDecorator.groovy │ │ │ │ │ ├── SourceCode.groovy │ │ │ │ │ ├── SourceCodeCriteria.groovy │ │ │ │ │ ├── SourceFile.groovy │ │ │ │ │ └── SourceString.groovy │ │ │ │ │ ├── test │ │ │ │ │ └── AbstractTestCase.groovy │ │ │ │ │ ├── tool │ │ │ │ │ ├── GenerateAll.groovy │ │ │ │ │ ├── GenerateCodeNarcRulesProperties.groovy │ │ │ │ │ ├── GenerateRuleIndexPages.groovy │ │ │ │ │ ├── GenerateRuleSetAllRules.groovy │ │ │ │ │ ├── GenerateRuleSetAllRulesByCategory.groovy │ │ │ │ │ └── GenerateUtil.groovy │ │ │ │ │ └── util │ │ │ │ │ ├── CodeNarcVersion.groovy │ │ │ │ │ ├── ConsecutiveUtils.groovy │ │ │ │ │ ├── GroovyVersion.groovy │ │ │ │ │ ├── ImportUtil.groovy │ │ │ │ │ ├── ModifiersUtil.groovy │ │ │ │ │ ├── MultilineCommentChecker.groovy │ │ │ │ │ ├── PathUtil.groovy │ │ │ │ │ ├── PropertyUtil.groovy │ │ │ │ │ ├── SourceCodeUtil.groovy │ │ │ │ │ ├── WildcardPattern.groovy │ │ │ │ │ └── io │ │ │ │ │ ├── ClassPathResource.groovy │ │ │ │ │ ├── DefaultResourceFactory.groovy │ │ │ │ │ ├── Resource.groovy │ │ │ │ │ ├── ResourceFactory.groovy │ │ │ │ │ └── UrlResource.groovy │ │ │ ├── java │ │ │ │ └── org │ │ │ │ │ ├── codehaus │ │ │ │ │ └── groovy │ │ │ │ │ │ └── transform │ │ │ │ │ │ └── powerassert │ │ │ │ │ │ ├── Value.java │ │ │ │ │ │ └── ValueRecorder.java │ │ │ │ │ └── codenarc │ │ │ │ │ ├── ant │ │ │ │ │ └── AntFileSetSourceAnalyzer.java │ │ │ │ │ ├── rule │ │ │ │ │ ├── AbstractAstVisitor.java │ │ │ │ │ ├── AbstractAstVisitorRule.java │ │ │ │ │ ├── AbstractEnhanceableAstVisitorRule.java │ │ │ │ │ ├── AbstractFieldVisitor.java │ │ │ │ │ ├── AbstractMethodCallExpressionVisitor.java │ │ │ │ │ ├── AbstractMethodVisitor.java │ │ │ │ │ ├── AbstractRule.java │ │ │ │ │ ├── AbstractSharedAstVisitorRule.java │ │ │ │ │ └── Rule.java │ │ │ │ │ ├── source │ │ │ │ │ └── ExpressionCollector.java │ │ │ │ │ └── util │ │ │ │ │ └── AstUtil.java │ │ │ └── resources │ │ │ │ ├── codenarc-base-messages.properties │ │ │ │ ├── codenarc-base-rules.properties │ │ │ │ ├── codenarc-htmlreport.css │ │ │ │ ├── codenarc-rule-extrainfo.properties │ │ │ │ ├── codenarc-sortablehtmlreport.css │ │ │ │ ├── codenarc-version.txt │ │ │ │ ├── js │ │ │ │ └── sort-table.js │ │ │ │ ├── ruleset-schema.xsd │ │ │ │ ├── rulesets │ │ │ │ ├── basic.xml │ │ │ │ ├── braces.xml │ │ │ │ ├── comments.xml │ │ │ │ ├── concurrency.xml │ │ │ │ ├── convention.xml │ │ │ │ ├── design.xml │ │ │ │ ├── dry.xml │ │ │ │ ├── ecocode.xml │ │ │ │ ├── enhanced.xml │ │ │ │ ├── exceptions.xml │ │ │ │ ├── formatting.xml │ │ │ │ ├── generic.xml │ │ │ │ ├── grails.xml │ │ │ │ ├── groovyism.xml │ │ │ │ ├── imports.xml │ │ │ │ ├── jdbc.xml │ │ │ │ ├── junit.xml │ │ │ │ ├── logging.xml │ │ │ │ ├── naming.xml │ │ │ │ ├── security.xml │ │ │ │ ├── serialization.xml │ │ │ │ ├── size.xml │ │ │ │ ├── unnecessary.xml │ │ │ │ └── unused.xml │ │ │ │ └── templates │ │ │ │ ├── StarterRuleSet-AllRules.groovy.template │ │ │ │ ├── StarterRuleSet-AllRulesByCategory.groovy.template │ │ │ │ ├── codenarc-rule-index-by-name.md.template │ │ │ │ ├── codenarc-rule-index.apt.template │ │ │ │ └── codenarc-rule-index.md.template │ │ └── test │ │ │ ├── groovy │ │ │ └── org │ │ │ │ └── codenarc │ │ │ │ ├── CodeNarcRunnerTest.groovy │ │ │ │ ├── CodeNarcTest.groovy │ │ │ │ ├── analyzer │ │ │ │ ├── AbstractSourceAnalyzerTest.groovy │ │ │ │ ├── FilesystemSourceAnalyzerTest.groovy │ │ │ │ ├── SourceStringAnalyzerTest.groovy │ │ │ │ ├── StringSourceAnalyzerTest.groovy │ │ │ │ └── SuppressionAnalyzerTest.groovy │ │ │ │ ├── ant │ │ │ │ ├── AntFileSetSourceAnalyzerTest.groovy │ │ │ │ ├── CodeNarcTaskAllRuleSetsTest.groovy │ │ │ │ ├── CodeNarcTaskClasspathTest.groovy │ │ │ │ ├── CodeNarcTaskTest.groovy │ │ │ │ ├── CodeNarcTask_CustomRuleSetTest.groovy │ │ │ │ ├── CodeNarc_AntBuilderTest.groovy │ │ │ │ ├── CodeNarc_CompileErrorsTest.groovy │ │ │ │ └── ReportTest.groovy │ │ │ │ ├── plugin │ │ │ │ ├── FileViolationsTest.groovy │ │ │ │ ├── TestPlugin1.groovy │ │ │ │ ├── TestPlugin2.groovy │ │ │ │ ├── baseline │ │ │ │ │ └── BaselineResultsPluginTest.groovy │ │ │ │ └── disablerules │ │ │ │ │ ├── DisableRulesInCommentsPluginTest.groovy │ │ │ │ │ ├── DisableRulesInComments_AntTest.groovy │ │ │ │ │ └── LookupTableTest.groovy │ │ │ │ ├── report │ │ │ │ ├── AbstractCompactTextReportWriterTestCase.groovy │ │ │ │ ├── AbstractHtmlReportWriterTest.groovy │ │ │ │ ├── AbstractHtmlReportWriterTestCase.groovy │ │ │ │ ├── AbstractJsonReportWriterTestCase.groovy │ │ │ │ ├── AbstractReportWriterTest.groovy │ │ │ │ ├── AbstractTextReportWriterTestCase.groovy │ │ │ │ ├── AbstractXmlReportWriterTestCase.groovy │ │ │ │ ├── BaselineXmlReportParserTest.groovy │ │ │ │ ├── BaselineXmlReportWriterTest.groovy │ │ │ │ ├── BaselineXmlReport_IntegrationTest.groovy │ │ │ │ ├── CompactTextReportWriterTest.groovy │ │ │ │ ├── HtmlReportWriterTest.groovy │ │ │ │ ├── IdeTextReportWriterTest.groovy │ │ │ │ ├── InlineXmlReportWriterTest.groovy │ │ │ │ ├── JsonReportWriterTest.groovy │ │ │ │ ├── ReportWriterFactoryTest.groovy │ │ │ │ ├── SortableHtmlReportWriterTest.groovy │ │ │ │ ├── TextReportWriterTest.groovy │ │ │ │ ├── XmlReportUtilTest.groovy │ │ │ │ └── XmlReportWriterTest.groovy │ │ │ │ ├── results │ │ │ │ ├── DirectoryResultsTest.groovy │ │ │ │ ├── FileResultsTest.groovy │ │ │ │ └── VirtualResultsTest.groovy │ │ │ │ ├── rule │ │ │ │ ├── AbstractAstVisitorRuleTest.groovy │ │ │ │ ├── AbstractAstVisitorTest.groovy │ │ │ │ ├── AbstractClassReferenceRuleTestCase.groovy │ │ │ │ ├── AbstractEnhanceableAstVisitorRuleTest.groovy │ │ │ │ ├── AbstractRuleTest.groovy │ │ │ │ ├── FakeCountRule.groovy │ │ │ │ ├── FakePathRule.groovy │ │ │ │ ├── InlineViolationsParserTest.groovy │ │ │ │ ├── MockRule.groovy │ │ │ │ ├── basic │ │ │ │ │ ├── AssertWithinFinallyBlockRuleTest.groovy │ │ │ │ │ ├── AssignmentInConditionalRuleTest.groovy │ │ │ │ │ ├── BigDecimalInstantiationRuleTest.groovy │ │ │ │ │ ├── BitwiseOperatorInConditionalRuleTest.groovy │ │ │ │ │ ├── BooleanGetBooleanRuleTest.groovy │ │ │ │ │ ├── BrokenNullCheckRuleTest.groovy │ │ │ │ │ ├── BrokenOddnessCheckRuleTest.groovy │ │ │ │ │ ├── ClassForNameRuleTest.groovy │ │ │ │ │ ├── ComparisonOfTwoConstantsRuleTest.groovy │ │ │ │ │ ├── ComparisonWithSelfRuleTest.groovy │ │ │ │ │ ├── ConstantAssertExpressionRuleTest.groovy │ │ │ │ │ ├── ConstantIfExpressionRuleTest.groovy │ │ │ │ │ ├── ConstantTernaryExpressionRuleTest.groovy │ │ │ │ │ ├── ConstantTernaryExpressionRule_ElvisTest.groovy │ │ │ │ │ ├── DeadCodeRuleTest.groovy │ │ │ │ │ ├── DoubleNegativeRuleTest.groovy │ │ │ │ │ ├── DuplicateCaseStatementRuleTest.groovy │ │ │ │ │ ├── DuplicateMapKeyRuleTest.groovy │ │ │ │ │ ├── DuplicateSetValueRuleTest.groovy │ │ │ │ │ ├── EmptyCatchBlockRuleTest.groovy │ │ │ │ │ ├── EmptyClassRuleTest.groovy │ │ │ │ │ ├── EmptyElseBlockRuleTest.groovy │ │ │ │ │ ├── EmptyFinallyBlockRuleTest.groovy │ │ │ │ │ ├── EmptyForStatementRuleTest.groovy │ │ │ │ │ ├── EmptyIfStatementRuleTest.groovy │ │ │ │ │ ├── EmptyInstanceInitializerRuleTest.groovy │ │ │ │ │ ├── EmptyMethodRuleTest.groovy │ │ │ │ │ ├── EmptyStaticInitializerRuleTest.groovy │ │ │ │ │ ├── EmptySwitchStatementRuleTest.groovy │ │ │ │ │ ├── EmptySynchronizedStatementRuleTest.groovy │ │ │ │ │ ├── EmptyTryBlockRuleTest.groovy │ │ │ │ │ ├── EmptyWhileStatementRuleTest.groovy │ │ │ │ │ ├── EqualsAndHashCodeRuleTest.groovy │ │ │ │ │ ├── EqualsOverloadedRuleTest.groovy │ │ │ │ │ ├── ExplicitGarbageCollectionRuleTest.groovy │ │ │ │ │ ├── ForLoopShouldBeWhileLoopRuleTest.groovy │ │ │ │ │ ├── HardCodedWindowsFileSeparatorRuleTest.groovy │ │ │ │ │ ├── HardCodedWindowsRootDirectoryRuleTest.groovy │ │ │ │ │ ├── IntegerGetIntegerRuleTest.groovy │ │ │ │ │ ├── MultipleUnaryOperatorsRuleTest.groovy │ │ │ │ │ ├── ParameterAssignmentInFilterClosureRuleTest.groovy │ │ │ │ │ ├── RandomDoubleCoercedToZeroRuleTest.groovy │ │ │ │ │ ├── RemoveAllOnSelfRuleTest.groovy │ │ │ │ │ ├── ReturnFromFinallyBlockRuleTest.groovy │ │ │ │ │ └── ThrowExceptionFromFinallyBlockRuleTest.groovy │ │ │ │ ├── braces │ │ │ │ │ ├── ElseBlockBracesRuleTest.groovy │ │ │ │ │ ├── ForStatementBracesRuleTest.groovy │ │ │ │ │ ├── IfStatementBracesRuleTest.groovy │ │ │ │ │ └── WhileStatementBracesRuleTest.groovy │ │ │ │ ├── comments │ │ │ │ │ ├── AbstractJavadocEmptyTagRuleTestCase.groovy │ │ │ │ │ ├── AbstractJavadocMissingDescriptionRuleTestCase.groovy │ │ │ │ │ ├── ClassJavadocRuleTest.groovy │ │ │ │ │ ├── JavadocConsecutiveEmptyLinesRuleTest.groovy │ │ │ │ │ ├── JavadocEmptyAuthorTagRuleTest.groovy │ │ │ │ │ ├── JavadocEmptyExceptionTagRuleTest.groovy │ │ │ │ │ ├── JavadocEmptyFirstLineRuleTest.groovy │ │ │ │ │ ├── JavadocEmptyLastLineRuleTest.groovy │ │ │ │ │ ├── JavadocEmptyParamTagRuleTest.groovy │ │ │ │ │ ├── JavadocEmptyReturnTagRuleTest.groovy │ │ │ │ │ ├── JavadocEmptySeeTagRuleTest.groovy │ │ │ │ │ ├── JavadocEmptySinceTagRuleTest.groovy │ │ │ │ │ ├── JavadocEmptyThrowsTagRuleTest.groovy │ │ │ │ │ ├── JavadocEmptyVersionTagRuleTest.groovy │ │ │ │ │ ├── JavadocMissingExceptionDescriptionRuleTest.groovy │ │ │ │ │ ├── JavadocMissingParamDescriptionRuleTest.groovy │ │ │ │ │ └── JavadocMissingThrowsDescriptionRuleTest.groovy │ │ │ │ ├── concurrency │ │ │ │ │ ├── BusyWaitRuleTest.groovy │ │ │ │ │ ├── DoubleCheckedLockingRuleTest.groovy │ │ │ │ │ ├── InconsistentPropertyLockingRuleTest.groovy │ │ │ │ │ ├── InconsistentPropertySynchronizationRuleTest.groovy │ │ │ │ │ ├── NestedSynchronizationRuleTest.groovy │ │ │ │ │ ├── StaticCalendarFieldRuleTest.groovy │ │ │ │ │ ├── StaticConnectionRuleTest.groovy │ │ │ │ │ ├── StaticDateFormatFieldRuleTest.groovy │ │ │ │ │ ├── StaticMatcherFieldRuleTest.groovy │ │ │ │ │ ├── StaticSimpleDateFormatFieldRuleTest.groovy │ │ │ │ │ ├── SynchronizedMethodRuleTest.groovy │ │ │ │ │ ├── SynchronizedOnBoxedPrimitiveRuleTest.groovy │ │ │ │ │ ├── SynchronizedOnGetClassRuleTest.groovy │ │ │ │ │ ├── SynchronizedOnReentrantLockRuleTest.groovy │ │ │ │ │ ├── SynchronizedOnStringRuleTest.groovy │ │ │ │ │ ├── SynchronizedOnThisRuleTest.groovy │ │ │ │ │ ├── SynchronizedReadObjectMethodRuleTest.groovy │ │ │ │ │ ├── SystemRunFinalizersOnExitRuleTest.groovy │ │ │ │ │ ├── ThisReferenceEscapesConstructorRuleTest.groovy │ │ │ │ │ ├── ThreadGroupRuleTest.groovy │ │ │ │ │ ├── ThreadLocalNotStaticFinalRuleTest.groovy │ │ │ │ │ ├── ThreadYieldRuleTest.groovy │ │ │ │ │ ├── UseOfNotifyMethodRuleTest.groovy │ │ │ │ │ ├── VolatileArrayFieldRuleTest.groovy │ │ │ │ │ ├── VolatileLongOrDoubleFieldRuleTest.groovy │ │ │ │ │ └── WaitOutsideOfWhileLoopRuleTest.groovy │ │ │ │ ├── convention │ │ │ │ │ ├── CompileStaticRuleTest.groovy │ │ │ │ │ ├── ConfusingTernaryRuleTest.groovy │ │ │ │ │ ├── CouldBeElvisRuleTest.groovy │ │ │ │ │ ├── CouldBeSwitchStatementRuleTest.groovy │ │ │ │ │ ├── FieldTypeRequiredRuleTest.groovy │ │ │ │ │ ├── HashtableIsObsoleteRule_HashtableTest.groovy │ │ │ │ │ ├── HashtableIsObsoleteRule_JavaUtilHashtableTest.groovy │ │ │ │ │ ├── IfStatementCouldBeTernaryRuleTest.groovy │ │ │ │ │ ├── ImplicitClosureParameterRuleTest.groovy │ │ │ │ │ ├── ImplicitReturnStatementRuleTest.groovy │ │ │ │ │ ├── InvertedConditionRuleTest.groovy │ │ │ │ │ ├── InvertedIfElseRuleTest.groovy │ │ │ │ │ ├── LongLiteralWithLowerCaseLRuleTest.groovy │ │ │ │ │ ├── MethodParameterTypeRequiredTest.groovy │ │ │ │ │ ├── MethodReturnTypeRequiredRuleTest.groovy │ │ │ │ │ ├── NoDefRuleTest.groovy │ │ │ │ │ ├── NoDoubleRuleTest.groovy │ │ │ │ │ ├── NoFloatRuleTest.groovy │ │ │ │ │ ├── NoJavaUtilDateRuleTest.groovy │ │ │ │ │ ├── NoTabCharacterRuleTest.groovy │ │ │ │ │ ├── ParameterReassignmentRuleTest.groovy │ │ │ │ │ ├── PublicMethodsBeforeNonPublicMethodsRuleTest.groovy │ │ │ │ │ ├── StaticFieldsBeforeInstanceFieldsRuleTest.groovy │ │ │ │ │ ├── StaticMethodsBeforeInstanceMethodsRuleTest.groovy │ │ │ │ │ ├── TernaryCouldBeElvisRuleTest.groovy │ │ │ │ │ ├── TrailingCommaRuleTest.groovy │ │ │ │ │ ├── VariableTypeRequiredRuleTest.groovy │ │ │ │ │ ├── VectorIsObsoleteRule_JavaUtilVectorTest.groovy │ │ │ │ │ └── VectorIsObsoleteRule_VectorTest.groovy │ │ │ │ ├── design │ │ │ │ │ ├── AbstractClassWithPublicConstructorRuleTest.groovy │ │ │ │ │ ├── AbstractClassWithoutAbstractMethodRuleTest.groovy │ │ │ │ │ ├── AssignmentToStaticFieldFromInstanceMethodRuleTest.groovy │ │ │ │ │ ├── BooleanMethodReturnsNullRuleTest.groovy │ │ │ │ │ ├── BuilderMethodWithSideEffectsRuleTest.groovy │ │ │ │ │ ├── CloneWithoutCloneableRuleTest.groovy │ │ │ │ │ ├── CloneableWithoutCloneRuleTest.groovy │ │ │ │ │ ├── CloseWithoutCloseableRuleTest.groovy │ │ │ │ │ ├── CompareToWithoutComparableRuleTest.groovy │ │ │ │ │ ├── ConstantsOnlyInterfaceRuleTest.groovy │ │ │ │ │ ├── EmptyMethodInAbstractClassRuleTest.groovy │ │ │ │ │ ├── FinalClassWithProtectedMemberRuleTest.groovy │ │ │ │ │ ├── ImplementationAsTypeRuleTest.groovy │ │ │ │ │ ├── InstanceofRuleTest.groovy │ │ │ │ │ ├── LocaleSetDefaultRuleTest.groovy │ │ │ │ │ ├── NestedForLoopRuleTest.groovy │ │ │ │ │ ├── OptionalCollectionReturnTypeRuleTest.groovy │ │ │ │ │ ├── OptionalFieldRuleTest.groovy │ │ │ │ │ ├── OptionalMethodParameterRuleTest.groovy │ │ │ │ │ ├── PrivateFieldCouldBeFinalRuleTest.groovy │ │ │ │ │ ├── PublicInstanceFieldRuleTest.groovy │ │ │ │ │ ├── ReturnsNullInsteadOfEmptyArrayRuleTest.groovy │ │ │ │ │ ├── ReturnsNullInsteadOfEmptyCollectionRuleTest.groovy │ │ │ │ │ ├── SimpleDateFormatMissingLocaleRuleTest.groovy │ │ │ │ │ ├── StatelessSingletonRuleTest.groovy │ │ │ │ │ └── ToStringReturnsNullRuleTest.groovy │ │ │ │ ├── dry │ │ │ │ │ ├── DuplicateListLiteralRuleTest.groovy │ │ │ │ │ ├── DuplicateMapLiteralRuleTest.groovy │ │ │ │ │ ├── DuplicateNumberLiteralRuleTest.groovy │ │ │ │ │ └── DuplicateStringLiteralRuleTest.groovy │ │ │ │ ├── ecocode │ │ │ │ │ ├── DisableObfuscationRuleTest.groovy │ │ │ │ │ ├── FatAppRuleTest.groovy │ │ │ │ │ └── SupportedVersionRangeRuleTest.groovy │ │ │ │ ├── enhanced │ │ │ │ │ └── MissingOverrideAnnotationRuleTest.groovy │ │ │ │ ├── exceptions │ │ │ │ │ ├── CatchArrayIndexOutOfBoundsExceptionRuleTest.groovy │ │ │ │ │ ├── CatchErrorRuleTest.groovy │ │ │ │ │ ├── CatchExceptionRuleTest.groovy │ │ │ │ │ ├── CatchIllegalMonitorStateExceptionRuleTest.groovy │ │ │ │ │ ├── CatchIndexOutOfBoundsExceptionRuleTest.groovy │ │ │ │ │ ├── CatchNullPointerExceptionRuleTest.groovy │ │ │ │ │ ├── CatchRuntimeExceptionRuleTest.groovy │ │ │ │ │ ├── CatchThrowableRuleTest.groovy │ │ │ │ │ ├── ConfusingClassNamedExceptionRuleTest.groovy │ │ │ │ │ ├── ExceptionExtendsErrorRuleTest.groovy │ │ │ │ │ ├── ExceptionExtendsThrowableRuleTest.groovy │ │ │ │ │ ├── ExceptionNotThrownRuleTest.groovy │ │ │ │ │ ├── MissingNewInThrowStatementRuleTest.groovy │ │ │ │ │ ├── ReturnNullFromCatchBlockRuleTest.groovy │ │ │ │ │ ├── SwallowThreadDeathRuleTest.groovy │ │ │ │ │ ├── ThrowErrorRuleTest.groovy │ │ │ │ │ ├── ThrowExceptionRuleTest.groovy │ │ │ │ │ ├── ThrowNullPointerExceptionRuleTest.groovy │ │ │ │ │ ├── ThrowRuntimeExceptionRuleTest.groovy │ │ │ │ │ └── ThrowThrowableRuleTest.groovy │ │ │ │ ├── formatting │ │ │ │ │ ├── BlankLineBeforePackageRuleTest.groovy │ │ │ │ │ ├── BlockEndsWithBlankLineRuleTest.groovy │ │ │ │ │ ├── BlockStartsWithBlankLineRuleTest.groovy │ │ │ │ │ ├── BracesForClassRuleTest.groovy │ │ │ │ │ ├── BracesForForLoopRuleTest.groovy │ │ │ │ │ ├── BracesForIfElseRuleTest.groovy │ │ │ │ │ ├── BracesForMethodRuleTest.groovy │ │ │ │ │ ├── BracesForTryCatchFinallyRuleTest.groovy │ │ │ │ │ ├── ClassEndsWithBlankLineRuleTest.groovy │ │ │ │ │ ├── ClassStartsWithBlankLineRuleTest.groovy │ │ │ │ │ ├── ClosureStatementOnOpeningLineOfMultipleLineClosureRuleTest.groovy │ │ │ │ │ ├── ConsecutiveBlankLinesRuleTest.groovy │ │ │ │ │ ├── FileEndsWithoutNewlineRuleTest.groovy │ │ │ │ │ ├── IndentationRuleTest.groovy │ │ │ │ │ ├── IndentationRule_MethodChainingTest.groovy │ │ │ │ │ ├── LineLengthRuleTest.groovy │ │ │ │ │ ├── MissingBlankLineAfterImportsRuleTest.groovy │ │ │ │ │ ├── MissingBlankLineAfterPackageRuleTest.groovy │ │ │ │ │ ├── MissingBlankLineBeforeAnnotatedFieldRuleTest.groovy │ │ │ │ │ ├── SpaceAfterCatchRuleTest.groovy │ │ │ │ │ ├── SpaceAfterClosingBraceRuleTest.groovy │ │ │ │ │ ├── SpaceAfterCommaRuleTest.groovy │ │ │ │ │ ├── SpaceAfterForRuleTest.groovy │ │ │ │ │ ├── SpaceAfterIfRuleTest.groovy │ │ │ │ │ ├── SpaceAfterMethodCallNameRuleTest.groovy │ │ │ │ │ ├── SpaceAfterMethodDeclarationNameRuleTest.groovy │ │ │ │ │ ├── SpaceAfterNotOperatorRuleTest.groovy │ │ │ │ │ ├── SpaceAfterOpeningBraceRuleTest.groovy │ │ │ │ │ ├── SpaceAfterSemicolonRuleTest.groovy │ │ │ │ │ ├── SpaceAfterSwitchRuleTest.groovy │ │ │ │ │ ├── SpaceAfterWhileRuleTest.groovy │ │ │ │ │ ├── SpaceAroundClosureArrowRuleTest.groovy │ │ │ │ │ ├── SpaceAroundMapEntryColonRuleTest.groovy │ │ │ │ │ ├── SpaceAroundOperatorRuleTest.groovy │ │ │ │ │ ├── SpaceBeforeClosingBraceRuleTest.groovy │ │ │ │ │ ├── SpaceBeforeOpeningBraceRuleTest.groovy │ │ │ │ │ ├── SpaceInsideParenthesesRuleTest.groovy │ │ │ │ │ └── TrailingWhitespaceRuleTest.groovy │ │ │ │ ├── generic │ │ │ │ │ ├── IllegalClassMemberRuleTest.groovy │ │ │ │ │ ├── IllegalClassReferenceRule_MultipleClassNamesTest.groovy │ │ │ │ │ ├── IllegalClassReferenceRule_SingleClassNameTest.groovy │ │ │ │ │ ├── IllegalClassReferenceRule_WildcardsClassNamesTest.groovy │ │ │ │ │ ├── IllegalPackageReferenceRuleTest.groovy │ │ │ │ │ ├── IllegalRegexRuleTest.groovy │ │ │ │ │ ├── IllegalStringRuleTest.groovy │ │ │ │ │ ├── IllegalSubclassRuleTest.groovy │ │ │ │ │ ├── RequiredRegexRuleTest.groovy │ │ │ │ │ ├── RequiredStringRuleTest.groovy │ │ │ │ │ └── StatelessClassRuleTest.groovy │ │ │ │ ├── grails │ │ │ │ │ ├── GrailsDomainGormMethodsRuleTest.groovy │ │ │ │ │ ├── GrailsDomainHasEqualsRuleTest.groovy │ │ │ │ │ ├── GrailsDomainHasToStringRuleTest.groovy │ │ │ │ │ ├── GrailsDomainReservedSqlKeywordNameRuleTest.groovy │ │ │ │ │ ├── GrailsDomainStringPropertyMaxSizeRuleTest.groovy │ │ │ │ │ ├── GrailsDomainWithServiceReferenceRuleTest.groovy │ │ │ │ │ ├── GrailsDuplicateConstraintRuleTest.groovy │ │ │ │ │ ├── GrailsDuplicateMappingRuleTest.groovy │ │ │ │ │ ├── GrailsMassAssignmentRuleTest.groovy │ │ │ │ │ ├── GrailsPublicControllerMethodRuleTest.groovy │ │ │ │ │ ├── GrailsServletContextReferenceRuleTest.groovy │ │ │ │ │ └── GrailsStatelessServiceRuleTest.groovy │ │ │ │ ├── groovyism │ │ │ │ │ ├── AssignCollectionSortRuleTest.groovy │ │ │ │ │ ├── AssignCollectionUniqueRuleTest.groovy │ │ │ │ │ ├── ClosureAsLastMethodParameterRuleTest.groovy │ │ │ │ │ ├── CollectAllIsDeprecatedRuleTest.groovy │ │ │ │ │ ├── ConfusingMultipleReturnsRuleTest.groovy │ │ │ │ │ ├── ExplicitArrayListInstantiationRuleTest.groovy │ │ │ │ │ ├── ExplicitCallToAndMethodRuleTest.groovy │ │ │ │ │ ├── ExplicitCallToCompareToMethodRuleTest.groovy │ │ │ │ │ ├── ExplicitCallToDivMethodRuleTest.groovy │ │ │ │ │ ├── ExplicitCallToEqualsMethodRuleTest.groovy │ │ │ │ │ ├── ExplicitCallToGetAtMethodRuleTest.groovy │ │ │ │ │ ├── ExplicitCallToLeftShiftMethodRuleTest.groovy │ │ │ │ │ ├── ExplicitCallToMinusMethodRuleTest.groovy │ │ │ │ │ ├── ExplicitCallToModMethodRuleTest.groovy │ │ │ │ │ ├── ExplicitCallToMultiplyMethodRuleTest.groovy │ │ │ │ │ ├── ExplicitCallToOrMethodRuleTest.groovy │ │ │ │ │ ├── ExplicitCallToPlusMethodRuleTest.groovy │ │ │ │ │ ├── ExplicitCallToPowerMethodRuleTest.groovy │ │ │ │ │ ├── ExplicitCallToPutAtMethodRuleTest.groovy │ │ │ │ │ ├── ExplicitCallToRightShiftMethodRuleTest.groovy │ │ │ │ │ ├── ExplicitCallToXorMethodRuleTest.groovy │ │ │ │ │ ├── ExplicitHashMapInstantiationRuleTest.groovy │ │ │ │ │ ├── ExplicitHashSetInstantiationRuleTest.groovy │ │ │ │ │ ├── ExplicitLinkedHashMapInstantiationRuleTest.groovy │ │ │ │ │ ├── ExplicitLinkedListInstantiationRuleTest.groovy │ │ │ │ │ ├── ExplicitStackInstantiationRuleTest.groovy │ │ │ │ │ ├── ExplicitTreeSetInstantiationRuleTest.groovy │ │ │ │ │ ├── GStringAsMapKeyRuleTest.groovy │ │ │ │ │ ├── GStringExpressionWithinStringRuleTest.groovy │ │ │ │ │ ├── GetterMethodCouldBePropertyRuleTest.groovy │ │ │ │ │ ├── GroovyLangImmutableRuleTest.groovy │ │ │ │ │ ├── UseCollectManyRuleTest.groovy │ │ │ │ │ └── UseCollectNestedRuleTest.groovy │ │ │ │ ├── imports │ │ │ │ │ ├── DuplicateImportRuleTest.groovy │ │ │ │ │ ├── ImportFromSamePackageRuleTest.groovy │ │ │ │ │ ├── ImportFromSunPackagesRuleTest.groovy │ │ │ │ │ ├── MisorderedStaticImportsRuleTest.groovy │ │ │ │ │ ├── NoWildcardImportsRuleTest.groovy │ │ │ │ │ ├── UnnecessaryGroovyImportRuleTest.groovy │ │ │ │ │ └── UnusedImportRuleTest.groovy │ │ │ │ ├── jdbc │ │ │ │ │ ├── DirectConnectionManagementRuleTest.groovy │ │ │ │ │ ├── JdbcConnectionReferenceRuleTest.groovy │ │ │ │ │ ├── JdbcResultSetReferenceRuleTest.groovy │ │ │ │ │ ├── JdbcStatementReferenceRule_CallableStatementTest.groovy │ │ │ │ │ ├── JdbcStatementReferenceRule_PreparedStatementTest.groovy │ │ │ │ │ └── JdbcStatementReferenceRule_StatementTest.groovy │ │ │ │ ├── junit │ │ │ │ │ ├── ChainedTestRuleTest.groovy │ │ │ │ │ ├── CoupledTestCaseRuleTest.groovy │ │ │ │ │ ├── JUnitAssertAlwaysFailsRuleTest.groovy │ │ │ │ │ ├── JUnitAssertAlwaysSucceedsRuleTest.groovy │ │ │ │ │ ├── JUnitAssertEqualsConstantActualValueRuleTest.groovy │ │ │ │ │ ├── JUnitFailWithoutMessageRuleTest.groovy │ │ │ │ │ ├── JUnitLostTestRuleTest.groovy │ │ │ │ │ ├── JUnitPublicFieldRuleTest.groovy │ │ │ │ │ ├── JUnitPublicNonTestMethodRuleTest.groovy │ │ │ │ │ ├── JUnitPublicPropertyRuleTest.groovy │ │ │ │ │ ├── JUnitSetUpCallsSuperRuleTest.groovy │ │ │ │ │ ├── JUnitStyleAssertionsRuleTest.groovy │ │ │ │ │ ├── JUnitTearDownCallsSuperRuleTest.groovy │ │ │ │ │ ├── JUnitTestMethodWithoutAssertRuleTest.groovy │ │ │ │ │ ├── JUnitUnnecessarySetUpRuleTest.groovy │ │ │ │ │ ├── JUnitUnnecessaryTearDownRuleTest.groovy │ │ │ │ │ ├── JUnitUnnecessaryThrowsExceptionRuleTest.groovy │ │ │ │ │ ├── SpockIgnoreRestUsedRuleTest.groovy │ │ │ │ │ ├── UnnecessaryFailRuleTest.groovy │ │ │ │ │ ├── UseAssertEqualsInsteadOfAssertTrueRuleTest.groovy │ │ │ │ │ ├── UseAssertFalseInsteadOfNegationRuleTest.groovy │ │ │ │ │ ├── UseAssertNullInsteadOfAssertEqualsRuleTest.groovy │ │ │ │ │ ├── UseAssertSameInsteadOfAssertTrueRuleTest.groovy │ │ │ │ │ ├── UseAssertTrueInsteadOfAssertEqualsRuleTest.groovy │ │ │ │ │ └── UseAssertTrueInsteadOfNegationRuleTest.groovy │ │ │ │ ├── logging │ │ │ │ │ ├── LoggerForDifferentClassRuleTest.groovy │ │ │ │ │ ├── LoggerWithWrongModifiersRuleTest.groovy │ │ │ │ │ ├── LoggingSwallowsStacktraceRuleTest.groovy │ │ │ │ │ ├── MultipleLoggersRuleTest.groovy │ │ │ │ │ ├── PrintStackTraceRuleTest.groovy │ │ │ │ │ ├── PrintlnRuleTest.groovy │ │ │ │ │ ├── SystemErrPrintRuleTest.groovy │ │ │ │ │ └── SystemOutPrintRuleTest.groovy │ │ │ │ ├── naming │ │ │ │ │ ├── AbstractClassNameRuleTest.groovy │ │ │ │ │ ├── ClassNameRuleTest.groovy │ │ │ │ │ ├── ClassNameSameAsFilenameRuleTest.groovy │ │ │ │ │ ├── ClassNameSameAsSuperclassRuleTest.groovy │ │ │ │ │ ├── ConfusingMethodNameRuleTest.groovy │ │ │ │ │ ├── FactoryMethodNameRuleTest.groovy │ │ │ │ │ ├── FieldNameRuleTest.groovy │ │ │ │ │ ├── InterfaceNameRuleTest.groovy │ │ │ │ │ ├── InterfaceNameSameAsSuperInterfaceRuleTest.groovy │ │ │ │ │ ├── MethodNameRuleTest.groovy │ │ │ │ │ ├── ObjectOverrideMisspelledMethodNameRuleTest.groovy │ │ │ │ │ ├── PackageNameMatchesFilePathRuleTest.groovy │ │ │ │ │ ├── PackageNameRuleTest.groovy │ │ │ │ │ ├── ParameterNameRuleTest.groovy │ │ │ │ │ ├── PropertyNameRuleTest.groovy │ │ │ │ │ └── VariableNameRuleTest.groovy │ │ │ │ ├── security │ │ │ │ │ ├── FileCreateTempFileRuleTest.groovy │ │ │ │ │ ├── InsecureRandomRuleTest.groovy │ │ │ │ │ ├── JavaIoPackageAccessRuleTest.groovy │ │ │ │ │ ├── NonFinalPublicFieldRuleTest.groovy │ │ │ │ │ ├── NonFinalSubclassOfSensitiveInterfaceRuleTest.groovy │ │ │ │ │ ├── ObjectFinalizeRuleTest.groovy │ │ │ │ │ ├── PublicFinalizeMethodRuleTest.groovy │ │ │ │ │ ├── SystemExitRuleTest.groovy │ │ │ │ │ ├── UnsafeArrayDeclarationRuleTest.groovy │ │ │ │ │ └── UnsafeImplementationAsMapRuleTest.groovy │ │ │ │ ├── serialization │ │ │ │ │ ├── EnumCustomSerializationIgnoredRuleTest.groovy │ │ │ │ │ ├── SerialPersistentFieldsRuleTest.groovy │ │ │ │ │ ├── SerialVersionUIDRuleTest.groovy │ │ │ │ │ └── SerializableClassMustDefineSerialVersionUIDRuleTest.groovy │ │ │ │ ├── size │ │ │ │ │ ├── AbcMetricRuleTest.groovy │ │ │ │ │ ├── ClassSizeRuleTest.groovy │ │ │ │ │ ├── CrapMetricRuleTest.groovy │ │ │ │ │ ├── CyclomaticComplexityRuleTest.groovy │ │ │ │ │ ├── GMetricsSourceCodeAdapterTest.groovy │ │ │ │ │ ├── MethodCountRuleTest.groovy │ │ │ │ │ ├── MethodSizeRuleTest.groovy │ │ │ │ │ ├── NestedBlockDepthRuleTest.groovy │ │ │ │ │ └── ParameterCountRuleTest.groovy │ │ │ │ ├── unnecessary │ │ │ │ │ ├── AddEmptyStringRuleTest.groovy │ │ │ │ │ ├── ConsecutiveLiteralAppendsRuleTest.groovy │ │ │ │ │ ├── ConsecutiveStringConcatenationRuleTest.groovy │ │ │ │ │ ├── UnnecessaryBigDecimalInstantiationRuleTest.groovy │ │ │ │ │ ├── UnnecessaryBigIntegerInstantiationRuleTest.groovy │ │ │ │ │ ├── UnnecessaryBooleanExpressionRuleTest.groovy │ │ │ │ │ ├── UnnecessaryBooleanInstantiationRuleTest.groovy │ │ │ │ │ ├── UnnecessaryCallForLastElementRuleTest.groovy │ │ │ │ │ ├── UnnecessaryCallToSubstringRuleTest.groovy │ │ │ │ │ ├── UnnecessaryCastRuleTest.groovy │ │ │ │ │ ├── UnnecessaryCatchBlockRuleTest.groovy │ │ │ │ │ ├── UnnecessaryCollectCallRuleTest.groovy │ │ │ │ │ ├── UnnecessaryCollectionCallRuleTest.groovy │ │ │ │ │ ├── UnnecessaryConstructorRuleTest.groovy │ │ │ │ │ ├── UnnecessaryDefInFieldDeclarationRuleTest.groovy │ │ │ │ │ ├── UnnecessaryDefInMethodDeclarationRuleTest.groovy │ │ │ │ │ ├── UnnecessaryDefInVariableDeclarationRuleTest.groovy │ │ │ │ │ ├── UnnecessaryDotClassRuleTest.groovy │ │ │ │ │ ├── UnnecessaryDoubleInstantiationRuleTest.groovy │ │ │ │ │ ├── UnnecessaryElseStatementRuleTest.groovy │ │ │ │ │ ├── UnnecessaryFinalOnPrivateMethodRuleTest.groovy │ │ │ │ │ ├── UnnecessaryFloatInstantiationRuleTest.groovy │ │ │ │ │ ├── UnnecessaryGStringRuleTest.groovy │ │ │ │ │ ├── UnnecessaryGetterRuleTest.groovy │ │ │ │ │ ├── UnnecessaryIfStatementRuleTest.groovy │ │ │ │ │ ├── UnnecessaryInstanceOfCheckRuleTest.groovy │ │ │ │ │ ├── UnnecessaryInstantiationToGetClassRuleTest.groovy │ │ │ │ │ ├── UnnecessaryIntegerInstantiationRuleTest.groovy │ │ │ │ │ ├── UnnecessaryLongInstantiationRuleTest.groovy │ │ │ │ │ ├── UnnecessaryModOneRuleTest.groovy │ │ │ │ │ ├── UnnecessaryNullCheckBeforeInstanceOfRuleTest.groovy │ │ │ │ │ ├── UnnecessaryNullCheckRuleTest.groovy │ │ │ │ │ ├── UnnecessaryObjectReferencesRuleTest.groovy │ │ │ │ │ ├── UnnecessaryOverridingMethodRuleTest.groovy │ │ │ │ │ ├── UnnecessaryPackageReferenceRuleTest.groovy │ │ │ │ │ ├── UnnecessaryParenthesesForMethodCallWithClosureRuleTest.groovy │ │ │ │ │ ├── UnnecessaryPublicModifierRuleTest.groovy │ │ │ │ │ ├── UnnecessaryReturnKeywordRuleTest.groovy │ │ │ │ │ ├── UnnecessarySafeNavigationOperatorRuleTest.groovy │ │ │ │ │ ├── UnnecessarySelfAssignmentRuleTest.groovy │ │ │ │ │ ├── UnnecessarySemicolonRuleTest.groovy │ │ │ │ │ ├── UnnecessarySetterRuleTest.groovy │ │ │ │ │ ├── UnnecessaryStringInstantiationRuleTest.groovy │ │ │ │ │ ├── UnnecessarySubstringRuleTest.groovy │ │ │ │ │ ├── UnnecessaryTernaryExpressionRuleTest.groovy │ │ │ │ │ ├── UnnecessaryToStringRuleTest.groovy │ │ │ │ │ └── UnnecessaryTransientModifierRuleTest.groovy │ │ │ │ └── unused │ │ │ │ │ ├── AbstractUnusedPrivateFieldRuleTest.groovy │ │ │ │ │ ├── ConstructorUsagesSkippingUnusedPrivateFieldRuleTest.groovy │ │ │ │ │ ├── UnusedArrayRuleTest.groovy │ │ │ │ │ ├── UnusedMethodParameterRuleTest.groovy │ │ │ │ │ ├── UnusedObjectRuleTest.groovy │ │ │ │ │ ├── UnusedPrivateFieldRuleTest.groovy │ │ │ │ │ ├── UnusedPrivateMethodParameterRuleTest.groovy │ │ │ │ │ ├── UnusedPrivateMethodRuleTest.groovy │ │ │ │ │ └── UnusedVariableRuleTest.groovy │ │ │ │ ├── ruleregistry │ │ │ │ ├── PropertiesFileRuleRegistryTest.groovy │ │ │ │ └── RuleRegistryInitializerTest.groovy │ │ │ │ ├── ruleset │ │ │ │ ├── CompositeRuleSetTest.groovy │ │ │ │ ├── FilteredRuleSetTest.groovy │ │ │ │ ├── GroovyDslRuleSetTest.groovy │ │ │ │ ├── JsonFileRuleSetTest.groovy │ │ │ │ ├── JsonReaderRuleSetTest.groovy │ │ │ │ ├── ListRuleSetTest.groovy │ │ │ │ ├── LoadAllPredefinedRuleSetsTest.groovy │ │ │ │ ├── MovedRulesTest.groovy │ │ │ │ ├── PropertiesFileRuleSetConfigurerTest.groovy │ │ │ │ ├── RuleSetBuilderTest.groovy │ │ │ │ ├── RuleSetUtilTest.groovy │ │ │ │ ├── XmlFileRuleSetTest.groovy │ │ │ │ ├── XmlReaderRuleSetSchemaValidationTest.groovy │ │ │ │ └── XmlReaderRuleSetTest.groovy │ │ │ │ ├── source │ │ │ │ ├── CustomCompilerPhaseSourceDecoratorTest.groovy │ │ │ │ ├── SourceCodeCriteriaTest.groovy │ │ │ │ ├── SourceFileTest.groovy │ │ │ │ └── SourceStringTest.groovy │ │ │ │ ├── test │ │ │ │ ├── RunCodeNarcAgainstProjectSourceCodeTest.groovy │ │ │ │ ├── SiteDocumentationTest.groovy │ │ │ │ └── TestUtil.groovy │ │ │ │ ├── tool │ │ │ │ ├── GenerateCodeNarcRulesPropertiesTest.groovy │ │ │ │ ├── GenerateRuleIndexPagesTest.groovy │ │ │ │ ├── GenerateRuleSetAllRulesByCategoryTest.groovy │ │ │ │ └── GenerateRuleSetAllRulesTest.groovy │ │ │ │ └── util │ │ │ │ ├── AstUtilTest.groovy │ │ │ │ ├── CodeNarcVersionTest.groovy │ │ │ │ ├── ImportUtilTest.groovy │ │ │ │ ├── ModifiersUtilTest.groovy │ │ │ │ ├── MultilineCommentCheckerTest.groovy │ │ │ │ ├── PathUtilTest.groovy │ │ │ │ ├── PropertyUtilTest.groovy │ │ │ │ ├── SourceCodeUtilTest.groovy │ │ │ │ ├── WildcardPatternTest.groovy │ │ │ │ └── io │ │ │ │ ├── ClassPathResourceTest.groovy │ │ │ │ ├── DefaultResourceFactoryTest.groovy │ │ │ │ ├── StringResource.groovy │ │ │ │ └── UrlResourceTest.groovy │ │ │ └── resources │ │ │ ├── RunCodeNarcAgainstProjectSourceCode.properties │ │ │ ├── RunCodeNarcAgainstProjectSourceCode.ruleset │ │ │ ├── SampleFile.groovy │ │ │ ├── SampleInvalidFile.txt │ │ │ ├── codenarc-messages.properties │ │ │ ├── codenarc.properties │ │ │ ├── coverage │ │ │ └── Cobertura-example.xml │ │ │ ├── disable-rules-in-comments │ │ │ ├── Sample.groovy │ │ │ └── disabling-rules.ruleset │ │ │ ├── override-codenarc.properties │ │ │ ├── resource │ │ │ └── SampleResource.txt │ │ │ ├── rule │ │ │ ├── BracesTestNewLine.txt │ │ │ ├── BracesTestSameLine.txt │ │ │ ├── DoNothingRule.txt │ │ │ ├── DoesNotCompileRule.txt │ │ │ └── NotARule.txt │ │ │ ├── rulesets │ │ │ ├── CustomRuleSet.groovy │ │ │ ├── GroovyRuleSet1.groovy │ │ │ ├── GroovyRuleSet1.txt │ │ │ ├── GroovyRuleSet2.txt │ │ │ ├── GroovyRuleSet_Bad.txt │ │ │ ├── JsonRuleSet1.json │ │ │ ├── NestedRuleSet1.xml │ │ │ ├── RuleSet1.xml │ │ │ ├── RuleSet2.xml │ │ │ ├── RuleSet3.xml │ │ │ ├── RuleSet4.xml │ │ │ └── WeirdCharsRuleSet-,#.txt │ │ │ ├── source │ │ │ ├── SomeOtherFile.txt │ │ │ ├── SourceFile1.groovy │ │ │ └── SourceFile2.groovy │ │ │ ├── sourcewithdirs │ │ │ ├── SourceFile1.groovy │ │ │ ├── subdir1 │ │ │ │ ├── Subdir1File1.groovy │ │ │ │ └── Subdir1File2.groovy │ │ │ └── subdir2 │ │ │ │ ├── Subdir2File1.groovy │ │ │ │ ├── subdir2a │ │ │ │ └── Subdir2aFile1.groovy │ │ │ │ └── subdir2b │ │ │ │ └── NotAGroovyFile.txt │ │ │ └── sourcewitherrors │ │ │ ├── SourceFile1.txt │ │ │ └── SourceFileWithCompileError.txt │ └── templates │ │ ├── Rule.groovy │ │ └── Test.groovy ├── README.md ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── sonar │ │ └── plugins │ │ └── groovy │ │ └── codenarc │ │ ├── ParseResult.java │ │ ├── Rule.java │ │ ├── RuleConverter.java │ │ ├── RuleParameter.java │ │ ├── RuleSet.java │ │ ├── parser │ │ ├── RuleParser.java │ │ ├── RuleParserResult.java │ │ └── markdown │ │ │ ├── MarkdownParser.java │ │ │ ├── RuleDescription.java │ │ │ ├── RuleSetVisitor.java │ │ │ └── RuleVisitor.java │ │ └── printer │ │ └── XMLPrinter.java │ └── test │ └── java │ └── org │ └── sonar │ └── plugins │ └── groovy │ └── codenarc │ └── RuleConverterTest.java ├── docker-compose.yml ├── ecolinter-plugin ├── pom.xml └── src │ ├── main │ ├── java │ │ └── fr │ │ │ └── cnumr │ │ │ └── ecolinter │ │ │ ├── MyEcoLintRulesPlugin.java │ │ │ ├── MyEslintRulesDefinition.java │ │ │ └── MyStylelintRulesDefinition.java │ └── resources │ │ └── fr │ │ └── cnumr │ │ └── l10n │ │ └── ecolint │ │ └── rules │ │ ├── eslint │ │ └── greenit.json │ │ └── stylelint │ │ └── greenit.json │ └── test │ └── java │ └── fr │ └── cnumr │ └── ecolinter │ ├── MyEcoLintRulesPluginTest.java │ ├── MyEslintRulesDefinitionTest.java │ └── MyStylelintRulesDefinitionTest.java ├── images ├── 5ekko.png ├── img.png ├── img_1.png ├── img_2.png ├── img_3.png ├── img_4.png ├── img_5.png └── img_6.png ├── java-plugin ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── fr │ │ │ └── cnumr │ │ │ └── java │ │ │ ├── MyJavaFileCheckRegistrar.java │ │ │ ├── MyJavaRulesDefinition.java │ │ │ ├── MyJavaRulesPlugin.java │ │ │ ├── RulesList.java │ │ │ ├── checks │ │ │ ├── ArrayCopyCheck.java │ │ │ ├── AvoidConcatenateStringsInLoop.java │ │ │ ├── AvoidFullSQLRequest.java │ │ │ ├── AvoidGettingSizeCollectionInLoop.java │ │ │ ├── AvoidMultipleIfElseStatement.java │ │ │ ├── AvoidRegexPatternNotStatic.java │ │ │ ├── AvoidSQLRequestInLoop.java │ │ │ ├── AvoidSetConstantInBatchUpdate.java │ │ │ ├── AvoidSpringRepositoryCallInLoopCheck.java │ │ │ ├── AvoidStatementForDMLQueries.java │ │ │ ├── AvoidUsageOfStaticCollections.java │ │ │ ├── AvoidUsingGlobalVariablesCheck.java │ │ │ ├── ConstOrLiteralDeclare.java │ │ │ ├── FreeResourcesOfAutoCloseableInterface.java │ │ │ ├── IncrementCheck.java │ │ │ ├── InitializeBufferWithAppropriateSize.java │ │ │ ├── NoFunctionCallWhenDeclaringForLoop.java │ │ │ ├── OptimizeReadFileExceptions.java │ │ │ ├── UnnecessarilyAssignValuesToVariables.java │ │ │ ├── UseCorrectForLoop.java │ │ │ └── package-info.java │ │ │ ├── package-info.java │ │ │ └── utils │ │ │ ├── PrinterVisitor.java │ │ │ ├── StringUtils.java │ │ │ └── package-info.java │ └── resources │ │ └── fr │ │ └── cnumr │ │ └── l10n │ │ └── java │ │ └── rules │ │ └── java │ │ ├── AMIES.html │ │ ├── AMIES.json │ │ ├── D4.html │ │ ├── D4.json │ │ ├── GRC1.html │ │ ├── GRC1.json │ │ ├── GRPS0027.html │ │ ├── GRPS0027.json │ │ ├── GRSP0028.html │ │ ├── GRSP0028.json │ │ ├── GRSP0032.html │ │ ├── GRSP0032.json │ │ ├── GSCIL.html │ │ ├── GSCIL.json │ │ ├── S53.html │ │ ├── S53.json │ │ ├── S63.html │ │ ├── S63.json │ │ ├── S67.html │ │ ├── S67.json │ │ ├── S69.html │ │ ├── S69.json │ │ ├── S72.html │ │ ├── S72.json │ │ ├── S74.html │ │ ├── S74.json │ │ ├── S75.html │ │ ├── S75.json │ │ ├── S76.html │ │ ├── S76.json │ │ ├── S77.html │ │ ├── S77.json │ │ ├── S78.html │ │ ├── S78.json │ │ ├── S79.html │ │ ├── S79.json │ │ ├── SDMLQ1.html │ │ └── SDMLQ1.json │ └── test │ ├── files │ ├── ArrayCopyCheck.java │ ├── AvoidConcatenateStringsInLoop.java │ ├── AvoidFullSQLRequestCheck.java │ ├── AvoidGettingSizeCollectionInLoopBad.java │ ├── AvoidGettingSizeCollectionInLoopGood.java │ ├── AvoidMultipleIfElseStatement.java │ ├── AvoidMultipleIfElseStatementNoIssue.java │ ├── AvoidRegexPatternNotStatic.java │ ├── AvoidSQLRequestInLoopCheck.java │ ├── AvoidSetConstantInBatchUpdateCheck.java │ ├── AvoidSpringRepositoryCallInLoopCheck.java │ ├── AvoidStatementForDMLQueries.java │ ├── AvoidUsageOfStaticCollections.java │ ├── AvoidUsingGlobalVariablesCheck.java │ ├── FreeResourcesOfAutoCloseableInterface.java │ ├── GoodUsageOfStaticCollections.java │ ├── GoodWayConcatenateStringsLoop.java │ ├── IncrementCheck.java │ ├── InitializeBufferWithAppropriateSize.java │ ├── NoFunctionCallWhenDeclaringForLoop.java │ ├── OptimizeReadFileExceptionCheck.java │ ├── UnnecessarilyAssignValuesToVariablesTestCheck.java │ ├── UseCorrectForLoopCheck.java │ ├── ValidRegexPattern.java │ ├── ValidRegexPattern2.java │ └── ValidRegexPattern3.java │ └── java │ └── fr │ └── cnumr │ └── java │ ├── MyJavaFileCheckRegistrarTest.java │ ├── MyJavaRulesDefinitionTest.java │ ├── MyJavaRulesPluginTest.java │ ├── checks │ ├── ArrayCopyCheckTest.java │ ├── AvoidConcatenateStringsInLoopTest.java │ ├── AvoidFullSQLRequestCheckTest.java │ ├── AvoidGettingSizeCollectionInLoopTest.java │ ├── AvoidMultipleIfElseStatementTest.java │ ├── AvoidRegexPatternNotStaticTest.java │ ├── AvoidSQLRequestInLoopCheckTest.java │ ├── AvoidSetConstantInBatchInsertTest.java │ ├── AvoidSpringRepositoryCallInLoopCheckTest.java │ ├── AvoidStatementForDMLQueriesTest.java │ ├── AvoidUsageOfStaticCollectionsTests.java │ ├── AvoidUsingGlobalVariablesCheckCheckTest.java │ ├── FreeResourcesOfAutoCloseableInterfaceTest.java │ ├── IncrementCheckTest.java │ ├── InitializeBufferWithAppropriateSizeTest.java │ ├── NoFunctionCallWhenDeclaringForLoopTest.java │ ├── OptimizeReadFileExceptionCheckTest.java │ ├── UnnecessarilyAssignValuesToVariablesTest.java │ └── UseCorrectLoopCheckTest.java │ └── utils │ ├── FilesUtils.java │ └── StringUtilsTest.java ├── php-plugin ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── fr │ │ │ └── cnumr │ │ │ └── php │ │ │ ├── MyPhpRules.java │ │ │ ├── PHPCustomRulesPlugin.java │ │ │ └── checks │ │ │ ├── AvoidDoubleQuoteCheck.java │ │ │ ├── AvoidFullSQLRequestCheck.java │ │ │ ├── AvoidSQLRequestInLoopCheck.java │ │ │ ├── AvoidTryCatchFinallyCheck_NOK_failsAllTryStatements.java │ │ │ ├── AvoidUsingGlobalVariablesCheck.java │ │ │ ├── IncrementCheck.java │ │ │ ├── NoFunctionCallWhenDeclaringForLoop.java │ │ │ └── UseOfMethodsForBasicOperations.java │ └── resources │ │ └── fr │ │ └── cnumr │ │ └── l10n │ │ └── php │ │ └── rules │ │ └── custom │ │ ├── D1.json │ │ ├── D2.html │ │ ├── D2.json │ │ ├── D4.html │ │ ├── D4.json │ │ ├── S34.html │ │ ├── S34.json │ │ ├── S66.html │ │ ├── S66.json │ │ ├── S67.html │ │ ├── S67.json │ │ ├── S69.html │ │ ├── S69.json │ │ ├── S72.html │ │ ├── S72.json │ │ ├── S74.html │ │ └── S74.json │ └── test │ ├── java │ └── fr │ │ └── cnumr │ │ └── php │ │ ├── MyPhpRulesTest.java │ │ └── checks │ │ ├── AvoidDoubleQuoteCheckTest.java │ │ ├── AvoidFullSQLRequestCheckTest.java │ │ ├── AvoidSQLRequestInLoopCheckTest.java │ │ ├── AvoidTryCatchFinallyCheckNOKfailsAllTryStatementsTest.java │ │ ├── AvoidUsingGlobalVariablesCheckTest.java │ │ ├── IncrementCheckTest.java │ │ ├── NoFunctionCallWhenDeclaringForLoopTest.java │ │ └── UseOfMethodsForBasicOperationsTest.java │ └── resources │ └── checks │ ├── AvoidFullSQLRequest.php │ ├── AvoidSQLRequestInLoop.php │ ├── AvoidUsingGlobalVariablesCheck.php │ ├── avoidDoubleQuote.php │ ├── avoidTryCatchFinallyCheck_NOK_FailsAllTryStatements.php │ ├── incrementCheck.php │ ├── noFunctionCallWhenDeclaringForLoop.php │ └── useOfMethodsForBasicOperations.php ├── pom.xml ├── prepare-codenarc ├── prepare-codenarc.bat ├── python-plugin ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── fr │ │ │ └── cnumr │ │ │ └── python │ │ │ ├── CustomPythonRuleRepository.java │ │ │ ├── CustomPythonRulesPlugin.java │ │ │ ├── checks │ │ │ ├── AvoidFullSQLRequest.java │ │ │ ├── AvoidGettersAndSetters.java │ │ │ ├── AvoidGlobalVariableInFunctionCheck.java │ │ │ ├── AvoidSQLRequestInLoop.java │ │ │ ├── AvoidTryCatchFinallyCheck.java │ │ │ ├── NoFunctionCallWhenDeclaringForLoop.java │ │ │ └── package-info.java │ │ │ └── package-info.java │ └── resources │ │ └── fr │ │ └── cnumr │ │ └── l10n │ │ └── python │ │ └── rules │ │ └── python │ │ ├── D4.html │ │ ├── D4.json │ │ ├── D7.html │ │ ├── D7.json │ │ ├── S34.html │ │ ├── S34.json │ │ ├── S69.html │ │ ├── S69.json │ │ ├── S72.html │ │ ├── S72.json │ │ ├── S74.html │ │ └── S74.json │ └── test │ ├── java │ └── fr │ │ └── cnumr │ │ └── python │ │ ├── CustomPythonRuleRepositoryTest.java │ │ ├── CustomPythonRulesPluginTest.java │ │ └── checks │ │ ├── AvoidFullSQLRequestTest.java │ │ ├── AvoidGettersAndSettersTest.java │ │ ├── AvoidGlobalVariableInFunctionCheckTest.java │ │ ├── AvoidSQLRequestInLoopTest.java │ │ ├── AvoidTryCatchFinallyCheckTest.java │ │ └── NoFunctionCallWhenDeclaringForLoopTest.java │ └── resources │ └── checks │ ├── .gitignore │ ├── avoidFullSQLRequest.py │ ├── avoidGettersAndSetters.py │ ├── avoidGlobalVariableInFunction.py │ ├── avoidSQLRequestInLoop.py │ ├── avoidSQLRequestInLoopCheck.py │ ├── avoidSQLRequestInLoopNoImports.py │ ├── avoidTryCatchFinallyCheck.py │ ├── init_dbtest.sql │ ├── my.conf.sample │ └── noFunctionCallWhenDeclaringForLoop.py ├── sonar-project.properties └── xml-plugin ├── README.md ├── pom.xml └── src ├── main ├── java │ └── fr │ │ └── cnumr │ │ └── xml │ │ ├── MyXmlRules.java │ │ ├── XMLCustomRulesPlugin.java │ │ └── checks │ │ ├── CheckList.java │ │ └── UseUnoptimizedVectorImage.java └── resources │ └── fr │ └── cnumr │ └── l10n │ └── xml │ └── rules │ └── custom │ ├── S99.html │ └── S99.json └── test ├── java └── fr │ └── cnumr │ └── xml │ ├── MyXmlRulesTest.java │ └── checks │ └── UseUnoptimizedVectorImageTest.java └── resources └── checks └── UseUnoptimizedVectorImage ├── UseUnoptimizedVectorImage.svg ├── UseUnoptimizedVectorImageSVGO.svg └── pom.xml /.gitignore: -------------------------------------------------------------------------------- 1 | # Markdown 2 | README.md.tmp.html 3 | 4 | # Maven 5 | target/ 6 | pom.xml.tag 7 | pom.xml.releaseBackup 8 | pom.xml.versionsBackup 9 | pom.xml.next 10 | release.properties 11 | dependency-reduced-pom.xml 12 | buildNumber.properties 13 | .mvn/timing.properties 14 | # https://github.com/takari/maven-wrapper#usage-without-binary-jar 15 | .mvn/wrapper/maven-wrapper.jar 16 | 17 | # Gradle 18 | .gradle/ 19 | 20 | # Eclipse m2e generated files 21 | # Eclipse Core 22 | .project 23 | .idea 24 | # JDT-specific (Eclipse Java Development Tools) 25 | .classpath 26 | .settings/ 27 | 28 | # IntelliJ IDEA settings 29 | .idea -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | ![Logo](resources/logo-large.png) 2 | 3 | --- 4 | 5 | ## 🌠 Official resources 6 | 7 | Find official resources associated to ecoCode project [here](resources) 8 | 9 | ## 📜 Rules 10 | 11 | ecoCode is based on evolving catalogs of [good practices](rules), for various technologies. A SonarQube plugin then implement these catalogs as rules for scanning your projects. 12 | 13 | These catalogs of rules are listed [here](rules) -------------------------------------------------------------------------------- /docs/resources/challenge-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/docs/resources/challenge-logo.png -------------------------------------------------------------------------------- /docs/resources/logo-large.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/docs/resources/logo-large.png -------------------------------------------------------------------------------- /docs/resources/screenshot.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/docs/resources/screenshot.PNG -------------------------------------------------------------------------------- /hackathon/README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 |

Welcome to ecoCode Challenge

5 | 6 | 💪 Help us improve ecoCode (powered by SonarQube) by contributing to various [work-packages](work-packages.md). 7 | 8 | 🏁 Start by checking the [coding tips](coding-tips.md) and our [starter pack](starter-pack.md). 9 | 10 | 💬 At every moment of the challenge, [start new discussions](https://github.com/cnumr/ecoCode/discussions/new?category=hackathon) or [join existing ones](https://github.com/cnumr/ecoCode/discussions/categories/hackathon). 11 | -------------------------------------------------------------------------------- /sonarqube-plugin-greenit/python-plugin/src/main/resources/fr/cnumr/l10n/python/rules/python/64.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Avoid SQL request in loop", 3 | "type": "CODE_SMELL", 4 | 5 | "status": "ready", 6 | "remediation": { 7 | "func": "Constant\/Issue", 8 | "constantCost": "10min" 9 | }, 10 | "tags": [ 11 | "eco-conception" 12 | ], 13 | "defaultSeverity": "Minor" 14 | } -------------------------------------------------------------------------------- /sonarqube-plugin-greenit/python-plugin/src/test/java/fr/cnumr/python/checks/AvoidSQLRequestInLoopCheckTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.python.checks; 2 | 3 | import org.junit.Test; 4 | import org.sonar.python.checks.utils.PythonCheckVerifier; 5 | 6 | public class AvoidSQLRequestInLoopCheckTest { 7 | 8 | @Test 9 | public void test() { 10 | PythonCheckVerifier.verify("src/test/resources/checks/AvoidSQLRequestInLoopCheck.py", new AvoidSQLRequestInLoopCheckTest()); 11 | } 12 | } -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | !.gitignore 2 | .* 3 | node_modules 4 | yarn.lock 5 | target/ 6 | node/ 7 | *.iml 8 | /lib/*.jar 9 | bin -------------------------------------------------------------------------------- /src/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/.gitkeep -------------------------------------------------------------------------------- /src/0_init_reinit.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | docker-compose up --build -d -------------------------------------------------------------------------------- /src/1_compile.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | mvn clean compile 4 | -------------------------------------------------------------------------------- /src/2_build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | mvn clean package -DskipTests 4 | -------------------------------------------------------------------------------- /src/3_start.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | docker-compose start -------------------------------------------------------------------------------- /src/4_stop.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | docker-compose stop -------------------------------------------------------------------------------- /src/android-plugin/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM registry.snapp.fr/snapp/ecocode/sonar-ecocode/feature-new-ui:latest 2 | COPY target/*.jar /opt/sonarqube/extensions/plugins/ -------------------------------------------------------------------------------- /src/android-plugin/NOTICE.txt: -------------------------------------------------------------------------------- 1 | ecoCode SonarQube plugin 2 | Copyright (C) 2020-2021 Snapp' - Université de Pau et des Pays de l'Adour 3 | mailto: contact@ecocode.io 4 | -------------------------------------------------------------------------------- /src/android-plugin/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | 5 | sonar: 6 | image: sonarqube:8.6-community 7 | container_name: ecoCode-sonar 8 | restart: unless-stopped 9 | volumes: 10 | - ./target/ecocode-rules-1.0-SNAPSHOT.jar:/opt/sonarqube/extensions/plugins/ecocode-rules-1.0-SNAPSHOT.jar 11 | ports: 12 | - 9000:9000 13 | - 9092:9092 14 | -------------------------------------------------------------------------------- /src/android-plugin/docs/ekko-sonar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/android-plugin/docs/ekko-sonar.png -------------------------------------------------------------------------------- /src/android-plugin/docs/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/android-plugin/docs/logo.png -------------------------------------------------------------------------------- /src/android-plugin/docs/logoCCNR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/android-plugin/docs/logoCCNR.png -------------------------------------------------------------------------------- /src/android-plugin/docs/logoNA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/android-plugin/docs/logoNA.png -------------------------------------------------------------------------------- /src/android-plugin/docs/logoSnapp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/android-plugin/docs/logoSnapp.png -------------------------------------------------------------------------------- /src/android-plugin/docs/logoUnivPau.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/android-plugin/docs/logoUnivPau.png -------------------------------------------------------------------------------- /src/android-plugin/images/creed-4-sur-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/android-plugin/images/creed-4-sur-5.png -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/io/ecocode/xml/rules/EBAT001.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Batch: Service Boot Time", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "10min" 8 | }, 9 | "tags": [ 10 | "batch", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/io/ecocode/xml/rules/EIDL003.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Idleness: Keep Screen On", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "20min" 8 | }, 9 | "tags": [ 10 | "idleness", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/io/ecocode/xml/rules/EIDL005.html: -------------------------------------------------------------------------------- 1 | 2 |

To avoid draining the battery, an Android device that is left idle quickly falls asleep. 3 | Hence, keeping the screen on should be avoided, unless it is absolutely necessary.
4 | If so, developers typically use a Power Manager system service feature called wake locks 5 | by invoking PowerManager.WakeLock#newWakeLock(int levelAndFlags, String tag), 6 | along with the specific permission WAKE_LOCK in their manifest.

7 |

Noncompliant Code Example

8 |
 9 |     <manifest>
10 |         <uses-permission android:name="android.permission.WAKE_LOCK" />
11 |     </manifest>
12 | 
13 | -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/io/ecocode/xml/rules/EIDL005.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Idleness: Keep CPU On", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "1h" 8 | }, 9 | "tags": [ 10 | "idleness", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/io/ecocode/xml/rules/EPOW002.html: -------------------------------------------------------------------------------- 1 | 2 |

A negative effect on the device s battery is when an app is paired with a companion device (over Bluetooth, BLE, or Wi-Fi) 3 | and that it has been excluded from battery optimizations (run in the background) using the declaration 4 | Manifest.permission.REQUEST_COMPANION_RUN_IN_BACKGROUND.

5 |

Noncompliant Code Example

6 |
 7 |     <manifest>
 8 |        <uses-permission android:name="android.permission.REQUEST_COMPANION_RUN_IN_BACKGROUND">
 9 |     </manifest>
10 | 
-------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/io/ecocode/xml/rules/EPOW002.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Power: Compagnion In Background", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "20min" 8 | }, 9 | "tags": [ 10 | "power", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/io/ecocode/xml/rules/EPOW003.html: -------------------------------------------------------------------------------- 1 | 2 |

An app holding the permission REQUEST_IGNORE_BATTERY_OPTIMIZATIONS asks the user to allow it to ignore 3 | battery optimizations (that is, put them on the whitelist of apps).

4 |

Most applications should not use this; there are many facilities provided by the platform for applications to 5 | operate correctly in the various power saving modes.

6 | 7 |

Noncompliant Code Example

8 |
 9 |     <manifest>
10 |         <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
11 |     </manifest>
12 | 
13 | -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/io/ecocode/xml/rules/EPOW003.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Power: Ignore Battery Optimizations", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "1h" 8 | }, 9 | "tags": [ 10 | "power", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/io/ecocode/xml/rules/EPOW005.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Power: Charge Awareness", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "0min" 8 | }, 9 | "tags": [ 10 | "power", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Info" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/io/ecocode/xml/rules/EPOW007.html: -------------------------------------------------------------------------------- 1 | 2 |

Taking into account when the device is entering or exiting the power save mode is higly desirable for the battery 3 | life. 4 | It implies the existence of a broadcast receiver registered on the action 5 | ACTION_POWER_SAVE_MODE_CHANGED, 6 | or programmaticaly with a call to PowerManager#isPowerSaveMode().

7 |

Compliant Code Example

8 |
 9 |     <receiver android:name="io.ecocode.testapp.core.service.MyReceiver">
10 |         <intent-filter>
11 |             <action android:name="android.intent.action.BATTERY_CHANGED"/>
12 |         </intent-filter>
13 |     </receiver>
14 | 
-------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/io/ecocode/xml/rules/EPOW007.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Power: Save Mode Awareness", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "0min" 8 | }, 9 | "tags": [ 10 | "power", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Info" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/io/ecocode/xml/rules/ESOB003.html: -------------------------------------------------------------------------------- 1 | 2 |

Displaying dark colors is particularly beneficial for mobile devices with (AM)OLED screens.
3 | Consequently, custom resources like bright colors values and bitmap images with too high luminance should be avoided.

4 |

Noncompliant Code Example

5 |
 6 |     <TextView
 7 |         android:layout_width="match_parent"
 8 |         android:layout_height="match_parent"
 9 |         android:foreground="#FFFFFF"
10 |         android:foregroundTint="#FFFFFF">
11 |     </TextView>
12 | 
-------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/io/ecocode/xml/rules/ESOB003.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Sobriety: Dark UI (Bright Colors)", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "1h" 8 | }, 9 | "tags": [ 10 | "sobriety", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/io/ecocode/xml/rules/ESOB004.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Sobriety: Dark UI (Theme)", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "1h" 8 | }, 9 | "tags": [ 10 | "sobriety", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/io/ecocode/xml/rules/README.md: -------------------------------------------------------------------------------- 1 | # These files are GENERATED 2 | 3 | The files from this folder are **generated** directly from our rules descriptions project. 4 | 5 | Consequently, do not attempt to manually modify files here, nor submit Pull Request (PR) modifying description 6 | or rule metatada. Any PR will be systematically rejected. 7 | 8 | If you want to: 9 | 10 | * update descriptions; 11 | * extends their content; 12 | * fix misleading content; 13 | * adjust rule metadata; 14 | * etc. 15 | 16 | Then, please reach us though our mail , prior to submitting any code change. 17 | 18 | Thanks, 19 | *The ecoCode Team* 20 | -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/io/ecocode/xml/rules/ecocode_xml_profile.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ecoCode", 3 | "ruleKeys": [ 4 | "EBAT001", 5 | "EIDL003", 6 | "EIDL005", 7 | "EPOW002", 8 | "EPOW003", 9 | "EPOW005", 10 | "EPOW007", 11 | "ESOB004" 12 | ] 13 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/EBAT002_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Batch: Sensor Coalesce", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "20min" 8 | }, 9 | "tags": [ 10 | "batch", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Minor" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/EBAT003_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Batch: Job Coalesce", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "3h" 8 | }, 9 | "tags": [ 10 | "batch", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Minor" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/EBOT001_java.html: -------------------------------------------------------------------------------- 1 | 2 |

Opening and closing internet connection continuously is extremely battery-inefficient since HTTP exchange is the most 3 | consuming operation of the network. This bug typically occurs when one obtain a new HttpURLConnection 4 | by calling URL#openConnection() within a loop control structure (while, for, do-while, for-each).
5 | Also, this bad practice must be early prevented because it is the root of another evil that consists in polling 6 | data at regular intervals, instead of using push notifications to save a lot of battery power.

7 |

Noncompliant Code Example

8 |
 9 |     for (int val : myArray) {
10 |         URL.openConnection();
11 |     }
12 | 
13 | -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/EBOT001_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Bottleneck: Internet In The Loop", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "3h" 8 | }, 9 | "tags": [ 10 | "optimized-api", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Critical" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/EBOT002_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Bottleneck: Wifi Multicast Lock", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "20min" 8 | }, 9 | "tags": [ 10 | "bottleneck", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Minor" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/EBOT003_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Bottleneck: Uncompressed Data Transmission", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "10min" 8 | }, 9 | "tags": [ 10 | "bottleneck", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Minor" 15 | } 16 | -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/EIDL001_java.html: -------------------------------------------------------------------------------- 1 | 2 |

To avoid draining the battery, an Android device that is left idle quickly falls asleep.
3 | Hence, keeping the screen on should be avoided, unless it is absolutely necessary. If so, developers typically 4 | use the FLAG_KEEP_SCREEN_ON in their activity. Another way to implement this is in their application's 5 | layout XML file, by using the android:keepScreenOn attribute.

6 |

Noncompliant Code Example

7 |
 8 |     getWindow().addFlags(FLAG_KEEP_SCREEN_ON);
 9 | 
10 | -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/EIDL001_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Idleness: Keep Screen On (addFlags)", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "20min" 8 | }, 9 | "tags": [ 10 | "idleness", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/EIDL002_java.html: -------------------------------------------------------------------------------- 1 | 2 |

To avoid draining the battery, an Android device that is left idle quickly falls asleep.
3 | Hence, keeping the screen on should be avoided, unless it is absolutely necessary. If so, developers typically 4 | use the FLAG_KEEP_SCREEN_ON in their activity. Another way to implement this is in their application's 5 | layout XML file, by using the android:keepScreenOn attribute.

6 |

Noncompliant Code Example

7 |
 8 |     getWindow().setFlags(FLAG_KEEP_SCREEN_ON, FLAG_KEEP_SCREEN_ON);
 9 | 
10 | -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/EIDL002_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Idleness: Keep Screen On (setFlags)", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "20min" 8 | }, 9 | "tags": [ 10 | "idleness", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/EIDL004_java.html: -------------------------------------------------------------------------------- 1 | 2 |

To avoid draining the battery, an Android device that is left idle quickly falls asleep. 3 | Hence, keeping the CPU on should be avoided, unless it is absolutely necessary.
4 | If so, developers typically use a Power Manager system service feature called wake locks 5 | by invoking PowerManager.WakeLock#newWakeLock(int levelAndFlags, String tag), 6 | along with the specific permission WAKE_LOCK in their manifest.

7 |

Noncompliant Code Example

8 |
 9 |     PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
10 |     WakeLock manager = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "TAG");
11 | 
-------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/EIDL004_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Idleness: Keep Cpu On", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "1h" 8 | }, 9 | "tags": [ 10 | "idleness", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/EIDL006_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Idleness: Durable Wake Lock", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "10min" 8 | }, 9 | "tags": [ 10 | "idleness", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/EIDL007_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Idleness: Rigid Alarm", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "1d" 8 | }, 9 | "tags": [ 10 | "idleness", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/EIDL008_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Idleness: Continuous Rendering", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "10min" 8 | }, 9 | "tags": [ 10 | "idleness", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Minor" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/EIDL009_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Idleness: Keep Voice Awake", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "10min" 8 | }, 9 | "tags": [ 10 | "idleness", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/ELEA002_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Leakage: Camera Leak", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "20min" 8 | }, 9 | "tags": [ 10 | "leakage", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Critical" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/ELEA003_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Leakage: Location Leak", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "20min" 8 | }, 9 | "tags": [ 10 | "leakage", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Minor" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/ELEA004_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Leakage: SensorManager Leak", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "20min" 8 | }, 9 | "tags": [ 10 | "leakage", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/ELEA005_java.html: -------------------------------------------------------------------------------- 1 | 2 |

Creation of a Media Recorder object with new MediaRecorder() is used to record 3 | audio and video. Class own a release() method.

4 |

In addition to unnecessary resources (such as memory and instances of codecs) being held, 5 | failure to call this method immediately if a media object is no longer needed may also lead to 6 | continuous battery consumption for mobile devices.

7 |

Noncompliant Code Example

8 |
 9 |     MediaRecorder mr = new MediaRecorder();
10 | 
11 |

Compliant Solution

12 |
13 |     MediaRecorder mr = new MediaRecorder();
14 |     mr.release();
15 | 
16 | -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/ELEA005_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Leakage: Media Leak (MediaRecorder)", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "20min" 8 | }, 9 | "tags": [ 10 | "leakage", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/ELEA006_java.html: -------------------------------------------------------------------------------- 1 | 2 |

Creation of a Media Player object with new MediaPlayer() can 3 | be used to control playback of audio/video files and streams. Class own arelease() method.

4 |

In addition to unnecessary resources (such as memory and instances of codecs) being held, 5 | failure to call this method immediately if a media object is no longer needed may also lead to 6 | continuous battery consumption for mobile devices.

7 |

Noncompliant Code Example

8 |
 9 |     MediaPlayer mp = new MediaPlayer();
10 | 
11 |

Compliant Solution

12 |
13 |     MediaPlayer mp = new MediaPlayer();
14 |     mp.release();
15 | 
16 | -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/ELEA006_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Leakage: Media Leak (MediaPlayer)", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "20min" 8 | }, 9 | "tags": [ 10 | "leakage", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/EOPT001_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Optimized API: Fused Location", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "20min" 8 | }, 9 | "tags": [ 10 | "optimized-api", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/EOPT002_java.html: -------------------------------------------------------------------------------- 1 | 2 |

In contrast to classic Bluetooth, Bluetooth Low Energy (BLE) 3 | is designed to provide significantly lower power consumption. 4 | Its purpose is to save energy on both paired devices but very few 5 | developers are aware of this alternative API. 6 | From the Android client side, it means append android.bluetooth.le.* 7 | imports to android.bluetooth.* imports in order to benefits from 8 | low-energy features.

9 |

Noncompliant Code Example

10 |
11 |     import android.bluetooth.*
12 | 
13 |

Compliant Solution

14 |
15 |     import android.bluetooth.le.*
16 | 
-------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/EOPT002_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Optimized API: Bluetooth Low-Energy", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "20min" 8 | }, 9 | "tags": [ 10 | "optimized-api", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/EPOW004_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Power: Charge Awareness", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "0min" 8 | }, 9 | "tags": [ 10 | "power", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Info" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/EPOW006_java.html: -------------------------------------------------------------------------------- 1 | 2 |

Taking into account when the device is entering or exiting the power save mode is higly desirable for the battery 3 | life. 4 | It implies the existence of a broadcast receiver registered on the action 5 | ACTION_POWER_SAVE_MODE_CHANGED, 6 | or programmaticaly with a call to PowerManager#isPowerSaveMode().

7 |

Compliant Code Example

8 |
 9 |     new IntentFilter(Intent.ACTION_POWER_SAVE_MODE_CHANGED)
10 | 
11 | OR 12 |
13 |     intentFilter.addAction(ACTION_POWER_SAVE_MODE_CHANGED)
14 | 
15 | OR 16 |
17 |     IntentFilter.create(ACTION_POWER_SAVE_MODE_CHANGED,"")
18 | 
19 | OR 20 |
21 |     powerManager.isPowerSaveMode()
22 | 
-------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/EPOW006_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Power: Save Mode Awareness", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "0min" 8 | }, 9 | "tags": [ 10 | "power", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Info" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/ESOB001_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Sobriety: Thrifty Motion Sensor", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "sobriety", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Minor" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/ESOB002_java.html: -------------------------------------------------------------------------------- 1 | 2 |

Introduced in Android 9, the adaptive brightness feature raises or lower the brightness of the screen depending on 3 | the light in the current environment.
4 | For some reasons, developers may disable this feature programmatically, setting the field 5 | WindowManager.LayoutParams#screenBrightness with the constant BRIGHTNESS_OVERRIDE_FULL.
6 | This feature was introduced to improve battery life, be careful when deactivating it.

7 |

Noncompliant Code Example

8 |
 9 |     getWindow().getAttributes().screenBrightness = BRIGHTNESS_OVERRIDE_FULL;
10 | 
11 | -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/ESOB002_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Sobriety: Brightness Override", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "20min" 8 | }, 9 | "tags": [ 10 | "sobriety", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Minor" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/ESOB005_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Sobriety: Thrifty Geolocation (minTime)", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "10min" 8 | }, 9 | "tags": [ 10 | "sobriety", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/ESOB006_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Sobriety: Thrifty Geolocation Criteria", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "20min" 8 | }, 9 | "tags": [ 10 | "sobriety", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } 16 | -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/ESOB007_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Sobriety: Thrifty Bluetooth Low Energy (setAdvertiseMode)", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "10min" 8 | }, 9 | "tags": [ 10 | "sobriety", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/ESOB008_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Sobriety: Thrifty Bluetooth Low Energy (requestConnectionPriority)", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "10min" 8 | }, 9 | "tags": [ 10 | "sobriety", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/ESOB010_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Sobriety: Thrifty Geolocation (minDistance)", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "10min" 8 | }, 9 | "tags": [ 10 | "sobriety", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Minor" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/ESOB011_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Sobriety: Vibration Free", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "sobriety", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Minor" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/ESOB012_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Sobriety: Thrifty Notification", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "sobriety", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Minor" 15 | } 16 | -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/ESOB013_java.html: -------------------------------------------------------------------------------- 1 | 2 |

Turning on the torch mode programmatically with CameraManager#setTorchMode(..., true) must absolutely be 3 | avoided because the flashlight is one of the most energy-intensive component.

4 |

Noncompliant Code Example

5 |
 6 |  CameraManager camManager = (CameraManager) getSystemService(Context.CAMERA_SERVICE);
 7 |         String cameraId = null;
 8 |         try {
 9 |             cameraId = camManager.getCameraIdList()[0];
10 |             camManager.setTorchMode(cameraId, true);
11 |         } catch (CameraAccessException e) {
12 |             e.printStackTrace();
13 |         }
14 | 
-------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/ESOB013_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Sobriety: Torch Free", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "sobriety", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } 16 | -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/ESOB014_java.html: -------------------------------------------------------------------------------- 1 | 2 |

In Android 11 (API level 30) or higher, a call to 3 | Surface#setFrameRate(float frameRate, int compatibility) results in a change to the display refresh 4 | rate. However, a regular app displays 60 frames per second (60Hz). In order to optimize content refreshes and hence 5 | saving energy, this frequency should not be raised to 90Hz or 120Hz, despite this is now supported by many devices. 6 |

7 |

Noncompliant Code Example

8 |
 9 |     surface.setFrameRate(120f, FRAME_RATE_COMPATIBILITY_DEFAULT);
10 | 
11 |

Compliant Code Example

12 |
13 |     surface.setFrameRate(60f, FRAME_RATE_COMPATIBILITY_DEFAULT);
14 | 
-------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/ESOB014_java.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Sobriety: High Frame Rate", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "sobriety", 11 | "environment", 12 | "ecocode" 13 | ], 14 | "defaultSeverity": "Major" 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/README.md: -------------------------------------------------------------------------------- 1 | # These files are GENERATED 2 | 3 | The files from this folder are **generated** directly from our rules descriptions project. 4 | 5 | Consequently, do not attempt to manually modify files here, nor submit Pull Request (PR) modifying description 6 | or rule metatada. Any PR will be systematically rejected. 7 | 8 | If you want to: 9 | 10 | * update descriptions; 11 | * extends their content; 12 | * fix misleading content; 13 | * adjust rule metadata; 14 | * etc. 15 | 16 | Then, please reach us though our mail , prior to submitting any code change. 17 | 18 | Thanks, 19 | *The ecoCode Team* 20 | -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/l10n/java/rules/squid/ecocode_java_profile.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ecoCode", 3 | "ruleKeys": [ 4 | "EBAT002", 5 | "EBAT003", 6 | "EBOT001", 7 | "EBOT002", 8 | "EBOT003", 9 | "EIDL001", 10 | "EIDL002", 11 | "EIDL004", 12 | "EIDL006", 13 | "EIDL007", 14 | "EIDL008", 15 | "EIDL009", 16 | "ELEA002", 17 | "ELEA003", 18 | "ELEA004", 19 | "ELEA005", 20 | "ELEA006", 21 | "EOPT001", 22 | "EOPT002", 23 | "EPOW004", 24 | "EPOW006", 25 | "ESOB001", 26 | "ESOB002", 27 | "ESOB005", 28 | "ESOB006", 29 | "ESOB007", 30 | "ESOB008", 31 | "ESOB010", 32 | "ESOB011", 33 | "ESOB012", 34 | "ESOB013", 35 | "ESOB014" 36 | ] 37 | } -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/plugins/groovy/cost.csv: -------------------------------------------------------------------------------- 1 | ruleKey;remediationFunction;remediationFactor 2 | org.codenarc.rule.ecocode.FatAppRule;linear;1h 3 | org.codenarc.rule.ecocode.SupportedVersionRangeRule;linear;10min 4 | org.codenarc.rule.ecocode.DisableObfuscationRule;linear;10min 5 | -------------------------------------------------------------------------------- /src/android-plugin/src/main/resources/org/sonar/plugins/groovy/profile-default.txt: -------------------------------------------------------------------------------- 1 | org.codenarc.rule.ecocode.FatAppRule 2 | org.codenarc.rule.ecocode.SupportedVersionRangeRule 3 | org.codenarc.rule.ecocode.DisableObfuscationRule -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/bottleneck/WifiMulticastLockCheck.java: -------------------------------------------------------------------------------- 1 | package android.net.wifi; 2 | 3 | public class WifiManager { 4 | 5 | public void test() { 6 | MulticastLock multicastLock = new MulticastLock(); 7 | multicastLock.acquire();// Noncompliant {{Failing to call WifiManager.MulticastLock#release() can cause a noticeable battery drain.}} 8 | } 9 | 10 | public class MulticastLock { 11 | public void acquire() { 12 | String str = "acquire Called"; 13 | } 14 | 15 | public void release() { 16 | String str = "release Called"; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/bottleneck/WifiMulticastLockNoIssueCheck.java: -------------------------------------------------------------------------------- 1 | package android.net.wifi; 2 | 3 | public class WifiManager { 4 | 5 | public void test() { 6 | MulticastLock multicastLock = new MulticastLock(); 7 | multicastLock.acquire(); 8 | multicastLock.release(); 9 | 10 | MulticastLock multicastLock2 = new MulticastLock(); 11 | multicastLock2.acquire(); 12 | multicastLock2.release(); 13 | } 14 | 15 | public class MulticastLock { 16 | public void acquire() { 17 | string str = "acquire Called"; 18 | } 19 | 20 | public void release() { 21 | string str = "release Called"; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/idleness/ContinuousRenderingCheck.java: -------------------------------------------------------------------------------- 1 | package android.opengl; 2 | 3 | public class GLSurfaceView { 4 | 5 | public final static int RENDERMODE_WHEN_DIRTY = 0; 6 | public final static int RENDERMODE_CONTINUOUSLY = 1; 7 | 8 | public void test() { 9 | GLSurfaceView surface = new GLSurfaceView(); 10 | surface.setRenderMode(RENDERMODE_CONTINUOUSLY); // Noncompliant {{Using RENDERMODE_WHEN_DIRTY instead of RENDERMODE_CONTINUOUSLY can improve battery life.}} 11 | surface.setRenderMode(RENDERMODE_WHEN_DIRTY); 12 | } 13 | 14 | public void setRenderMode(int renderMode) { 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/idleness/KeepCpuOnCheck.java: -------------------------------------------------------------------------------- 1 | package android.os; 2 | 3 | public final class PowerManager { 4 | 5 | public void test() { 6 | PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); 7 | WakeLock manager = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, getPackageName()); // Noncompliant {{Keeping the screen on should be avoided to avoid draining battery.}} 8 | } 9 | 10 | public WakeLock newWakeLock(int levelAndFlags, String tag) { 11 | validateWakeLockParameters(levelAndFlags, tag); 12 | return new WakeLock(levelAndFlags, tag, mContext.getOpPackageName()); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/idleness/KeepVoiceAwakeCheck.java: -------------------------------------------------------------------------------- 1 | package android.service.voice; 2 | 3 | public class VoiceInteractionSession { 4 | 5 | public void test() { 6 | VoiceInteractionSession session = new VoiceInteractionSession(); 7 | session.setKeepAwake(true);// Noncompliant {{VoiceInteractionSession.setKeepAwake(false) should be called to limit battery drain.}} 8 | } 9 | 10 | public VoiceInteractionSession() { 11 | } 12 | 13 | public void setKeepAwake(boolean type) { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/idleness/KeepVoiceAwakeNotPresentCheck.java: -------------------------------------------------------------------------------- 1 | package android.service.voice; 2 | 3 | public class VoiceInteractionSession { 4 | 5 | public void test() { 6 | VoiceInteractionSession session = new VoiceInteractionSession();// Noncompliant {{VoiceInteractionSession.setKeepAwake(false) should be called to limit battery drain.}} 7 | } 8 | 9 | public VoiceInteractionSession() { 10 | } 11 | 12 | public void setKeepAwake(boolean type) { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/idleness/KeepVoiceAwakeToFalseCheck.java: -------------------------------------------------------------------------------- 1 | package android.service.voice; 2 | 3 | public class VoiceInteractionSession { 4 | 5 | public void test() { 6 | VoiceInteractionSession session = new VoiceInteractionSession(); 7 | session.setKeepAwake(false); 8 | } 9 | 10 | public VoiceInteractionSession() { 11 | } 12 | 13 | public void setKeepAwake(boolean type) { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/leakage/CameraLeakCheckIssue.java: -------------------------------------------------------------------------------- 1 | package android.hardware; 2 | 3 | public class Camera { 4 | 5 | public void test() { 6 | open();// Noncompliant {{Failing to call android.hardware.Camera#release() can drain the battery in just a few hours.}} 7 | } 8 | 9 | public boolean open() { 10 | return true; 11 | } 12 | 13 | public void release() { 14 | } 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/leakage/CameraLeakCheckNoIssue.java: -------------------------------------------------------------------------------- 1 | package android.hardware; 2 | 3 | public class Camera { 4 | 5 | public void test() { 6 | open(); 7 | release(); 8 | } 9 | 10 | public boolean open() { 11 | return true; 12 | } 13 | 14 | public void release() { 15 | } 16 | } -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/leakage/LocationLeakCheckIssue.java: -------------------------------------------------------------------------------- 1 | package android.location; 2 | 3 | public class LocationManager { 4 | 5 | public void test() { 6 | requestLocationUpdates();// Noncompliant {{Failing to call android.location.LocationManager#removeUpdates() can drain the battery in just a few hours.}} 7 | } 8 | 9 | public boolean requestLocationUpdates() { 10 | return true; 11 | } 12 | 13 | public void removeUpdates() { 14 | } 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/leakage/LocationLealCheckNoIssue.java: -------------------------------------------------------------------------------- 1 | package android.location; 2 | 3 | public class LocationManager { 4 | 5 | public void test() { 6 | requestLocationUpdates(); 7 | removeUpdates(); 8 | } 9 | 10 | public boolean requestLocationUpdates() { 11 | return true; 12 | } 13 | 14 | public void removeUpdates() { 15 | } 16 | } -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/leakage/MediaLeakMediaPlayerCheckIssue.java: -------------------------------------------------------------------------------- 1 | package android.media; 2 | 3 | public class MediaPlayer { 4 | 5 | public void test() { 6 | MediaPlayer mp = new MediaPlayer(); // Noncompliant {{Failing to call release() on a Media Player may lead to continuous battery consumption.}} 7 | } 8 | 9 | public MediaPlayer() { 10 | } 11 | 12 | public void release() { 13 | } 14 | } -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/leakage/MediaLeakMediaPlayerCheckNoIssue.java: -------------------------------------------------------------------------------- 1 | package android.media; 2 | 3 | public class MediaPlayer { 4 | 5 | public void test() { 6 | MediaPlayer mp = new MediaPlayer(); 7 | mp.release(); 8 | } 9 | 10 | public MediaPlayer() { 11 | } 12 | 13 | public void release() { 14 | } 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/leakage/MediaLeakMediaRecorderCheckIssue.java: -------------------------------------------------------------------------------- 1 | package android.media; 2 | 3 | public class MediaRecorder { 4 | 5 | public void test() { 6 | MediaRecorder mr = new MediaRecorder(); // Noncompliant {{Failing to call release() on a Media Recorder may lead to continuous battery consumption.}} 7 | } 8 | 9 | public MediaRecorder() { 10 | } 11 | 12 | public void release() { 13 | } 14 | } -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/leakage/MediaLeakMediaRecorderCheckNoIssue.java: -------------------------------------------------------------------------------- 1 | package android.media; 2 | 3 | public class MediaRecorder { 4 | 5 | public void test() { 6 | MediaRecorder mr = new MediaRecorder(); 7 | mr.release(); 8 | } 9 | 10 | public MediaRecorder() { 11 | } 12 | 13 | public void release() { 14 | } 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/leakage/SensorManagerLeakCheckIssue.java: -------------------------------------------------------------------------------- 1 | package android.hardware; 2 | 3 | public class SensorManager { 4 | 5 | public SensorManager() { 6 | unregisterListener(); 7 | } 8 | 9 | public void test() { 10 | registerListener(); 11 | } 12 | 13 | public static boolean registerListener() { 14 | return true; 15 | } 16 | 17 | public static void unregisterListener() { 18 | } 19 | } 20 | 21 | public class SensorManager2 { 22 | public void test() { 23 | unregisterListener(); 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/leakage/SensorManagerLeakCheckNoIssue.java: -------------------------------------------------------------------------------- 1 | package android.hardware; 2 | 3 | public class SensorManager { 4 | 5 | public void test() { 6 | registerListener(); 7 | unregisterListener(); 8 | } 9 | 10 | public boolean registerListener() { 11 | return true; 12 | } 13 | 14 | public void unregisterListener() { 15 | } 16 | } -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/optimized_api/BluetoothLowEnergyCheckBothBleBc.java: -------------------------------------------------------------------------------- 1 | import android.bluetooth; 2 | import android.bluetooth.le; // Noncompliant {{Using android.bluetooth.le.* is a good practice.}} 3 | 4 | public class Dijon { 5 | } 6 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/optimized_api/BluetoothLowEnergyCheckOnlyBc.java: -------------------------------------------------------------------------------- 1 | import androidx.appcompat.app.AppCompatActivity; 2 | import android.bluetooth; // Noncompliant {{You are using Bluetooth. Did you take a look at the Bluetooth Low Energy API?}} 3 | import android.bluetooth.*; // Noncompliant {{You are using Bluetooth. Did you take a look at the Bluetooth Low Energy API?}} 4 | 5 | public class Dijon { 6 | } 7 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/optimized_api/BluetoothLowEnergyCheckOnlyBle.java: -------------------------------------------------------------------------------- 1 | import android.bluetooth.le.AdvertisingSet; // Noncompliant {{Using android.bluetooth.le.* is a good practice.}} 2 | 3 | public class Dijon { 4 | } 5 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/optimized_api/BluetoothLowEnergyCheckWildcard.java: -------------------------------------------------------------------------------- 1 | import android.bluetooth; 2 | import android.bluetooth.le; // Noncompliant {{Using android.bluetooth.le.* is a good practice.}} 3 | import android.bluetooth.le.*; // Noncompliant {{Using android.bluetooth.le.* is a good practice.}} 4 | import android.bluetooth.*; 5 | import androidx.appcompat.app.AppCompatActivity; 6 | 7 | public class Dijon { 8 | } 9 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/optimized_api/FusedLocationCheck.java: -------------------------------------------------------------------------------- 1 | import android.location.Location; // Noncompliant {{Use com.google.android.gms.location instead of android.location to maximize battery life.}} 2 | import android.location.GnssStatus; // Noncompliant {{Use com.google.android.gms.location instead of android.location to maximize battery life.}} 3 | import android.location.*; // Noncompliant {{Use com.google.android.gms.location instead of android.location to maximize battery life.}} 4 | import com.location.*; 5 | import com.location.GnssStatus; 6 | import android.GnssStatus; 7 | 8 | public class Dijon { 9 | } 10 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/optimized_api/FusedLocationCheckNoIssue.java: -------------------------------------------------------------------------------- 1 | import android.location.Location; 2 | import android.location.GnssStatus; 3 | import android.location.*; 4 | import com.google.android.gms.location.*; 5 | import com.location.*; 6 | import com.location.GnssStatus; 7 | import android.GnssStatus; 8 | 9 | public class Dijon { 10 | } 11 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/files/power/SaveModeAwarenessCheckPowerManager.java: -------------------------------------------------------------------------------- 1 | package android.os; 2 | 3 | public class PowerManager { 4 | private static final String POWER_SERVICE = "saveMode"; 5 | 6 | public void test() { 7 | PowerManager powerManager = POWER_SERVICE; 8 | if (powerManager.isPowerSaveMode()) { // Noncompliant {{Taking into account when the device is entering or exiting the power save mode is a good practice.}} 9 | } 10 | } 11 | 12 | public final bool isPowerSaveMode() { 13 | return true; 14 | } 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/batch/JobCoalesceRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.batch; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class JobCoalesceRuleTest { 7 | 8 | @Test 9 | public void verify() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/batch/JobCoalesceCheckAlarmManager.java") 11 | .withCheck(new JobCoalesceRule()) 12 | .verifyIssues(); 13 | 14 | JavaCheckVerifier.newVerifier().onFile("src/test/files/batch/JobCoalesceCheckSyncAdapter.java") 15 | .withCheck(new JobCoalesceRule()) 16 | .verifyIssues(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/batch/SensorCoalesceRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.batch; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class SensorCoalesceRuleTest { 7 | 8 | @Test 9 | public void verify() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/batch/SensorCoalesceCheck.java") 11 | .withCheck(new SensorCoalesceRule()) 12 | .verifyIssues(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/bottleneck/InternetInTheLoopRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.bottleneck; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class InternetInTheLoopRuleTest { 7 | 8 | @Test 9 | public void verifyLoop() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/bottleneck/InternetInTheLoopCheck.java") 11 | .withCheck(new InternetInTheLoopRule()) 12 | .verifyIssues(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/bottleneck/UncompressedDataTransmissionRulesTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.bottleneck; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class UncompressedDataTransmissionRulesTest { 7 | 8 | @Test 9 | public void verify() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/bottleneck/UncompressedDataTransmissionCheck.java") 11 | .withCheck(new UncompressedDataTransmissionRule()) 12 | .verifyIssues(); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/bottleneck/WifiMulticastLockRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.bottleneck; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class WifiMulticastLockRuleTest { 7 | 8 | @Test 9 | public void verify() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/bottleneck/WifiMulticastLockCheck.java") 11 | .withCheck(new WifiMulticastLockRule()) 12 | .verifyIssues(); 13 | } 14 | 15 | @Test 16 | public void verifyNoIssue() { 17 | JavaCheckVerifier.newVerifier().onFile("src/test/files/bottleneck/WifiMulticastLockNoIssueCheck.java") 18 | .withCheck(new WifiMulticastLockRule()) 19 | .verifyNoIssues(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/idleness/ContinuousRenderingTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.idleness; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class ContinuousRenderingTest { 7 | 8 | @Test 9 | public void checkContinuousRendering() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/idleness/ContinuousRenderingCheck.java") 11 | .withCheck(new ContinuousRenderingRule()) 12 | .verifyIssues(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/idleness/DurableWakeLockRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.idleness; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class DurableWakeLockRuleTest { 7 | 8 | @Test 9 | public void attributePresentTrue() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/idleness/DurableWakeLockCheck.java") 11 | .withCheck(new DurableWakeLockRule()) 12 | .verifyIssues(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/idleness/KeepCpuOnRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.idleness; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class KeepCpuOnRuleTest { 7 | 8 | @Test 9 | public void attributePresentTrue() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/idleness/KeepCpuOnCheck.java") 11 | .withCheck(new KeepCpuOnRule()) 12 | .verifyIssues(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/idleness/KeepScreenOnAddFlagsRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.idleness; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class KeepScreenOnAddFlagsRuleTest { 7 | 8 | @Test 9 | public void verify() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/idleness/KeepScreenOnAddFlagsCheck.java") 11 | .withCheck(new KeepScreenOnAddFlagsRule()) 12 | .verifyIssues(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/idleness/KeepScreenOnSetFlagsRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.idleness; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class KeepScreenOnSetFlagsRuleTest { 7 | 8 | @Test 9 | public void verify() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/idleness/KeepScreenOnSetFlagsCheck.java") 11 | .withCheck(new KeepScreenOnSetFlagsRule()) 12 | .verifyIssues(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/idleness/RigidAlarmRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.idleness; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class RigidAlarmRuleTest { 7 | 8 | @Test 9 | public void checkRigidAlarm() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/idleness/RigidAlarmCheck.java") 11 | .withCheck(new RigidAlarmRule()) 12 | .verifyIssues(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/leakage/CameraLeakRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.leakage; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class CameraLeakRuleTest { 7 | 8 | @Test 9 | public void CameraOnlyRegister() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/leakage/CameraLeakCheckIssue.java") 11 | .withCheck(new CameraLeakRule()) 12 | .verifyIssues(); 13 | } 14 | 15 | @Test 16 | public void CameraRegisterAndUnregister() { 17 | JavaCheckVerifier.newVerifier().onFile("src/test/files/leakage/CameraLeakCheckNoIssue.java") 18 | .withCheck(new CameraLeakRule()) 19 | .verifyNoIssues(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/leakage/LocationLeakRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.leakage; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class LocationLeakRuleTest { 7 | 8 | @Test 9 | public void LocationOnlyRegister() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/leakage/LocationLeakCheckIssue.java") 11 | .withCheck(new LocationLeakRule()) 12 | .verifyIssues(); 13 | } 14 | 15 | @Test 16 | public void LocationRegisterAndUnregister() { 17 | JavaCheckVerifier.newVerifier().onFile("src/test/files/leakage/LocationLealCheckNoIssue.java") 18 | .withCheck(new LocationLeakRule()) 19 | .verifyNoIssues(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/leakage/MediaLeakMediaPlayerRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.leakage; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class MediaLeakMediaPlayerRuleTest { 7 | 8 | @Test 9 | public void onlyConstructor() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/leakage/MediaLeakMediaPlayerCheckIssue.java") 11 | .withCheck(new MediaLeakMediaPlayerRule()) 12 | .verifyIssues(); 13 | } 14 | 15 | @Test 16 | public void constructorAndRelease() { 17 | JavaCheckVerifier.newVerifier().onFile("src/test/files/leakage/MediaLeakMediaPlayerCheckNoIssue.java") 18 | .withCheck(new MediaLeakMediaPlayerRule()) 19 | .verifyNoIssues(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/leakage/MediaLeakMediaRecorderRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.leakage; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class MediaLeakMediaRecorderRuleTest { 7 | 8 | @Test 9 | public void onlyConstructor() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/leakage/MediaLeakMediaRecorderCheckIssue.java") 11 | .withCheck(new MediaLeakMediaRecorderRule()) 12 | .verifyIssues(); 13 | } 14 | 15 | @Test 16 | public void constructorAndRelease() { 17 | JavaCheckVerifier.newVerifier().onFile("src/test/files/leakage/MediaLeakMediaRecorderCheckNoIssue.java") 18 | .withCheck(new MediaLeakMediaRecorderRule()) 19 | .verifyNoIssues(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/leakage/SensorManagerLeakRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.leakage; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class SensorManagerLeakRuleTest { 7 | 8 | @Test 9 | public void SensorManagerOnlyRegister() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/leakage/SensorManagerLeakCheckIssue.java") 11 | .withCheck(new SensorManagerLeakRule()) 12 | .verifyNoIssues(); 13 | } 14 | 15 | @Test 16 | public void SensorManagerRegisterAndUnregister() { 17 | JavaCheckVerifier.newVerifier().onFile("src/test/files/leakage/SensorManagerLeakCheckNoIssue.java") 18 | .withCheck(new SensorManagerLeakRule()) 19 | .verifyNoIssues(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/optimized_api/FusedLocationCheckTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.optimized_api; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class FusedLocationCheckTest { 7 | 8 | @Test 9 | public void verify() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/optimized_api/FusedLocationCheck.java") 11 | .withCheck(new FusedLocationRule()) 12 | .verifyIssues(); 13 | } 14 | 15 | @Test 16 | public void verifyNoIssue() { 17 | JavaCheckVerifier.newVerifier().onFile("src/test/files/optimized_api/FusedLocationCheckNoIssue.java") 18 | .withCheck(new FusedLocationRule()) 19 | .verifyNoIssues(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/power/ChargeAwarenessRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.power; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class ChargeAwarenessRuleTest { 7 | 8 | @Test 9 | public void verify() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/power/ChargeAwarenessCheck.java") 11 | .withCheck(new ChargeAwarenessRule()) 12 | .verifyIssues(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/power/SaveModeAwarenessRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.power; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class SaveModeAwarenessRuleTest { 7 | 8 | @Test 9 | public void verify() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/power/SaveModeAwarenessCheckIntentFilter.java") 11 | .withCheck(new SaveModeAwarenessRule()) 12 | .verifyIssues(); 13 | 14 | JavaCheckVerifier.newVerifier().onFile("src/test/files/power/SaveModeAwarenessCheckPowerManager.java") 15 | .withCheck(new SaveModeAwarenessRule()) 16 | .verifyIssues(); 17 | } 18 | } -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/sobriety/BrightnessOverrideRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.sobriety; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class BrightnessOverrideRuleTest { 7 | 8 | @Test 9 | public void verify() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/sobriety/BrightnessOverrideCheck.java") 11 | .withCheck(new BrightnessOverrideRule()) 12 | .verifyIssues(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/sobriety/HighFrameRateCheckTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.sobriety; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class HighFrameRateCheckTest { 7 | 8 | @Test 9 | public void verify() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/sobriety/HighFrameRateCheck.java") 11 | .withChecks(new HighFrameRateRule()) 12 | .verifyIssues(); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/sobriety/ThriftyBluetoothLowEnergyRequestConnectionPriorityRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.sobriety; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class ThriftyBluetoothLowEnergyRequestConnectionPriorityRuleTest { 7 | 8 | @Test 9 | public void verify() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/sobriety/ThriftyBluetoothLowEnergyRequestConnectionPriorityCheck.java") 11 | .withCheck(new ThriftyBluetoothLowEnergyRequestConnectionPriorityRule()) 12 | .verifyIssues(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/sobriety/ThriftyBluetoothLowEnergySetAdvertiseModeRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.sobriety; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class ThriftyBluetoothLowEnergySetAdvertiseModeRuleTest { 7 | 8 | @Test 9 | public void verify() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/sobriety/ThriftyBluetoothLowEnergySetAdvertiseModeCheck.java") 11 | .withCheck(new ThriftyBluetoothLowEnergySetAdvertiseModeRule()) 12 | .verifyIssues(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/sobriety/ThriftyGeolocationCheckTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.sobriety; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class ThriftyGeolocationCheckTest { 7 | 8 | @Test 9 | public void verify() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/sobriety/ThriftyGeolocationCheck.java") 11 | .withChecks(new ThriftyGeolocationMinTimeRule(), new ThriftyGeolocationMinDistanceRule()) 12 | .verifyIssues(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/sobriety/ThriftyMotionSensorRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.sobriety; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class ThriftyMotionSensorRuleTest { 7 | 8 | @Test 9 | public void verify() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/sobriety/ThriftyMotionSensorCheck.java") 11 | .withCheck(new ThriftyMotionSensorRule()) 12 | .verifyIssues(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/sobriety/ThriftyNotificationRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.sobriety; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class ThriftyNotificationRuleTest { 7 | 8 | @Test 9 | public void verify() { 10 | 11 | JavaCheckVerifier.newVerifier().onFile("src/test/files/sobriety/ThriftyNotificationCheckBuilder.java") 12 | .withCheck(new ThriftyNotificationRule()) 13 | .verifyIssues(); 14 | 15 | JavaCheckVerifier.newVerifier().onFile("src/test/files/sobriety/ThriftyNotificationCheckChannel.java") 16 | .withCheck(new ThriftyNotificationRule()) 17 | .verifyIssues(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/sobriety/TorchFreeRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.sobriety; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class TorchFreeRuleTest { 7 | 8 | @Test 9 | public void verify() { 10 | JavaCheckVerifier.newVerifier().onFile("src/test/files/sobriety/TorchFreeCheck.java") 11 | .withCheck(new TorchFreeRule()) 12 | .verifyIssues(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/java/checks/sobriety/VibrationFreeRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.java.checks.sobriety; 2 | 3 | import org.junit.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class VibrationFreeRuleTest { 7 | 8 | @Test 9 | public void verify() { 10 | 11 | JavaCheckVerifier.newVerifier().onFiles("src/test/files/sobriety/VibrationFreeCheckContext.java", "src/test/files/sobriety/VibrationFreeCheckActivity.java") 12 | .withChecks(new VibrationFreeRule(), new VibrationFreeRule()) 13 | .verifyIssues(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/xml/checks/batch/ServiceBootTimeXmlRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.xml.checks.batch; 2 | 3 | import org.junit.Test; 4 | import org.sonarsource.analyzer.commons.xml.checks.SonarXmlCheckVerifier; 5 | 6 | public class ServiceBootTimeXmlRuleTest { 7 | 8 | @Test 9 | public void attributePresentTrue() { 10 | SonarXmlCheckVerifier.verifyIssues("ServiceBootTimeXmlCheck.xml", new ServiceBootTimeXmlRule()); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/xml/checks/idleness/KeepCpuOnXmlRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.xml.checks.idleness; 2 | 3 | import org.junit.Test; 4 | import org.sonarsource.analyzer.commons.xml.checks.SonarXmlCheckVerifier; 5 | 6 | public class KeepCpuOnXmlRuleTest { 7 | 8 | @Test 9 | public void attributePresentTrue() { 10 | SonarXmlCheckVerifier.verifyIssues("KeepCpuOnXmlCheckReport.xml", new KeepCpuOnXmlRule()); 11 | } 12 | 13 | @Test 14 | public void attributePresentFalse() { 15 | SonarXmlCheckVerifier.verifyNoIssue("KeepCpuOnXmlCheckNoReport.xml", new KeepCpuOnXmlRule()); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/xml/checks/idleness/KeepScreenOnXmlRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.xml.checks.idleness; 2 | 3 | import org.junit.Test; 4 | import org.sonarsource.analyzer.commons.xml.checks.SonarXmlCheckVerifier; 5 | 6 | public class KeepScreenOnXmlRuleTest { 7 | 8 | @Test 9 | public void attributePresentTrue() { 10 | SonarXmlCheckVerifier.verifyIssues("KeepScreenOnXmlCheckTrue.xml", new KeepScreenOnXmlRule()); 11 | } 12 | 13 | @Test 14 | public void attributePresentFalse() { 15 | SonarXmlCheckVerifier.verifyNoIssue("KeepScreenOnXmlCheckFalse.xml", new KeepScreenOnXmlRule()); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/xml/checks/power/ChargeAwarenessXmlRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.xml.checks.power; 2 | 3 | import org.junit.Test; 4 | import org.sonarsource.analyzer.commons.xml.checks.SonarXmlCheckVerifier; 5 | 6 | public class ChargeAwarenessXmlRuleTest { 7 | 8 | @Test 9 | public void attributePresentTrue() { 10 | SonarXmlCheckVerifier.verifyIssues("ChargeAwarenessXmlCheck.xml", new ChargeAwarenessXmlRule()); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/xml/checks/power/CompagnionInBackgroundXmlRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.xml.checks.power; 2 | 3 | import org.junit.Test; 4 | import org.sonarsource.analyzer.commons.xml.checks.SonarXmlCheckVerifier; 5 | 6 | public class CompagnionInBackgroundXmlRuleTest { 7 | 8 | @Test 9 | public void attributePresentTrue() { 10 | SonarXmlCheckVerifier.verifyIssues("CompagnionInBackgroundXmlCheck.xml", new CompagnionInBackgroundXmlRule()); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/xml/checks/power/IgnoreBatteryOptimizationsXmlRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.xml.checks.power; 2 | 3 | import org.junit.Test; 4 | import org.sonarsource.analyzer.commons.xml.checks.SonarXmlCheckVerifier; 5 | 6 | public class IgnoreBatteryOptimizationsXmlRuleTest { 7 | 8 | @Test 9 | public void attributePresentTrue() { 10 | SonarXmlCheckVerifier.verifyIssues("IgnoreBatteryOptimizationsXmlCheckReport.xml", new IgnoreBatteryOptimizationsXmlRule()); 11 | } 12 | 13 | @Test 14 | public void attributePresentFalse() { 15 | SonarXmlCheckVerifier.verifyNoIssue("IgnoreBatteryOptimizationsXmlCheckNoReport.xml", new IgnoreBatteryOptimizationsXmlRule()); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/xml/checks/power/SaveModeAwarenessXmlRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.xml.checks.power; 2 | 3 | import org.junit.Test; 4 | import org.sonarsource.analyzer.commons.xml.checks.SonarXmlCheckVerifier; 5 | 6 | public class SaveModeAwarenessXmlRuleTest { 7 | 8 | @Test 9 | public void attributePresentTrue() { 10 | SonarXmlCheckVerifier.verifyIssues("SaveModeAwarenessXmlCheck.xml", new SaveModeAwarenessXmlRule()); 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/xml/checks/sobriety/DarkUIBrightColorsXmlRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.xml.checks.sobriety; 2 | 3 | import org.junit.Test; 4 | import org.sonarsource.analyzer.commons.xml.checks.SonarXmlCheckVerifier; 5 | 6 | public class DarkUIBrightColorsXmlRuleTest { 7 | 8 | @Test 9 | public void colorCheck() { 10 | SonarXmlCheckVerifier.verifyIssues("DarkUIBrightColorsXmlCheck.xml", new DarkUIBrightColorsXmlRule()); 11 | } 12 | 13 | @Test 14 | public void colorResourceCheck() { 15 | SonarXmlCheckVerifier.verifyIssues("DarkUIBrightColorsXmlCheckResources.xml", new DarkUIBrightColorsXmlRule()); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/java/io/ecocode/xml/checks/sobriety/DarkUIThemeXmlRuleTest.java: -------------------------------------------------------------------------------- 1 | package io.ecocode.xml.checks.sobriety; 2 | 3 | import org.junit.Test; 4 | import org.sonarsource.analyzer.commons.xml.checks.SonarXmlCheckVerifier; 5 | 6 | public class DarkUIThemeXmlRuleTest { 7 | 8 | @Test 9 | public void styleCheck() { 10 | SonarXmlCheckVerifier.verifyIssues("DarkUIThemeXmlCheckStyle.xml", new DarkUIThemeXmlRule()); 11 | } 12 | 13 | @Test 14 | public void manifestCheck() { 15 | SonarXmlCheckVerifier.verifyIssues("DarkUIThemeXmlCheckManifest.xml", new DarkUIThemeXmlRule()); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/checks/CompagnionInBackgroundXmlRule/CompagnionInBackgroundXmlCheck.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/checks/DarkUIBrightColorsXmlRule/DarkUIBrightColorsXmlCheckResources.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFFFFF 4 | #000000 5 | #FFBB86FC 6 | #FF6200EE 7 | #FF3700B3 8 | #FF03DAC5 9 | #FF018786 10 | #FF000000 11 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/checks/IgnoreBatteryOptimizationsXmlRule/IgnoreBatteryOptimizationsXmlCheckNoReport.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/checks/IgnoreBatteryOptimizationsXmlRule/IgnoreBatteryOptimizationsXmlCheckReport.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/checks/KeepCpuOnXmlRule/KeepCpuOnXmlCheckNoReport.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/checks/KeepCpuOnXmlRule/KeepCpuOnXmlCheckReport.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/checks/KeepScreenOnXmlRule/KeepScreenOnXmlCheckFalse.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/checks/KeepScreenOnXmlRule/KeepScreenOnXmlCheckTrue.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/checks/ServiceBootTimeXmlRule/ServiceBootTimeXmlCheck.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/codenarc/exportProfile/exportEscapedParameters.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/codenarc/exportProfile/exportFixedRules.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/codenarc/exportProfile/exportNullParameters.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/codenarc/exportProfile/exportParameters.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/codenarc/exportProfile/exportProfile.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/codenarc/parsing/Sample.groovy: -------------------------------------------------------------------------------- 1 | 2 | class Sample { 3 | String format(Integer i) { 4 | i.toString() 5 | } 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | // file is pretty long 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/codenarc/parsing/line-number-not-specified.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/foundation/Error.groovy: -------------------------------------------------------------------------------- 1 | class Error { 2 | def name# 3 | def missing 4 | } 5 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/foundation/Greet.groovy: -------------------------------------------------------------------------------- 1 | class Greet { 2 | def name 3 | Greet(who) { name = who } 4 | def salute() { println "Hello $name and $name!" } 5 | } 6 | 7 | /** 8 | * Javadoc style 9 | */ 10 | @groovy.beans.Bindable 11 | class Cool { 12 | double x = 1.4 // Comment 13 | } 14 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/gmetrics/Greeting.groovy: -------------------------------------------------------------------------------- 1 | /** 2 | * Header Comment 3 | * plop 4 | */ 5 | package example; 6 | 7 | class Greeting { 8 | 9 | def void sayHello() { 10 | if (true) { 11 | print "Hello world!" 12 | } else { 13 | } 14 | } 15 | 16 | } 17 | 18 | class OneMoreClass { //comment line 19 | 20 | def void sayHello() { 21 | /* 22 | * Multi-line comment 23 | * 24 | * with empty lines. 25 | */ 26 | if (true) { 27 | // 28 | print "Hello world!" 29 | } else { 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/jacoco/Hello$InnerClass.class.toCopy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/android-plugin/src/test/resources/org/sonar/plugins/groovy/jacoco/Hello$InnerClass.class.toCopy -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/jacoco/Hello.class.toCopy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/android-plugin/src/test/resources/org/sonar/plugins/groovy/jacoco/Hello.class.toCopy -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/jacoco/JaCoCoSensor_0_7_4/jacoco-ut.exec: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/android-plugin/src/test/resources/org/sonar/plugins/groovy/jacoco/JaCoCoSensor_0_7_4/jacoco-ut.exec -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/jacoco/JaCoCoSensor_0_7_4/readme.txt: -------------------------------------------------------------------------------- 1 | Coverage generated using 2 | 3 | mvn clean install 4 | 5 | on project : 6 | 7 | https://github.com/SonarSource/sonar-examples/tree/master/projects/languages/groovy/groovy-sonar-runner-jacoco 8 | 9 | based on commit 10 | 11 | 052dda3ea6c7bfb61e0f7e6cb7b396b7d1d4a92a -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/jacoco/JaCoCoSensor_0_7_5/jacoco-ut.exec: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/android-plugin/src/test/resources/org/sonar/plugins/groovy/jacoco/JaCoCoSensor_0_7_5/jacoco-ut.exec -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/jacoco/JaCoCoSensor_0_7_5/readme.txt: -------------------------------------------------------------------------------- 1 | Coverage generated using 2 | 3 | mvn clean install -Djacoco.version=0.7.5.201505241946 4 | 5 | on project : 6 | 7 | https://github.com/SonarSource/sonar-examples/tree/master/projects/languages/groovy/groovy-sonar-runner-jacoco 8 | 9 | based on commit 10 | 11 | 052dda3ea6c7bfb61e0f7e6cb7b396b7d1d4a92a -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/jacoco/JaCoCo_incompatible_merge/jacoco-0.7.4.exec: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/android-plugin/src/test/resources/org/sonar/plugins/groovy/jacoco/JaCoCo_incompatible_merge/jacoco-0.7.4.exec -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/jacoco/JaCoCo_incompatible_merge/jacoco-0.7.5.exec: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/android-plugin/src/test/resources/org/sonar/plugins/groovy/jacoco/JaCoCo_incompatible_merge/jacoco-0.7.5.exec -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/jacoco/JaCoCo_incompatible_merge/jacoco-it-0.7.4.exec: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/android-plugin/src/test/resources/org/sonar/plugins/groovy/jacoco/JaCoCo_incompatible_merge/jacoco-it-0.7.4.exec -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/jacoco/JaCoCo_incompatible_merge/jacoco-it-0.7.5.exec: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/android-plugin/src/test/resources/org/sonar/plugins/groovy/jacoco/JaCoCo_incompatible_merge/jacoco-it-0.7.5.exec -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/surefire/SurefireSensorTest/roundingTests/TEST-Rounding.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/surefire/SurefireSensorTest/shouldHandleTestSuiteDetails/ExtensionsFinderTest2-expected-result.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/surefire/SurefireSensorTest/shouldHandleTestSuiteDetails/ExtensionsFinderTest3-expected-result.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | -------------------------------------------------------------------------------- /src/android-plugin/src/test/resources/org/sonar/plugins/groovy/surefire/api/SurefireUtilsTest/shouldGetReportsFromProperty/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | fake.group 5 | fake.artifactId 6 | jar 7 | 1.0-SNAPSHOT 8 | 9 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.bat eol=crlf -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # / 3 | /.classpath 4 | /.settings 5 | /.project 6 | /hamlet_docs 7 | /*.patch 8 | /*.iws 9 | *.iml 10 | /*.ipr 11 | /AntBuilderTestXmlReport.xml 12 | /*.html 13 | /target 14 | /AntBuilderTestTextReport.txt 15 | /CodeNarcReport.txt 16 | /CodeNarcXmlReport.xml 17 | /*CodeNarcReport.xml 18 | /.idea 19 | build/ 20 | src/main/java/META-INF/ 21 | /.gradle 22 | /classes 23 | /out 24 | /integration-test/out/test/classes 25 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/.travis.yml: -------------------------------------------------------------------------------- 1 | language: groovy 2 | sudo: required 3 | install: true 4 | 5 | jdk: 6 | - openjdk8 7 | - openjdk11 8 | - openjdk14 9 | 10 | before_cache: 11 | - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock 12 | - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ 13 | cache: 14 | directories: 15 | - $HOME/.gradle/caches/ 16 | - $HOME/.gradle/wrapper/ 17 | 18 | script: 19 | - ./gradlew check --no-daemon 20 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/NOTICE.txt: -------------------------------------------------------------------------------- 1 | ====================================================================== 2 | == NOTICE file corresponding to section 4 d of the Apache License, == 3 | == Version 2.0, in this case for the CodeNarc distribution. == 4 | ====================================================================== 5 | 6 | This product includes software developed by 7 | the Apache Software Foundation (http://www.apache.org). 8 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/docker/README.md: -------------------------------------------------------------------------------- 1 | # README for CodeNarc Dockerfile 2 | 3 | To build the image: 4 | 5 | docker build -t codenarc . 6 | # or 7 | docker build -t codenarc --build-arg CODENARC_VERSION=1.6.1 --build-arg GROOVY_VERSION=3.0.6 . 8 | 9 | To run: 10 | 11 | docker run --rm -v `pwd`:/ws --user `id -u`:`id -g` codenarc 12 | 13 | # or (assumes there is a "codenarc.ruleset" file in the current directory) 14 | docker run --rm -v `pwd`:/ws --user `id -u`:`id -g` codenarc -report=json -rulesetfiles=file:codenarc.ruleset 15 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/docs/CNAME: -------------------------------------------------------------------------------- 1 | codenarc.org -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/docs/_config.yml: -------------------------------------------------------------------------------- 1 | name: CodeNarc 2 | markdown: kramdown 3 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/docs/_data/navigation.yml: -------------------------------------------------------------------------------- 1 | sidebar-nav: 2 | - title: "General" 3 | children: 4 | - title: "Home" 5 | url: http://codenarc.org 6 | - title: "Downloads" 7 | url: https://github.com/CodeNarc/CodeNarc/releases 8 | - title: "GitHub Project" 9 | url: https://github.com/CodeNarc 10 | - title: "Running" 11 | children: 12 | - title: "Ant Task Usage" 13 | url: / 14 | - title: "Command-line" 15 | url: / 16 | - title: "Run as a Test" 17 | url: / 18 | - title: "Other Tools/Frameworks" 19 | url: / 20 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/docs/images/codenarc-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/codenarc-converter/CodeNarc/docs/images/codenarc-logo.png -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/docs/images/forkme_right_red_aa0000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/codenarc-converter/CodeNarc/docs/images/forkme_right_red_aa0000.png -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/gradle.properties: -------------------------------------------------------------------------------- 1 | ossrhUsername = undefined 2 | ossrhPassword = undefined 3 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/codenarc-converter/CodeNarc/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.2-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/integration-test/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'groovy' 3 | id 'idea' 4 | } 5 | 6 | repositories { 7 | mavenCentral() 8 | } 9 | 10 | dependencies { 11 | testImplementation project(':'), { 12 | exclude group: 'org.codehaus.groovy' 13 | } 14 | testImplementation gradleTestKit() 15 | testImplementation 'junit:junit:4.12' 16 | } 17 | 18 | test { 19 | systemProperty 'codenarc.test.projectPath', rootProject.projectDir.absolutePath 20 | } -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/settings.gradle: -------------------------------------------------------------------------------- 1 | include 'integration-test' 2 | 3 | rootProject.name = 'CodeNarc' 4 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/main/resources/codenarc-rule-extrainfo.properties: -------------------------------------------------------------------------------- 1 | # Optional extra information display next to rule names in the rule index and sample rule sets 2 | AbcMetric = Requires the GMetrics jar 3 | CrapMetric = Requires the GMetrics jar and a Cobertura coverage file 4 | CyclomaticComplexity = Requires the GMetrics jar 5 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/main/resources/codenarc-version.txt: -------------------------------------------------------------------------------- 1 | 2.2.3 2 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/main/resources/rulesets/braces.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | Braces rule set. 8 | These rules implement standards and best practices related to using braces. 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/main/resources/rulesets/dry.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | Dry rule set. 8 | These rules check for duplicate code, enforcing the DRY (Don't Repeat Yourself) principle. 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/main/resources/rulesets/ecocode.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | EcoCode rule set. 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/main/resources/rulesets/jdbc.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | JDBC rule set. 8 | These rules check for JDBC-specific violations. 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/main/resources/rulesets/serialization.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | Serialization rule set. 8 | These rules check for Java serialization-specific violations. 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/main/resources/templates/StarterRuleSet-AllRules.groovy.template: -------------------------------------------------------------------------------- 1 | ruleset { 2 | 3 | description ''' 4 | A Sample Groovy RuleSet containing all CodeNarc Rules 5 | You can use this as a template for your own custom RuleSet. 6 | Just delete the rules that you don't want to include. 7 | ''' 8 | 9 | <% rules.each { rule -> def extraInfo = ruleExtraInformation[rule.name] ? " // ${ruleExtraInformation[rule.name]}" : '' %>${rule.name} ${extraInfo} 10 | <% } %> 11 | } -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/main/resources/templates/StarterRuleSet-AllRulesByCategory.groovy.template: -------------------------------------------------------------------------------- 1 | ruleset { 2 | 3 | description ''' 4 | A Sample Groovy RuleSet containing all CodeNarc Rules, grouped by category. 5 | You can use this as a template for your own custom RuleSet. 6 | Just delete the rules that you don't want to include. 7 | ''' 8 | 9 | <% ruleSets.each { name, rules -> %>// ${name} 10 | <% rules.each { rule -> def extraInfo = ruleExtraInformation[rule.name] ? " // ${ruleExtraInformation[rule.name]}" : '' %>${rule.name} ${extraInfo} 11 | <% } %> 12 | <% } %> 13 | } -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/main/resources/templates/codenarc-rule-index-by-name.md.template: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: CodeNarc - Rule Index by Name 4 | --- 5 | 6 | # Rule Index by Name 7 | 8 | **CodeNarc** includes ${numberOfRules} rules. 9 | 10 | ## Rules 11 | <% ruleToRuleSetMap.each { rule, ruleSetName -> def extraInfo = ruleExtraInformation[rule.name] ? " (${ruleExtraInformation[rule.name]})" : '' %>\ 12 | * [${rule.name}](./codenarc-rules-${ruleSetName}.html#${rule.name.toLowerCase()}-rule) ${extraInfo} 13 | <% } %> 14 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/main/resources/templates/codenarc-rule-index.apt.template: -------------------------------------------------------------------------------- 1 | -------------------------------------------------- 2 | CodeNarc - Rule Index 3 | -------------------------------------------------- 4 | 5 | Rule Index 6 | ~~~~~~~~~~ 7 | <> includes ${numberOfRules} rules. 8 | 9 | <% ruleSets.each { name, rules -> %> 10 | <% def ruleSetLink = "./codenarc-rules-${name}.html" %> 11 | <% def capitalizedName = name.capitalize() %> 12 | * {{{$ruleSetLink}$capitalizedName}} 13 | <% rules.each { rule -> %> 14 | <% def extraInfo = ruleExtraInformation[rule.name] ? " (${ruleExtraInformation[rule.name]})" : '' %> 15 | * {{{./codenarc-rules-${name}.html#${rule.name}}${rule.name}}} ${extraInfo} 16 | <% } %> 17 | <% } %> 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/main/resources/templates/codenarc-rule-index.md.template: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: CodeNarc - Rule Index 4 | --- 5 | 6 | # Rule Index 7 | 8 | **CodeNarc** includes ${numberOfRules} rules. 9 | <% ruleSets.each { name, rules ->\ 10 | def ruleSetLink = "./codenarc-rules-${name}.html" 11 | def capitalizedName = name.capitalize() %> 12 | ## [$capitalizedName]($ruleSetLink) 13 | <% rules.each { rule -> def extraInfo = ruleExtraInformation[rule.name] ? " (${ruleExtraInformation[rule.name]})" : '' %>\ 14 | * [${rule.name}](./codenarc-rules-${name}.html#${rule.name.toLowerCase()}-rule) ${extraInfo} 15 | <% } } %> 16 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/SampleFile.groovy: -------------------------------------------------------------------------------- 1 | class SampleFile { 2 | 3 | } 4 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/SampleInvalidFile.txt: -------------------------------------------------------------------------------- 1 | %^&^% -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/codenarc-messages.properties: -------------------------------------------------------------------------------- 1 | # Custom Messages ResourceBundle file for testing. See HtmlReportWriterTest 2 | # WARNING: Do not changes the values within this file 3 | 4 | MyRuleXX.description=My Rule XX 5 | MyRuleXX.description.html=HTML Rule XX 6 | 7 | MyRuleYY.description = My Rule YY 8 | 9 | abc=123 10 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/codenarc.properties: -------------------------------------------------------------------------------- 1 | # Test-only properties - Used by PropertiesFileRuleSetConfigurerTest, CodeNarcTaskTest and CodeNarcTaskAllRuleSetsTest 2 | 3 | # PropertiesFileRuleSetConfigurerTest 4 | rule1.priority=3 5 | rule2.violationMessage = violation 6 | other.priority = 1 7 | rule2.other.form = ignore this 8 | 9 | # CodeNarcTaskTest 10 | TestPath.priority=3 11 | #TestPath.description=problem 12 | 13 | # CodeNarcTaskAllRuleSetsTest 14 | StatelessClass.enabled = false 15 | DuplicateNumberLiteral.enabled = false 16 | DuplicateStringLiteral.enabled = false 17 | UnnecessaryGetter.enabled = false -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/disable-rules-in-comments/Sample.groovy: -------------------------------------------------------------------------------- 1 | class MyClass { // codenarc-disable 2 | 3 | def maxValue = 10 4 | /* codenarc-enable */ 5 | 6 | def myMethod(def name) { // codenarc-disable NoDef 7 | def other = 123 8 | // codenarc-enable NoDef 9 | 10 | /* codenarc-disable NoDef, Println */ 11 | println other 12 | /* codenarc-enable NoDef, Println */ 13 | 14 | println "name=$name" /*codenarc-disable-line*/ 15 | } 16 | 17 | private void doStuff() { // codenarc-disable-line NoDef 18 | 19 | // codenarc-disable R1, R2, R3, R4, NoDef 20 | def count = 99 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/disable-rules-in-comments/disabling-rules.ruleset: -------------------------------------------------------------------------------- 1 | ruleset { 2 | description 'CodeNarc ruleset for testing disabling rules within comments' 3 | 4 | Println 5 | NoDef 6 | 7 | } -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/override-codenarc.properties: -------------------------------------------------------------------------------- 1 | # Test-only properties - Used by PropertiesFileRuleSetConfigurerTest 2 | 3 | # PropertiesFileRuleSetConfigurerTest 4 | rule1.priority=2 5 | rule2.violationMessage = override 6 | other.priority = 1 7 | rule2.other.form = ignore this 8 | 9 | # Not allowed to override rule name 10 | rule2.name = NewName_IgnoreThis 11 | 12 | # CodeNarcTaskTest 13 | TestPath.priority=3 14 | #TestPath.description=problem -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/resource/SampleResource.txt: -------------------------------------------------------------------------------- 1 | abcdef12345 -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/rule/DoNothingRule.txt: -------------------------------------------------------------------------------- 1 | import org.codenarc.rule.AbstractRule 2 | import org.codenarc.rule.Violation 3 | import org.codenarc.source.SourceCode 4 | 5 | class DoNothingRule extends AbstractRule { 6 | String name = 'DoNothing' 7 | int priority = 2 8 | 9 | void applyTo(SourceCode sourceCode, List violations) { 10 | // Do nothing 11 | } 12 | } -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/rule/DoesNotCompileRule.txt: -------------------------------------------------------------------------------- 1 | import org.codenarc.rule.AbstractRule 2 | import org.codenarc.rule.Violation 3 | import org.codenarc.source.SourceCode 4 | 5 | class DoesNotCompileRule extends AbstractRule { 6 | String name = 'DoNothing' 7 | int priority = 2 8 | 9 | void applyTo(SourceCode sourceCode, List violations) { 10 | &^%$%^ This definitely won't compile 11 | } 12 | } -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/rule/NotARule.txt: -------------------------------------------------------------------------------- 1 | class NotARule { 2 | String name = 'DoNothing' 3 | int priority = 2 4 | } -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/rulesets/CustomRuleSet.groovy: -------------------------------------------------------------------------------- 1 | ruleset { 2 | description 'A custom Groovy RuleSet (see CodeNarcTask_CustomRuleSetTest)' 3 | 4 | CyclomaticComplexity { 5 | maxMethodComplexity = 1 6 | } 7 | 8 | ClassName 9 | 10 | MethodName 11 | 12 | ConfusingTernary(priority:3) 13 | 14 | StatelessClass { 15 | name = 'StatelessDao' 16 | applyToClassNames = '*Dao' 17 | } 18 | 19 | // Old style 20 | rule(org.codenarc.rule.basic.ThrowExceptionFromFinallyBlockRule) { 21 | priority = 3 22 | } 23 | ruleset('rulesets/dry.xml') 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/rulesets/GroovyRuleSet1.groovy: -------------------------------------------------------------------------------- 1 | // Example Groovy RuleSet for testing 2 | 3 | 4 | import org.codenarc.rule.basic.ThrowExceptionFromFinallyBlockRule 5 | 6 | ruleset { 7 | description 'A sample Groovy RuleSet' 8 | 9 | ruleset('rulesets/RuleSet4.xml') { 10 | 'CatchThrowable' { 11 | priority = 1 12 | enabled = false 13 | } 14 | include 'CatchThrowable' 15 | } 16 | 17 | rule(ThrowExceptionFromFinallyBlockRule) { 18 | priority = 3 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/rulesets/GroovyRuleSet1.txt: -------------------------------------------------------------------------------- 1 | // Example Groovy RuleSet for testing 2 | 3 | import org.codenarc.rule.basic.ThrowExceptionFromFinallyBlockRule 4 | 5 | ruleset { 6 | description 'A sample Groovy RuleSet' 7 | 8 | ruleset('rulesets/RuleSet4.xml') { 9 | 'CatchThrowable' { 10 | priority = 1 11 | enabled = false 12 | } 13 | include 'CatchThrowable' 14 | } 15 | 16 | rule(ThrowExceptionFromFinallyBlockRule) { 17 | priority = 3 18 | } 19 | } -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/rulesets/GroovyRuleSet2.txt: -------------------------------------------------------------------------------- 1 | // Example Groovy RuleSet for testing 2 | 3 | import org.codenarc.rule.basic.ThrowExceptionFromFinallyBlockRule 4 | 5 | ruleset { 6 | 7 | ruleset('rulesets/GroovyRuleSet1.txt') { 8 | 'CatchThrowable' { 9 | priority = 3 10 | } 11 | } 12 | 13 | rule(org.codenarc.rule.generic.StatelessClassRule) { 14 | addToIgnoreFieldNames = '*Test*' 15 | } 16 | } -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/rulesets/GroovyRuleSet_Bad.txt: -------------------------------------------------------------------------------- 1 | // Example Groovy RuleSet for testing 2 | 3 | import org.codenarc.rule.basic.ThrowExceptionFromFinallyBlockRule 4 | 5 | ruleset { 6 | description 'A sample Groovy RuleSet' 7 | 8 | rule(ThrowExceptionFromFinallyBlockRule) { 9 | priority = 3 10 | noSuchProperty = 'abc' 11 | } 12 | } -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/rulesets/JsonRuleSet1.json: -------------------------------------------------------------------------------- 1 | { 2 | "ExplicitCallToEqualsMethod": { "priority": 2}, 3 | "Println": { }, 4 | "SpaceAroundMapEntryColon": { "enabled" : false } 5 | } -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/rulesets/NestedRuleSet1.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/rulesets/RuleSet1.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/rulesets/RuleSet2.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/rulesets/RuleSet3.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/rulesets/RuleSet4.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/rulesets/WeirdCharsRuleSet-,#.txt: -------------------------------------------------------------------------------- 1 | // Example Groovy RuleSet for testing 2 | 3 | import org.codenarc.rule.basic.ThrowExceptionFromFinallyBlockRule 4 | 5 | ruleset { 6 | description 'A Groovy RuleSet whose filename contains weird, problematic characters' 7 | 8 | EmptyClass 9 | 10 | } -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/source/SomeOtherFile.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/codenarc-converter/CodeNarc/src/test/resources/source/SomeOtherFile.txt -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/source/SourceFile1.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package source 17 | 18 | /** 19 | * Source file for testing 20 | * 21 | * @author Chris Mair 22 | */ 23 | class SourceFile1 { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/sourcewithdirs/SourceFile1.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package sourcewithdirs 17 | 18 | /** 19 | * Source file for testing 20 | * 21 | * @author Chris Mair 22 | */ 23 | class SourceFile1 { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/sourcewithdirs/subdir1/Subdir1File1.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package sourcewithdirs.subdir1 17 | 18 | /** 19 | * Source file for testing 20 | * 21 | * @author Chris Mair 22 | */ 23 | class Subdir1File1 { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/sourcewithdirs/subdir1/Subdir1File2.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package sourcewithdirs.subdir1 17 | 18 | /** 19 | * Source file for testing 20 | * 21 | * @author Chris Mair 22 | */ 23 | class Subdir1File2 { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/sourcewithdirs/subdir2/Subdir2File1.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package sourcewithdirs.subdir2 17 | 18 | /** 19 | * Source file for testing 20 | * 21 | * @author Chris Mair 22 | */ 23 | class Subdir2File1 { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/sourcewithdirs/subdir2/subdir2b/NotAGroovyFile.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/codenarc-converter/CodeNarc/src/test/resources/sourcewithdirs/subdir2/subdir2b/NotAGroovyFile.txt -------------------------------------------------------------------------------- /src/codenarc-converter/CodeNarc/src/test/resources/sourcewitherrors/SourceFile1.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2008 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package sourcewitherrors 17 | 18 | /** 19 | * Source file for testing 20 | * 21 | * @author Chris Mair 22 | */ 23 | class SourceFile1 { 24 | 25 | String name 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/ecolinter-plugin/src/main/resources/fr/cnumr/l10n/ecolint/rules/stylelint/greenit.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "key": "greenit/avoid-animation", 4 | "name": "Avoid too many js/css animation", 5 | "url": "https://github.com/cnumr/ecoLinter/blob/wallaby-dev/docs/rules/css/avoid-animation.md", 6 | "tags": [ 7 | "eco-conception" 8 | ] 9 | } 10 | ] -------------------------------------------------------------------------------- /src/images/5ekko.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/images/5ekko.png -------------------------------------------------------------------------------- /src/images/img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/images/img.png -------------------------------------------------------------------------------- /src/images/img_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/images/img_1.png -------------------------------------------------------------------------------- /src/images/img_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/images/img_2.png -------------------------------------------------------------------------------- /src/images/img_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/images/img_3.png -------------------------------------------------------------------------------- /src/images/img_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/images/img_4.png -------------------------------------------------------------------------------- /src/images/img_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/images/img_5.png -------------------------------------------------------------------------------- /src/images/img_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cnumr/ecoCode/f3c79f4fc728b2f2e575981efcec1d4a49b2dd16/src/images/img_6.png -------------------------------------------------------------------------------- /src/java-plugin/README.md: -------------------------------------------------------------------------------- 1 | https://github.com/SonarSource/sonar-java/blob/master/docs/CUSTOM_RULES_101.md -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/AMIES.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Avoid multiple if-else statement", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/D4.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Avoid using global variables", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/GRC1.html: -------------------------------------------------------------------------------- 1 |

Using Spring repository in loop induced unnecessary calculation by the cpu so unless energy consumption.

2 |

Noncompliant Code Example

3 |
 4 | 		private final List<Integer> ids = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
 5 | 
 6 | 		List<Employee> employees = new ArrayList<>();
 7 | 		
 8 | 		for (Integer id: ids) {
 9 |             Optional<Employee> employee = employeeRepository.findById(id); // Noncompliant
10 |             if (employee.isPresent()) {
11 |                 employees.add(employee.get());
12 |             }
13 |         }
14 | 
15 | 
16 |

Compliant Solution

17 |
18 | 		private final List<Integer> ids = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
19 | 		List<Employee> employees = employeeRepository.findAllById(ids);
20 | 
21 | -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/GRC1.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Avoid Spring repository call in loop", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "50min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/GRPS0027.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Use System.arraycopy to copy arrays", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "20min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/GRSP0028.html: -------------------------------------------------------------------------------- 1 |

Optimize read file exception

2 |

Noncompliant Code Example

3 |
 4 | 		public void readPreferences(String filename) {
 5 | 		  //...
 6 | 		  InputStream in = null;
 7 | 		  try {
 8 | 			in = new FileInputStream(filename);
 9 | 		  } catch (FileNotFoundException e) {
10 | 			logger.log(e);
11 | 		  }
12 | 		  in.read(...);
13 | 		  //...
14 | 		}
15 | 
16 | 
17 |

Compliant Solution

18 |
19 | 		public void readPreferences(String filename)
20 | 			throws IllegalArgumentException,
21 | 				   FileNotFoundException, IOException {
22 | 		  if (filename == null) {
23 | 			throw new IllegalArgumentException ("filename is null");
24 | 		  }  //if
25 | 		  //...
26 | 		  InputStream in = new FileInputStream(filename);
27 | 		  //...
28 | 		}
29 | 
30 | -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/GRSP0028.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Optimize read file exceptions", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } 14 | -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/GRSP0032.html: -------------------------------------------------------------------------------- 1 |

2 | If you know in advance how many characters would be appended, initialize builder/buffer with the appropriate size. 3 | They will thus never have to be resized, It saves CPU cycles so unless energy consumption. 4 |

5 |

Noncompliant Code Example

6 |
 7 |     StringBuilder sb = new StringBuilder(); // Noncompliant
 8 |     for (int i = 0; i < 100; i++) {
 9 |        sb.append(...);
10 |     }
11 | 
12 |

Compliant Solution

13 |
14 |     StringBuilder sb = new StringBuilder(100);
15 |     for (int i = 0; i < 100; i++) {
16 |        sb.append(...);
17 |     }
18 | 
19 | -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/GRSP0032.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Initialize builder/buffer with the appropriate size", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/GSCIL.html: -------------------------------------------------------------------------------- 1 |

While iterating through any collection get the size of the collection beforehand and never get it during iteration, It saves CPU cycles so unless energy consumption. The sample is provided below as an illustration which is to be avoided as follows.

2 |

Noncompliant Code Example

3 |
 4 | 		List<String> objList = getData();
 5 | 
 6 |         for (int i = 0; i < objList.size(); i++) {
 7 |             // execute code
 8 |         }
 9 | 
10 | 
11 |

Compliant Solution

12 |
13 |         List<String> objList = getData();
14 | 
15 |         int size = objList.size();
16 |         for (int i = 0; i < size; i++) {
17 |             // execute code
18 |         }
19 | 
20 | -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/GSCIL.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Avoid getting the size of the collection in the loop", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/S53.html: -------------------------------------------------------------------------------- 1 |

Using List instead of Arrays with Foreach save CPU cycles calculations and RAM consumption.

2 |

Noncompliant Code Example

3 |
 4 | 		private final Integer[] intArray = new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
 5 | 
 6 | 		for (Integer i : intArray) {
 7 | 			...
 8 | 		}
 9 | 
10 | 
11 |

Compliant Solution

12 |
13 | 		private final List<Integer> intList = Arrays.asList(new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
14 | 
15 | 		for (Integer i : intList) {
16 | 			...
17 | 		}
18 | 
19 | -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/S53.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Avoid the use of Foreach with Arrays", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/S63.html: -------------------------------------------------------------------------------- 1 |

Do not unnecessarily assign values to variables. It increase unless RAM memory usage.

2 |

Noncompliant Code Example

3 |
 4 | String var1 = getValue();
 5 | return var1;
 6 | 
 7 | String var2 = "hello"
 8 | var2 = "world"        //Non compliant cause never assigned 
 9 | 
10 | 
11 |

Compliant Solution

12 |
return getValue();
13 | -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/S63.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Do not unnecessarily assign values to variables", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/S67.html: -------------------------------------------------------------------------------- 1 |

The form $i++ creates a temporary variable whereas ++$i does not. It save CPU cycles.

2 |

Noncompliant Code Example

3 |
4 | i++
5 | 
6 |

Compliant Solution

7 |
++i
8 | -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/S67.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Use ++i instead of i++", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/S69.html: -------------------------------------------------------------------------------- 1 |

Do not call a function when declaring a for-type loop in order to avoid function calls each iterations. It saves CPU cycles.

2 |

Noncompliant Code Example

3 |
 4 |     public void foo() {
 5 |         for (int i = 0; i < getMyValue(); i++) {  // Noncompliant
 6 |             System.out.println(i);
 7 |             boolean b = getMyValue() > 6;
 8 |         }
 9 |     }
10 | 
11 | 
12 |

Compliant Solution

13 |
14 | 
15 |     public void foo() {
16 |         int myValue =  getMyValue();
17 |         for (int i = 0; i < myValue; i++) {
18 |             System.out.println(i);
19 |             boolean b = getMyValue() > 6;
20 |         }
21 |     }
22 | 
23 | 
24 | -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/S69.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Do not call a function when declaring a for-type loop", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/S72.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Avoid SQL request in loop", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "10min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/S74.html: -------------------------------------------------------------------------------- 1 |

Databases servers have to solves fileds regarding to schema. Knowing and using the schema save CPU cycles and network transfer.

2 |

Noncompliant Code Example

3 |
 4 |     public void foo() {
 5 |         ...
 6 |         String baseQuery = "SELECT * FROM users"; // Noncompliant
 7 | 
 8 |         ...
 9 |     }
10 | 
11 | 
12 |

Compliant Solution

13 |
14 | 
15 |     public void foo() {
16 |         ...
17 |         String query = "SELECT id,name, adress FROM users ";
18 |         ...
19 |    }
20 | 
21 | 
22 | -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/S74.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Don't use the query SELECT * FROM", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "20min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/S75.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Don't concatenate Strings in loop, use StringBuilder instead.", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "20min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } 14 | -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/S76.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Avoid usage of static collections.", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "20min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/S77.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Avoid using Pattern.compile() in a non-static context.", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "20min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } 14 | -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/S78.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Don't set const parameter in batch update => Put its in query", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "15min" 8 | }, 9 | "tags": [ 10 | "eco-conception", "eco-sql" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/S79.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Free resources", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "15min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/java-plugin/src/main/resources/fr/cnumr/l10n/java/rules/java/SDMLQ1.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Use PreparedStatement instead of Statement", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "10min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/java-plugin/src/test/files/AvoidConcatenateStringsInLoop.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.utils; 2 | 3 | public class AvoidConcatenateStringsInLoop { 4 | 5 | public String concatenateStrings(String[] strings) { 6 | String result1 = ""; 7 | 8 | for (String string : strings) { 9 | result1 += string; // Noncompliant 10 | } 11 | return result1; 12 | } 13 | 14 | public String concatenateStrings2() { 15 | String result2 = ""; 16 | 17 | for (int i = 0; i < 1000; ++i) { 18 | result2 += "another"; // Noncompliant 19 | } 20 | return result2; 21 | } 22 | 23 | public String concatenateStrings3() { 24 | String result3 = ""; 25 | 26 | for (int i = 0; i < 1000; ++i) { 27 | result3 = result3 + "another"; // Noncompliant 28 | } 29 | return result3; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/java-plugin/src/test/files/AvoidGettingSizeCollectionInLoopBad.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import java.util.Collection; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | class AvoidGettingSizeCollectionInLoopBad { 8 | AvoidGettingSizeCollectionInLoopBad() { 9 | 10 | } 11 | 12 | public void badLoop() 13 | { 14 | List numberList = new ArrayList(); 15 | numberList.add(10); 16 | numberList.add(20); 17 | 18 | for (int i = 0; i < numberList.size(); i++) { // Noncompliant 19 | System.out.println("numberList.size()"); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/java-plugin/src/test/files/AvoidGettingSizeCollectionInLoopGood.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import java.util.Collection; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | class AvoidGettingSizeCollectionInLoopGood { 7 | AvoidGettingSizeCollectionInLoopGood(AvoidGettingSizeCollectionInLoopGood obj) { 8 | 9 | } 10 | 11 | public void goodLoop() 12 | { 13 | List numberList = new ArrayList(); 14 | numberList.add(10); 15 | numberList.add(20); 16 | 17 | int size = numberList.size(); 18 | for (int i = 0; i < size; i++) { // Compliant 19 | System.out.println("numberList.size()"); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/java-plugin/src/test/files/AvoidMultipleIfElseStatementNoIssue.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | class AvoidMultipleIfElseStatementNoIssueCheck { 4 | AvoidMultipleIfElseStatementNoIssueCheck (AvoidMultipleIfElseStatementNoIssueCheck mc) { 5 | } 6 | 7 | public void methodWithOneIfElseIf() { 8 | int nb1 = 0; 9 | int nb2 = 10; 10 | 11 | if (nb1 == 1) { 12 | nb1 = 1; 13 | } else if (nb1 == nb2) { 14 | // 15 | } else { 16 | // 17 | } 18 | nb1 = nb2; 19 | } 20 | 21 | public void methodWithOneIfElse() { 22 | int nb1 = 0; 23 | int nb2 = 10; 24 | 25 | if (nb1 == 1) { 26 | nb1 = 1; 27 | } else { 28 | // 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/java-plugin/src/test/files/AvoidRegexPatternNotStatic.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import java.util.regex.Pattern; 4 | 5 | public class AvoidRegexPatternNotStatic { 6 | 7 | public boolean foo() { 8 | final Pattern pattern = Pattern.compile("foo"); // Noncompliant 9 | return pattern.matcher("foo").find(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/java-plugin/src/test/files/AvoidStatementForDMLQueries.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import java.sql.Connection; 4 | import java.sql.DriverManager; 5 | import java.sql.*; 6 | import java.sql.PreparedStatement; 7 | 8 | 9 | 10 | class AvoidStatementForDMLQueries { 11 | AvoidStatementForDMLQueries(AvoidStatementForDMLQueries mc) { 12 | } 13 | 14 | public void insert() { 15 | Statement statement = connection.createStatement(); 16 | statement.executeUpdate("INSERT INTO persons(id, name) VALUES(2, 'Toto')"); // Noncompliant 17 | } 18 | } -------------------------------------------------------------------------------- /src/java-plugin/src/test/files/AvoidUsageOfStaticCollections.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import java.util.*; 4 | 5 | /** 6 | * Not compliant 7 | */ 8 | public class AvoidUsageOfStaticCollections { 9 | 10 | public static final List LIST = new ArrayList(); // Noncompliant 11 | 12 | public static final Set SET = new HashSet(); // Noncompliant 13 | 14 | public static final Map MAP = new HashMap(); // Noncompliant 15 | 16 | public AvoidUsageOfStaticCollections() { 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/java-plugin/src/test/files/AvoidUsingGlobalVariablesCheck.java: -------------------------------------------------------------------------------- 1 | public class Openclass { 2 | public static double price = 15.24; // Noncompliant 3 | public static long pages = 1053; // Noncompliant 4 | 5 | public static void main(String[] args) { 6 | double newPrice = Openclass.price; 7 | long newPages = Openclass.pages; 8 | System.out.println(newPrice); 9 | System.out.println(newPages); 10 | static long years = 3000; // Noncompliant 11 | } 12 | static{ // Noncompliant 13 | int a = 4; 14 | } 15 | 16 | public void printingA() { 17 | System.out.println(a); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /src/java-plugin/src/test/files/GoodUsageOfStaticCollections.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import java.util.*; 4 | 5 | /** 6 | * Compliant 7 | */ 8 | public class GoodUsageOfStaticCollections { 9 | public static volatile GoodUsageOfStaticCollections INSTANCE = new GoodUsageOfStaticCollections(); 10 | 11 | public final List LIST = new ArrayList(); // Compliant 12 | public final Set SET = new HashSet(); // Compliant 13 | public final Map MAP = new HashMap(); // Compliant 14 | 15 | private GoodUsageOfStaticCollections() { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/java-plugin/src/test/files/GoodWayConcatenateStringsLoop.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.utils; 2 | 3 | public class GoodWayConcatenateStringsLoop { 4 | 5 | public String concatenateStrings(String[] strings) { 6 | StringBuilder result = new StringBuilder(); 7 | 8 | for (String string : strings) { 9 | result.append(string); 10 | } 11 | return result.toString(); 12 | } 13 | 14 | public void testConcateOutOfLoop() { 15 | String result = ""; 16 | result += "another"; 17 | } 18 | 19 | public void testConcateOutOfLoop2() { 20 | String result = ""; 21 | result = result + "another"; 22 | } 23 | 24 | public String changeValueStringInLoop() { 25 | String result3 = ""; 26 | 27 | for (int i = 0; i < 1; ++i) { 28 | result3 = "another"; 29 | } 30 | return result3; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/java-plugin/src/test/files/IncrementCheck.java: -------------------------------------------------------------------------------- 1 | class MyClass { 2 | MyClass(MyClass mc) { 3 | } 4 | 5 | int foo1() { 6 | int counter = 0; 7 | return counter++; // Noncompliant 8 | } 9 | 10 | int foo11() { 11 | int counter = 0; 12 | return ++counter; 13 | } 14 | 15 | void foo2(int value) { 16 | int counter = 0; 17 | counter++; // Noncompliant 18 | } 19 | 20 | void foo22(int value) { 21 | int counter = 0; 22 | ++counter; 23 | } 24 | 25 | void foo3(int value) { 26 | int counter = 0; 27 | counter = counter + 197845 ; 28 | } 29 | 30 | void foo4(int value) { 31 | int counter =0; 32 | counter = counter + 35 + 78 ; 33 | } 34 | } -------------------------------------------------------------------------------- /src/java-plugin/src/test/files/OptimizeReadFileExceptionCheck.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | class ReadFile { 7 | ReadFile(ReadFile readFile) { 8 | } 9 | public void readPreferences(String filename) { 10 | //... 11 | InputStream in = null; 12 | try { 13 | in = new FileInputStream(filename); // Noncompliant 14 | } catch (FileNotFoundException e) { 15 | logger.log(e); 16 | } 17 | //... 18 | } 19 | } -------------------------------------------------------------------------------- /src/java-plugin/src/test/files/UseCorrectForLoopCheck.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | class UseCorrectForLoopCheck { 7 | UseCorrectForLoopCheck(UseCorrectForLoopCheck mc) { 8 | } 9 | 10 | private final Integer[] intArray = new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; 11 | private final List intList = Arrays.asList(intArray); 12 | 13 | public void testForEachLoop() { 14 | int dummy = 0; 15 | for (Integer i : intArray) { // Noncompliant 16 | dummy += i; 17 | } 18 | 19 | for (Integer i : intList) { 20 | dummy += i; 21 | } 22 | System.out.println(dummy); 23 | } 24 | } -------------------------------------------------------------------------------- /src/java-plugin/src/test/files/ValidRegexPattern.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import java.util.regex.Pattern; 4 | 5 | public class ValidRegexPattern { 6 | 7 | private static final Pattern pattern = Pattern.compile("foo"); // Compliant 8 | 9 | public boolean foo() { 10 | return pattern.matcher("foo").find(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/java-plugin/src/test/files/ValidRegexPattern2.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import java.util.regex.Pattern; 4 | 5 | public class ValidRegexPattern2 { 6 | 7 | private final Pattern pattern = Pattern.compile("foo"); // Compliant 8 | 9 | public boolean foo() { 10 | return pattern.matcher("foo").find(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/java-plugin/src/test/files/ValidRegexPattern3.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import java.util.regex.Pattern; 4 | 5 | public class ValidRegexPattern3 { 6 | 7 | private final Pattern pattern; 8 | 9 | public ValidRegexPattern3() { 10 | pattern = Pattern.compile("foo"); // Compliant 11 | } 12 | 13 | public boolean foo() { 14 | return pattern.matcher("foo").find(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/java-plugin/src/test/java/fr/cnumr/java/checks/ArrayCopyCheckTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.sonar.java.checks.verifier.CheckVerifier; 5 | 6 | class ArrayCopyCheckTest { 7 | 8 | /** 9 | * @formatter:off 10 | */ 11 | @Test 12 | void test() { 13 | CheckVerifier.newVerifier() 14 | .onFile("src/test/files/ArrayCopyCheck.java") 15 | .withCheck(new ArrayCopyCheck()) 16 | .verifyIssues(); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /src/java-plugin/src/test/java/fr/cnumr/java/checks/AvoidConcatenateStringsInLoopTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class AvoidConcatenateStringsInLoopTest { 7 | 8 | @Test 9 | public void checkNonCompliantTests() { 10 | JavaCheckVerifier.newVerifier() 11 | .onFile("src/test/files/AvoidConcatenateStringsInLoop.java") 12 | .withCheck(new AvoidConcatenateStringsInLoop()) 13 | .verifyIssues(); 14 | } 15 | 16 | @Test 17 | public void checkCompliantTests() { 18 | JavaCheckVerifier.newVerifier() 19 | .onFile("src/test/files/GoodWayConcatenateStringsLoop.java") 20 | .withCheck(new AvoidConcatenateStringsInLoop()) 21 | .verifyNoIssues(); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/java-plugin/src/test/java/fr/cnumr/java/checks/AvoidFullSQLRequestCheckTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | class AvoidFullSQLRequestCheckTest { 7 | 8 | @Test 9 | void test() { 10 | JavaCheckVerifier.newVerifier() 11 | .onFile("src/test/files/AvoidFullSQLRequestCheck.java") 12 | .withCheck(new AvoidFullSQLRequest()) 13 | .verifyIssues(); 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /src/java-plugin/src/test/java/fr/cnumr/java/checks/AvoidGettingSizeCollectionInLoopTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | class AvoidGettingSizeCollectionInLoopTest { 7 | @Test 8 | void test() { 9 | JavaCheckVerifier.newVerifier() 10 | .onFile("src/test/files/AvoidGettingSizeCollectionInLoopBad.java") 11 | .withCheck(new AvoidGettingSizeCollectionInLoop()) 12 | .verifyIssues(); 13 | JavaCheckVerifier.newVerifier() 14 | .onFile("src/test/files/AvoidGettingSizeCollectionInLoopGood.java") 15 | .withCheck(new AvoidGettingSizeCollectionInLoop()) 16 | .verifyNoIssues(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/java-plugin/src/test/java/fr/cnumr/java/checks/AvoidMultipleIfElseStatementTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.sonar.java.checks.verifier.CheckVerifier; 5 | 6 | class AvoidMultipleIfElseStatementTest { 7 | @Test 8 | void test() { 9 | CheckVerifier.newVerifier() 10 | .onFile("src/test/files/AvoidMultipleIfElseStatement.java") 11 | .withCheck(new AvoidMultipleIfElseStatement()) 12 | .verifyIssues(); 13 | CheckVerifier.newVerifier() 14 | .onFile("src/test/files/AvoidMultipleIfElseStatementNoIssue.java") 15 | .withCheck(new AvoidMultipleIfElseStatement()) 16 | .verifyNoIssues(); 17 | } 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/java-plugin/src/test/java/fr/cnumr/java/checks/AvoidSQLRequestInLoopCheckTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | class AvoidSQLRequestInLoopCheckTest { 7 | 8 | @Test 9 | void test() { 10 | JavaCheckVerifier.newVerifier() 11 | .onFile("src/test/files/AvoidSQLRequestInLoopCheck.java") 12 | .withCheck(new AvoidSQLRequestInLoop()) 13 | .verifyIssues(); 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /src/java-plugin/src/test/java/fr/cnumr/java/checks/AvoidSetConstantInBatchInsertTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | class AvoidSetConstantInBatchInsertTest { 7 | 8 | @Test 9 | void test() { 10 | JavaCheckVerifier.newVerifier() 11 | .onFile("src/test/files/AvoidSetConstantInBatchUpdateCheck.java") 12 | .withCheck(new AvoidSetConstantInBatchUpdate()) 13 | .verifyIssues(); 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /src/java-plugin/src/test/java/fr/cnumr/java/checks/AvoidSpringRepositoryCallInLoopCheckTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.sonar.java.checks.verifier.CheckVerifier; 5 | 6 | import fr.cnumr.java.utils.FilesUtils; 7 | 8 | class AvoidSpringRepositoryCallInLoopCheckTest { 9 | 10 | @Test 11 | void test() { 12 | CheckVerifier.newVerifier() 13 | .onFile("src/test/files/AvoidSpringRepositoryCallInLoopCheck.java") 14 | .withCheck(new AvoidSpringRepositoryCallInLoopCheck()) 15 | .withClassPath(FilesUtils.getClassPath("target/test-jars")) 16 | .verifyIssues(); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/java-plugin/src/test/java/fr/cnumr/java/checks/AvoidStatementForDMLQueriesTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | import org.junit.jupiter.api.Test; 3 | import org.sonar.java.checks.verifier.CheckVerifier; 4 | 5 | public class AvoidStatementForDMLQueriesTest { 6 | @Test 7 | void test() { 8 | CheckVerifier.newVerifier() 9 | .onFile("src/test/files/AvoidStatementForDMLQueries.java") 10 | .withCheck(new AvoidStatementForDMLQueries()) 11 | .verifyIssues(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/java-plugin/src/test/java/fr/cnumr/java/checks/AvoidUsageOfStaticCollectionsTests.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | public class AvoidUsageOfStaticCollectionsTests { 7 | 8 | @Test 9 | public void testHasIssues() { 10 | JavaCheckVerifier.newVerifier() 11 | .onFile("src/test/files/AvoidUsageOfStaticCollections.java") 12 | .withCheck(new AvoidUsageOfStaticCollections()) 13 | .verifyIssues(); 14 | } 15 | 16 | @Test 17 | public void testNoIssues() { 18 | JavaCheckVerifier.newVerifier() 19 | .onFile("src/test/files/GoodUsageOfStaticCollections.java") 20 | .withCheck(new AvoidUsageOfStaticCollections()) 21 | .verifyNoIssues(); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/java-plugin/src/test/java/fr/cnumr/java/checks/AvoidUsingGlobalVariablesCheckCheckTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | class AvoidUsingGlobalVariablesCheckCheckTest { 7 | 8 | @Test 9 | void test() { 10 | JavaCheckVerifier.newVerifier() 11 | .onFile("src/test/files/AvoidUsingGlobalVariablesCheck.java") 12 | .withCheck(new AvoidUsingGlobalVariablesCheck()) 13 | .verifyIssues(); 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /src/java-plugin/src/test/java/fr/cnumr/java/checks/IncrementCheckTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | class IncrementCheckTest { 7 | 8 | @Test 9 | void test() { 10 | JavaCheckVerifier.newVerifier() 11 | .onFile("src/test/files/IncrementCheck.java") 12 | .withCheck(new IncrementCheck()) 13 | .verifyIssues(); 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /src/java-plugin/src/test/java/fr/cnumr/java/checks/InitializeBufferWithAppropriateSizeTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | class InitializeBufferWithAppropriateSizeTest { 7 | 8 | @Test 9 | void test() { 10 | JavaCheckVerifier.newVerifier() 11 | .onFile("src/test/files/InitializeBufferWithAppropriateSize.java") 12 | .withCheck(new InitializeBufferWithAppropriateSize()) 13 | .verifyIssues(); 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /src/java-plugin/src/test/java/fr/cnumr/java/checks/NoFunctionCallWhenDeclaringForLoopTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | class NoFunctionCallWhenDeclaringForLoopTest { 7 | @Test 8 | void test() { 9 | JavaCheckVerifier.newVerifier() 10 | .onFile("src/test/files/NoFunctionCallWhenDeclaringForLoop.java") 11 | .withCheck(new NoFunctionCallWhenDeclaringForLoop()) 12 | .verifyIssues(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/java-plugin/src/test/java/fr/cnumr/java/checks/OptimizeReadFileExceptionCheckTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | class OptimizeReadFileExceptionCheckTest { 7 | 8 | @Test 9 | void test() { 10 | JavaCheckVerifier.newVerifier() 11 | .onFile("src/test/files/OptimizeReadFileExceptionCheck.java") 12 | .withCheck(new OptimizeReadFileExceptions()) 13 | .verifyIssues(); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/java-plugin/src/test/java/fr/cnumr/java/checks/UnnecessarilyAssignValuesToVariablesTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | class UnnecessarilyAssignValuesToVariablesTest { 7 | 8 | @Test 9 | void test() { 10 | JavaCheckVerifier.newVerifier() 11 | .onFile("src/test/files/UnnecessarilyAssignValuesToVariablesTestCheck.java") 12 | .withCheck(new UnnecessarilyAssignValuesToVariables()) 13 | .verifyIssues(); 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /src/java-plugin/src/test/java/fr/cnumr/java/checks/UseCorrectLoopCheckTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.java.checks; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.sonar.java.checks.verifier.JavaCheckVerifier; 5 | 6 | class UseCorrectLoopCheckTest { 7 | 8 | @Test 9 | void test() { 10 | JavaCheckVerifier.newVerifier() 11 | .onFile("src/test/files/UseCorrectForLoopCheck.java") 12 | .withCheck(new UseCorrectForLoop()) 13 | .verifyIssues(); 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /src/php-plugin/README.md: -------------------------------------------------------------------------------- 1 | https://github.com/SonarSource/sonar-custom-rules-examples/tree/master/php-custom-rules -------------------------------------------------------------------------------- /src/php-plugin/src/main/resources/fr/cnumr/l10n/php/rules/custom/D1.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Avoid using finally in try/catch", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/php-plugin/src/main/resources/fr/cnumr/l10n/php/rules/custom/D2.html: -------------------------------------------------------------------------------- 1 |

Use of methods for basic operations

2 |

Noncompliant Code Example

3 |
 4 |     $min = min($a, $b); // NOK
 5 | 
6 |

Compliant Solution

7 |
 8 |     $min = ($a < $b) ? $a : $b; // NOK
 9 | 
10 | -------------------------------------------------------------------------------- /src/php-plugin/src/main/resources/fr/cnumr/l10n/php/rules/custom/D2.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Use of methods for basic operations", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/php-plugin/src/main/resources/fr/cnumr/l10n/php/rules/custom/D4.html: -------------------------------------------------------------------------------- 1 |

2 | Prefer local variables as parameters 3 |

4 |

A l'appel d'une variable globale, le moteur d'interprétation doit vérifier son existence dans tous les scopes, qu'elle dispose d'une valeur, etc. Passer les variables globales en argument de routines les rend locales dans la fonction, permettant ainsi d'économiser du temps de calcul (cycles CPU). 5 |

6 |

exemple:
7 | var aGlobal = new String('Hello');
8 | function globalLength(){
9 | length = aGlobal.length;
10 | console.log(length);
11 | }
12 | globalLength();
13 |
14 | var aGlobal = new String('Hello');
15 | function someVarLength(str){
16 | length = str.length;
17 | console.log(length);
18 | }
19 | somVarLength(aGlobal);

-------------------------------------------------------------------------------- /src/php-plugin/src/main/resources/fr/cnumr/l10n/php/rules/custom/D4.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Avoid using global variables", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/php-plugin/src/main/resources/fr/cnumr/l10n/php/rules/custom/S34.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Avoid using try-catch-finally statement", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/php-plugin/src/main/resources/fr/cnumr/l10n/php/rules/custom/S66.html: -------------------------------------------------------------------------------- 1 |

PHP allows declaring a string with simple or double quotes. Using double quotes allows developers to insert variables which will be substituted during execution. When the string has no variables, using simple quotes avoid PHP to search inexisting variables. It will save CPU cycles consumption.

2 |

Noncompliant Code Example

3 |
 4 | myFunction("name", "age", "IsStudent");
 5 |   $lastName = "Hugo";
 6 | 
7 |

Compliant Solution

8 |
 9 | myFunction('name', 'age', 'IsStudent');
10 |     $lastName = 'Hugo';
11 |     $concatenatedString = "$lastName is a student";
12 | 
13 | 14 | -------------------------------------------------------------------------------- /src/php-plugin/src/main/resources/fr/cnumr/l10n/php/rules/custom/S66.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Avoid using double quote (\"), prefer using simple quote (')", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/php-plugin/src/main/resources/fr/cnumr/l10n/php/rules/custom/S67.html: -------------------------------------------------------------------------------- 1 |

The form $i++ creates a temporary variable whereas ++$i does not. It save CPU cycles.

2 |

Noncompliant Code Example

3 |
4 | $i++
5 | 
6 |

Compliant Solution

7 |
++$i
8 | -------------------------------------------------------------------------------- /src/php-plugin/src/main/resources/fr/cnumr/l10n/php/rules/custom/S67.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Use ++i instead of i++", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/php-plugin/src/main/resources/fr/cnumr/l10n/php/rules/custom/S69.html: -------------------------------------------------------------------------------- 1 |

Do not call a function when declaring a for-type loop in order to avoid function calls each iterations. It saves CPU cycles.

2 |

Noncompliant Code Example

3 |
 4 | for ($i = 0; $i <= foo(); $i++) { // NOK
 5 |   ......
 6 | }
 7 | 
8 |

Compliant Solution

9 |
10 | $maxI = foo();
11 | for ($i = 0; $i <= $maxI; $i++) {
12 |   .....
13 | }
14 | 
15 |   OR
16 | 
17 | for ($i = 0, $maxI = foo(); $i <= $maxI; $i++) {
18 |   .....
19 | }
20 | }
21 | -------------------------------------------------------------------------------- /src/php-plugin/src/main/resources/fr/cnumr/l10n/php/rules/custom/S69.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Do not call a function when declaring a for-type loop", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/php-plugin/src/main/resources/fr/cnumr/l10n/php/rules/custom/S72.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Avoid SQL request in loop", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "10min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/php-plugin/src/main/resources/fr/cnumr/l10n/php/rules/custom/S74.html: -------------------------------------------------------------------------------- 1 |

Databases servers have to solves fileds regarding to schema. Knowing and using the schema save CPU cycles and network transfer.

2 |

Noncompliant Code Example

3 |
 4 |     public function foo() {
 5 |         ...
 6 |         $baseQuery = "SELECT * FROM users"; // Noncompliant
 7 | 
 8 |         ...
 9 |     }
10 | 
11 |

Compliant Solution

12 |
13 |     public function foo() {
14 |         ...
15 |         $baseQuery = "SELECT id,name, adress FROM users ";
16 |         ...
17 |    }
18 | 
19 | -------------------------------------------------------------------------------- /src/php-plugin/src/main/resources/fr/cnumr/l10n/php/rules/custom/S74.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Don't use the query SELECT * FROM", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "20min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/php-plugin/src/test/java/fr/cnumr/php/MyPhpRulesTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.php; 2 | 3 | import org.junit.Test; 4 | import org.sonar.api.server.rule.RulesDefinition; 5 | 6 | import static org.junit.Assert.assertEquals; 7 | 8 | public class MyPhpRulesTest { 9 | 10 | private int NumberOfRuleInRepository = 6; 11 | 12 | @Test 13 | public void rules() { 14 | MyPhpRules rulesDefinition = new MyPhpRules(); 15 | RulesDefinition.Context context = new RulesDefinition.Context(); 16 | rulesDefinition.define(context); 17 | RulesDefinition.Repository repository = context.repository(MyPhpRules.REPOSITORY_KEY); 18 | assertEquals(NumberOfRuleInRepository, repository.rules().size()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/php-plugin/src/test/java/fr/cnumr/php/checks/AvoidDoubleQuoteCheckTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.php.checks; 2 | 3 | import org.junit.Test; 4 | import org.sonar.plugins.php.api.tests.PHPCheckTest; 5 | import org.sonar.plugins.php.api.tests.PhpTestFile; 6 | 7 | import java.io.File; 8 | 9 | public class AvoidDoubleQuoteCheckTest { 10 | 11 | @Test 12 | public void test() throws Exception { 13 | PHPCheckTest.check(new AvoidDoubleQuoteCheck(), new PhpTestFile(new File("src/test/resources/checks/avoidDoubleQuote.php"))); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/php-plugin/src/test/java/fr/cnumr/php/checks/AvoidFullSQLRequestCheckTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.php.checks; 2 | 3 | import org.junit.Test; 4 | import org.sonar.plugins.php.api.tests.PHPCheckTest; 5 | import org.sonar.plugins.php.api.tests.PhpTestFile; 6 | 7 | import java.io.File; 8 | 9 | public class AvoidFullSQLRequestCheckTest { 10 | 11 | @Test 12 | public void test() { 13 | PHPCheckTest.check(new AvoidFullSQLRequestCheck(), new PhpTestFile(new File("src/test/resources/checks/AvoidFullSQLRequest.php"))); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/php-plugin/src/test/java/fr/cnumr/php/checks/AvoidSQLRequestInLoopCheckTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.php.checks; 2 | 3 | import org.junit.Test; 4 | import org.sonar.plugins.php.api.tests.PHPCheckTest; 5 | import org.sonar.plugins.php.api.tests.PhpTestFile; 6 | 7 | import java.io.File; 8 | 9 | public class AvoidSQLRequestInLoopCheckTest { 10 | 11 | @Test 12 | public void test() throws Exception { 13 | PHPCheckTest.check(new AvoidSQLRequestInLoopCheck(), new PhpTestFile(new File("src/test/resources/checks/AvoidSQLRequestInLoop.php"))); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/php-plugin/src/test/java/fr/cnumr/php/checks/AvoidTryCatchFinallyCheckNOKfailsAllTryStatementsTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.php.checks; 2 | 3 | import org.junit.Test; 4 | import org.sonar.plugins.php.api.tests.PHPCheckTest; 5 | import org.sonar.plugins.php.api.tests.PhpTestFile; 6 | 7 | import java.io.File; 8 | 9 | public class AvoidTryCatchFinallyCheckNOKfailsAllTryStatementsTest { 10 | 11 | @Test 12 | public void test() throws Exception { 13 | PHPCheckTest.check(new AvoidTryCatchFinallyCheck_NOK_failsAllTryStatements(), new PhpTestFile(new File("src/test/resources/checks/avoidTryCatchFinallyCheck_NOK_FailsAllTryStatements.php"))); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/php-plugin/src/test/java/fr/cnumr/php/checks/NoFunctionCallWhenDeclaringForLoopTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.php.checks; 2 | 3 | import org.junit.Test; 4 | import org.sonar.plugins.php.api.tests.PHPCheckTest; 5 | import org.sonar.plugins.php.api.tests.PhpTestFile; 6 | 7 | import java.io.File; 8 | 9 | public class NoFunctionCallWhenDeclaringForLoopTest { 10 | 11 | @Test 12 | public void test() throws Exception { 13 | PHPCheckTest.check(new NoFunctionCallWhenDeclaringForLoop(), new PhpTestFile(new File("src/test/resources/checks/noFunctionCallWhenDeclaringForLoop.php"))); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/php-plugin/src/test/java/fr/cnumr/php/checks/UseOfMethodsForBasicOperationsTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.php.checks; 2 | 3 | import org.junit.Test; 4 | import org.sonar.plugins.php.api.tests.PHPCheckTest; 5 | import org.sonar.plugins.php.api.tests.PhpTestFile; 6 | 7 | import java.io.File; 8 | 9 | public class UseOfMethodsForBasicOperationsTest { 10 | 11 | @Test 12 | public void test() throws Exception { 13 | PHPCheckTest.check(new UseOfMethodsForBasicOperations(), new PhpTestFile(new File("src/test/resources/checks/useOfMethodsForBasicOperations.php"))); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/php-plugin/src/test/resources/checks/AvoidUsingGlobalVariablesCheck.php: -------------------------------------------------------------------------------- 1 | 17 | -------------------------------------------------------------------------------- /src/php-plugin/src/test/resources/checks/incrementCheck.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/php-plugin/src/test/resources/checks/useOfMethodsForBasicOperations.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/prepare-codenarc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # Define CodeNarc version 4 | codenarcVersion="2.2.3" 5 | 6 | # Build CodeNarc 7 | cd codenarc-converter/CodeNarc 8 | ./gradlew build -x test 9 | 10 | # Deploy to local repository 11 | mvn -B install:install-file -Dfile=build/libs/CodeNarc-${codenarcVersion}.jar -DgroupId=org.codenarc -DartifactId=CodeNarc -Dversion=${codenarcVersion} -Dpackaging=jar 12 | 13 | -------------------------------------------------------------------------------- /src/prepare-codenarc.bat: -------------------------------------------------------------------------------- 1 | REM == Define CodeNarc version 2 | set codenarc_version=2.2.3 3 | 4 | REM == Build CodeNarc 5 | cd codenarc-converter/CodeNarc 6 | call ./gradlew build -x test 7 | 8 | REM == Deploy to local repository 9 | mvn -B install:install-file -Dfile=build/libs/CodeNarc-%codenarc_version%.jar -DgroupId=org.codenarc -DartifactId=CodeNarc -Dversion=%codenarc_version% -Dpackaging=jar 10 | -------------------------------------------------------------------------------- /src/python-plugin/README.md: -------------------------------------------------------------------------------- 1 | https://github.com/SonarSource/sonar-custom-rules-examples/tree/master/python-custom-rules -------------------------------------------------------------------------------- /src/python-plugin/src/main/resources/fr/cnumr/l10n/python/rules/python/D4.html: -------------------------------------------------------------------------------- 1 |

When function calls global variables, a lot a CPU cycles is consumed.

2 |

Noncompliant Code Example

3 |
 4 | global_var = 'foo'
 5 | def print_global_var_details():
 6 |     print(len(global_var)) # Noncompliant
 7 |     print('Global var : ', global_var) # Noncompliant
 8 |     print('Global var : ' + global_var) # Noncompliant
 9 | print_global_var_details()
10 | 
11 |

Compliant Solution

12 |
13 | global_var = 'foo';
14 | def print_var_details(local_var) {
15 |   print(len(local_var));
16 |   print('Var : ', local_var)
17 |   print('Var : ' + local_var)
18 | }
19 | print_length(global_var);
20 | 
21 | -------------------------------------------------------------------------------- /src/python-plugin/src/main/resources/fr/cnumr/l10n/python/rules/python/D4.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Do not call global variables directly inside functions", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/python-plugin/src/main/resources/fr/cnumr/l10n/python/rules/python/D7.html: -------------------------------------------------------------------------------- 1 |

Avoid Getters and Setters in class, It increase unless RAM memory usage.

2 |

Noncompliant Code Example

3 |
 4 | class Client():
 5 | 
 6 |     def __init__(self, age):
 7 |         self.age = age
 8 | 
 9 |     def get_age(self):
10 |         return self.age
11 | 
12 |     def set_age(self, age):
13 |         self.age = age
14 | 
15 | client = Client(25)
16 | client.get_age() # Getter inutile
17 | client.set_age(25) # Setter inutile
18 | 
19 | 
20 |

Compliant Solution

21 |
22 | class Client():
23 | 
24 |     def __init__(self, age):
25 |         self.age = age
26 | 
27 |     def get_age(self):
28 |         return self.age
29 | 
30 |     def set_age(self, age):
31 |         self.age = age
32 | 
33 | client = Client(25)
34 | client.age # Récupérer l'attribut age
35 | client.age = 26 # Modifier l'attribut age
36 | 
37 | -------------------------------------------------------------------------------- /src/python-plugin/src/main/resources/fr/cnumr/l10n/python/rules/python/D7.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Avoid creating getter and setter methods in classes.", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/python-plugin/src/main/resources/fr/cnumr/l10n/python/rules/python/S34.html: -------------------------------------------------------------------------------- 1 |

Inside complex code parts (for exemple multiple loops, complex data constructions...), avoid using try...catch...finally. 2 |

When an exception is thrown, a variable (the exception itself) is created in a catch block and it's destruction consumes unnecessary CPU cycles and RAM. Prefer using logical tests in this cases.

3 |

4 |

Noncompliant Code Example

5 |
 6 | try:
 7 |     f = open(path)
 8 |     print(fh.read())
 9 | except:
10 |     print('No such file '+path
11 | finally:
12 |     f.close()
13 | 
14 | 
15 |

Compliant Solution

16 |
17 | if os.path.isfile(path):
18 |   fh = open(path, 'r')
19 |   print(fh.read())
20 |   fh.close
21 | 
22 | -------------------------------------------------------------------------------- /src/python-plugin/src/main/resources/fr/cnumr/l10n/python/rules/python/S34.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Avoid using try-catch-finally statement", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/python-plugin/src/main/resources/fr/cnumr/l10n/python/rules/python/S69.html: -------------------------------------------------------------------------------- 1 |

Do not call a function when declaring a for-type loop in order to avoid function calls each iterations. It saves CPU cycles.

2 |

Noncompliant Code Example

3 |
 4 | for i in my_function():
 5 |     ......
 6 | 
 7 | 
8 |

Compliant Solution

9 |
10 | limit = my_function()
11 | for i in limit:
12 |     ......
13 | 
14 | -------------------------------------------------------------------------------- /src/python-plugin/src/main/resources/fr/cnumr/l10n/python/rules/python/S69.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Do not call a function when declaring a for-type loop", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/python-plugin/src/main/resources/fr/cnumr/l10n/python/rules/python/S72.html: -------------------------------------------------------------------------------- 1 |

Executing SQL queries in loop induced unnecessary calculation by the cpu, RAM usage and network transfert.

2 |

Noncompliant Code Example

3 |
 4 |     def foo():
 5 |         ...
 6 |         results = []
 7 |         for id in range(20):
 8 |           results.append(cursor.execute("SELECT name FROM users where id = ?", (id)).fetchone()) # Noncompliant {{Avoid performing SQL queries within a loop}}
 9 |         ...
10 | 
11 |

Compliant Solution

12 |
13 | 
14 |     def foo():
15 |         ...
16 |         ids = range(20)
17 |         results = cursor.execute("SELECT name FROM users where id IN ({0})".format(', '.join("?" * len(ids))), ids).fetchmany() # Compliant
18 |         ...
19 |    }
20 | 
21 | 
22 | -------------------------------------------------------------------------------- /src/python-plugin/src/main/resources/fr/cnumr/l10n/python/rules/python/S72.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Avoid SQL request in loop", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "10min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/python-plugin/src/main/resources/fr/cnumr/l10n/python/rules/python/S74.html: -------------------------------------------------------------------------------- 1 |

Databases servers have to solves fileds regarding to schema. Knowing and using the schema save CPU cycles and network transfer.

2 |

Noncompliant Code Example

3 |
 4 |     public void foo() {
 5 |         ...
 6 |         String baseQuery = "SELECT * FROM users"; // Noncompliant
 7 | 
 8 |         ...
 9 |     }
10 | 
11 | 
12 |

Compliant Solution

13 |
14 | 
15 |     public void foo() {
16 |         ...
17 |         String query = "SELECT id,name, adress FROM users ";
18 |         ...
19 |    }
20 | 
21 | 
22 | -------------------------------------------------------------------------------- /src/python-plugin/src/main/resources/fr/cnumr/l10n/python/rules/python/S74.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Don't use the query SELECT * FROM", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "20min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/python-plugin/src/test/java/fr/cnumr/python/checks/AvoidFullSQLRequestTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.python.checks; 2 | 3 | import org.junit.Test; 4 | import org.sonar.python.checks.utils.PythonCheckVerifier; 5 | 6 | public class AvoidFullSQLRequestTest { 7 | 8 | @Test 9 | public void test() { 10 | PythonCheckVerifier.verify("src/test/resources/checks/avoidFullSQLRequest.py", new AvoidFullSQLRequest()); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/python-plugin/src/test/java/fr/cnumr/python/checks/AvoidGettersAndSettersTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.python.checks; 2 | 3 | import org.junit.Test; 4 | import org.sonar.python.checks.utils.PythonCheckVerifier; 5 | 6 | public class AvoidGettersAndSettersTest { 7 | 8 | @Test 9 | public void test() { 10 | PythonCheckVerifier.verify("src/test/resources/checks/avoidGettersAndSetters.py", new AvoidGettersAndSetters()); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/python-plugin/src/test/java/fr/cnumr/python/checks/AvoidGlobalVariableInFunctionCheckTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.python.checks; 2 | 3 | import org.junit.Test; 4 | import org.sonar.python.checks.utils.PythonCheckVerifier; 5 | 6 | public class AvoidGlobalVariableInFunctionCheckTest { 7 | @Test 8 | public void test() { 9 | PythonCheckVerifier.verify("src/test/resources/checks/avoidGlobalVariableInFunction.py", new AvoidGlobalVariableInFunctionCheck()); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/python-plugin/src/test/java/fr/cnumr/python/checks/AvoidSQLRequestInLoopTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.python.checks; 2 | 3 | import org.junit.Test; 4 | import org.sonar.python.checks.utils.PythonCheckVerifier; 5 | 6 | public class AvoidSQLRequestInLoopTest { 7 | @Test 8 | public void test() { 9 | PythonCheckVerifier.verify("src/test/resources/checks/avoidSQLRequestInLoop.py", new AvoidSQLRequestInLoop()); 10 | PythonCheckVerifier.verifyNoIssue("src/test/resources/checks/avoidSQLRequestInLoopNoImports.py", new AvoidSQLRequestInLoop()); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/python-plugin/src/test/java/fr/cnumr/python/checks/AvoidTryCatchFinallyCheckTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.python.checks; 2 | 3 | 4 | import org.junit.Test; 5 | import org.sonar.python.checks.utils.PythonCheckVerifier; 6 | 7 | public class AvoidTryCatchFinallyCheckTest { 8 | @Test 9 | public void test() { 10 | PythonCheckVerifier.verify("src/test/resources/checks/avoidTryCatchFinallyCheck.py", new AvoidTryCatchFinallyCheck()); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/python-plugin/src/test/java/fr/cnumr/python/checks/NoFunctionCallWhenDeclaringForLoopTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.python.checks; 2 | 3 | import org.junit.Test; 4 | import org.sonar.python.checks.utils.PythonCheckVerifier; 5 | 6 | public class NoFunctionCallWhenDeclaringForLoopTest { 7 | @Test 8 | public void test() { 9 | PythonCheckVerifier.verify("src/test/resources/checks/noFunctionCallWhenDeclaringForLoop.py", new NoFunctionCallWhenDeclaringForLoop()); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/python-plugin/src/test/resources/checks/.gitignore: -------------------------------------------------------------------------------- 1 | my.conf 2 | -------------------------------------------------------------------------------- /src/python-plugin/src/test/resources/checks/avoidFullSQLRequest.py: -------------------------------------------------------------------------------- 1 | def displayMessage(argument1): 2 | print(argument) 3 | 4 | displayMessage(' sElEcT * fRoM myTable') # Noncompliant {{Don't use the query SELECT * FROM}} 5 | displayMessage(' sElEcT user fRoM myTable') 6 | 7 | requestNonCompiliant = ' SeLeCt * FrOm myTable' # Noncompliant {{Don't use the query SELECT * FROM}} 8 | requestCompiliant = ' SeLeCt user FrOm myTable' 9 | displayMessage(requestNonCompiliant) 10 | displayMessage(requestCompiliant) 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/python-plugin/src/test/resources/checks/avoidGettersAndSetters.py: -------------------------------------------------------------------------------- 1 | from datetime import date 2 | 3 | class Client(): 4 | 5 | def __init__(self, age, weight): 6 | self.age = age 7 | self.weight = weight 8 | 9 | def set_age(self, age): # Noncompliant {{Avoid the use of getters and setters}} 10 | self.age = age 11 | 12 | def set_age(self, age2): # Noncompliant {{Avoid the use of getters and setters}} 13 | self.age = age2 14 | 15 | def get_age_in_five_years(self): 16 | a = Client() 17 | return a.age 18 | 19 | def get_age(self): # Noncompliant {{Avoid the use of getters and setters}} 20 | return self.age 21 | 22 | def is_major(self): 23 | return self.age >= 18 24 | 25 | def get_weight(self): # Noncompliant {{Avoid the use of getters and setters}} 26 | return self.weight -------------------------------------------------------------------------------- /src/python-plugin/src/test/resources/checks/avoidTryCatchFinallyCheck.py: -------------------------------------------------------------------------------- 1 | import os.path 2 | 3 | path = 'hello.txt' 4 | 5 | 6 | def my_function(): 7 | x=0 8 | 9 | try: # Noncompliant {{Avoid the use of try-catch-finally}} 10 | print(x) 11 | except: 12 | print("Something went wrong") 13 | finally: 14 | print("The 'try except' is finished") 15 | 16 | def foo(): 17 | try: # Noncompliant {{Avoid the use of try-catch-finally}} 18 | f = open(path) 19 | print(f.read()) 20 | except: 21 | print('No such file '+path) 22 | finally: 23 | f.close() 24 | 25 | def boo(): 26 | if os.path.isfile(path): 27 | fh = open(path, 'r') 28 | print(fh.read()) 29 | fh.close -------------------------------------------------------------------------------- /src/python-plugin/src/test/resources/checks/my.conf.sample: -------------------------------------------------------------------------------- 1 | [client] 2 | host = localhost 3 | user = dbtest 4 | password = dbtest 5 | database = dbtest 6 | -------------------------------------------------------------------------------- /src/python-plugin/src/test/resources/checks/noFunctionCallWhenDeclaringForLoop.py: -------------------------------------------------------------------------------- 1 | def my_function(): 2 | return 6 3 | 4 | for i in my_function(): # Noncompliant {{Do not call a function when declaring a for-type loop}} 5 | print("Test") 6 | my_function() 7 | pass 8 | 9 | 10 | 11 | my_function() -------------------------------------------------------------------------------- /src/sonar-project.properties: -------------------------------------------------------------------------------- 1 | # must be unique in a given SonarQube instance 2 | sonar.projectKey=sonar-custom-plugin-example 3 | 4 | # --- optional properties --- 5 | 6 | # defaults to project key 7 | #sonar.projectName=My project 8 | # defaults to 'not provided' 9 | #sonar.projectVersion=1.0 10 | 11 | # Path is relative to the sonar-project.properties file. Defaults to . 12 | #sonar.sources=. 13 | 14 | # Encoding of the source code. Default is default system encoding 15 | #sonar.sourceEncoding=UTF-8 16 | 17 | sonar.eslint.reportPaths=/opt/project/eslint-report.json 18 | sonar.css.stylelint.reportPaths=/opt/project/stylelint-report.json 19 | sonar.java.binaries=/opt/project/java-plugin/target/classes 20 | sonar.scm.disabled=true -------------------------------------------------------------------------------- /src/xml-plugin/README.md: -------------------------------------------------------------------------------- 1 | https://github.com/SonarSource/sonar-custom-rules-examples/tree/master/xml-custom-rules -------------------------------------------------------------------------------- /src/xml-plugin/src/main/resources/fr/cnumr/l10n/xml/rules/custom/S99.html: -------------------------------------------------------------------------------- 1 |

Avoid the use of unoptimized vector images

2 |

Noncompliant Code Example

3 |
 4 | Votre image contient des métadata non nécessaires à la visualisation de l'image
 5 | Your image has metadatas that are not necessary to visualize it
 6 | 
 7 | 
8 |

Compliant Solution

9 |
10 | Use SVGO to scan your image
11 | 
12 | -------------------------------------------------------------------------------- /src/xml-plugin/src/main/resources/fr/cnumr/l10n/xml/rules/custom/S99.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Avoid the use of unoptimized vector images", 3 | "type": "CODE_SMELL", 4 | "status": "ready", 5 | "remediation": { 6 | "func": "Constant\/Issue", 7 | "constantCost": "5min" 8 | }, 9 | "tags": [ 10 | "eco-conception" 11 | ], 12 | "defaultSeverity": "Minor" 13 | } -------------------------------------------------------------------------------- /src/xml-plugin/src/test/java/fr/cnumr/xml/MyXmlRulesTest.java: -------------------------------------------------------------------------------- 1 | package fr.cnumr.xml; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import org.junit.Test; 6 | import org.sonar.api.server.rule.RulesDefinition; 7 | 8 | public class MyXmlRulesTest { 9 | 10 | private int NumberOfRuleInRepository = 6; 11 | 12 | @Test 13 | public void rules() { 14 | MyXmlRules rulesDefinition = new MyXmlRules(); 15 | RulesDefinition.Context context = new RulesDefinition.Context(); 16 | rulesDefinition.define(context); 17 | RulesDefinition.Repository repository = context.repository(MyXmlRules.REPOSITORY_KEY); 18 | assertEquals(NumberOfRuleInRepository, repository.rules().size()); 19 | } 20 | } 21 | --------------------------------------------------------------------------------