├── .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 |  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 |
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.
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 |
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
.
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 |
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).
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 |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 |
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().
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 |
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.
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
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.
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 |
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.
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 |
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.
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 |
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.
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 |
Creation of a Media Recorder object with new MediaRecorder()
is used to record
3 | audio and video. Class own a release()
method.
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 |9 | MediaRecorder mr = new MediaRecorder(); 10 |11 |
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 |
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.
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 |9 | MediaPlayer mp = new MediaPlayer(); 10 |11 |
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 |
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.
11 | import android.bluetooth.* 12 |13 |
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 |
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().
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 |
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.
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 |
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.
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 |
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 |
9 | surface.setFrameRate(120f, FRAME_RATE_COMPATIBILITY_DEFAULT); 10 |11 |
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
Using Spring repository in loop induced unnecessary calculation by the cpu so unless energy consumption.
2 |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 |
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 |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 |
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 |7 | StringBuilder sb = new StringBuilder(); // Noncompliant 8 | for (int i = 0; i < 100; i++) { 9 | sb.append(...); 10 | } 11 |12 |
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 |4 | List<String> objList = getData(); 5 | 6 | for (int i = 0; i < objList.size(); i++) { 7 | // execute code 8 | } 9 | 10 |11 |
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 |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 |
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 |4 | String var1 = getValue(); 5 | return var1; 6 | 7 | String var2 = "hello" 8 | var2 = "world" //Non compliant cause never assigned 9 | 10 |11 |
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 |4 | i++ 5 |6 |
++i8 | -------------------------------------------------------------------------------- /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 |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 |
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 |4 | public void foo() { 5 | ... 6 | String baseQuery = "SELECT * FROM users"; // Noncompliant 7 | 8 | ... 9 | } 10 | 11 |12 |
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
Use of methods for basic operations
2 |4 | $min = min($a, $b); // NOK 5 |6 |
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);
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 |4 | myFunction("name", "age", "IsStudent"); 5 | $lastName = "Hugo"; 6 |7 |
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 |4 | $i++ 5 |6 |
++$i8 | -------------------------------------------------------------------------------- /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 |4 | for ($i = 0; $i <= foo(); $i++) { // NOK 5 | ...... 6 | } 7 |8 |
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 |4 | public function foo() { 5 | ... 6 | $baseQuery = "SELECT * FROM users"; // Noncompliant 7 | 8 | ... 9 | } 10 |11 |
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 |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 |
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 |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 |
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 |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 |
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 |4 | for i in my_function(): 5 | ...... 6 | 7 |8 |
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 |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 |
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 |4 | public void foo() { 5 | ... 6 | String baseQuery = "SELECT * FROM users"; // Noncompliant 7 | 8 | ... 9 | } 10 | 11 |12 |
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 |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 |
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 | --------------------------------------------------------------------------------