- Java JDK 11+
- Maven 3.8 or later
- A local SonarQube instance for local testing
The iOS plugin is split into 3 different modules:
swift-lang
is for Swift source files parsing and checkscommons-ios
gather common parsing utils and models that can be reused to implement other languages supportsonar-ios-plugin
the actual SonarQube plugin declaration
Swift file parser is build using the ANTLR parser generator.
The generated parser source files are located into swift-lang/src/main/java/io/ecocode/ios/swift/antlr/generated
. Those source files should not be edited manually.
When necessary (in case of Swift language syntax upgrade for example), those source files should be re-generated with ANTLR.
When adding a new rule, the following steps are required:
- Declare the rule
- Implement a check
- Add the @Rule to the class
The new rule must be declared in swift-lang/src/resources/ecocode_swift_profile.json
Note: in case the new rule is not available in https://github.com/green-code-initiative/ecoCode/tree/main/ecocode-rules-specifications yet create a matching <RULE_ID>.json ans <RULE_ID>.html in
swift-lang/src/resources/io/ecocode/rules/swift/
to provide rule metadata.
In order to implement a check for the rule, create a Check class inherited from SwiftRuleCheck
in src/main/java/io/ecocode/ios/swift/checks
.
Have a look at swift-lang/src/main/java/io/ecocode/ios/swift/checks/idleness/IdleTimerDisabledCheck
to learn more about the implementation.
Don't forget to add the @org.sonar.check.Rule
annotation to the check in order to register it to the AST visitor.