This is a developer documentation. If you want to analyze source code in SonarQube read one of the following documentations:
- Kotlin language: SonarKotlin documentation
- Ruby language: SonarRuby documentation
- Scala language: SonarScala documentation
SLang (SonarSource Language) is a framework to quickly develop code analyzers for SonarQube. SLang defines language agnostic AST. Using this AST we can develop simple syntax based rules. Then we use parser for real language to create this AST. Currently Kotlin, Ruby and Scala analyzers use this approach.
We use embeddable library of Kotlin compiler to create AST and visitor to create SLang AST.
We use whitequark parser to parse Ruby language by embedding it using JRuby runtime.
- AST documentation for the parser can be found here
- We use simple Ruby script to call the parser and invoke our visitor written in Java
We use Scalameta to parse Scala language.
Run:
mvn clean install
By default, Integration Tests (ITs) are skipped during build. If you want to run them, you need first to retrieve the related projects which are used as input:
git submodule update --init
Then run the ITs
cd its
mvn clean install -Dsonar.runtimeVersion=7.1
When adding a new source file, you will need to add license headers. Instead of copy-pasting blocks, the following command line can be used:
mvn license:format