简体   繁体   中英

SonarQube - help in creating a new language plugin

I am creating a new plugin for SonarQube which allows developers to perform static code analysis on ESQL code.

Using Maven I can build a shell of a plugin, which produces the JAR file which I can place in the correct folder in order for it to be added to SonarQube.

The next stage is to write the Java classes for the rules, however I am unsure on what and where these look like. I am using the example from the following GIT repository: https://github.com/SonarSource/sonar-examples/tree/master/plugins/sonar-reference-plugin

Do I simply create a new package with some classes? And how do I actually rules?

If you want to write a rule engine for the ESQL language, this means that you must first write a parser for this language. And only after you completed this stage, you will create a rule engine based on that parser (with visitor classes that navigate through the AST and that create issues under specific circumstances).

You can take a look at how we implemented the Javascript plugin ( see the code of version 1.3 ):

  • the "javascript-squid" module is where the parser is written
  • the "javascript-checks" module is where the rule engine (based on the parser) is written
  • the "sonar-javascript-plugin" module is the actual plugin, which embeds the parser and the rule engine and which provides all the required glue around them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM