Writing a sonarqube plugin
2021-09-15 / modified at 2023-01-29 / 290 words / 1 mins
️This article has been over 1 years since the last update.

Writing a sonarqube plugin is not always requiring a parser at the beginning. We are able to import a third-party report into sonarqube database.

In the recent times, we are working on integrating HDL(hardware description language) working with SoanrQube. Here is a roadmap for plugin developers from scratch.

Background

  • Official guide: Read carefully, but you are NOT required to write a parser at the beginning as the document mentions.
  • Sonar-cxx: A good example for reading third-party reports with the corner-case handled.

Relationship

$2SonarQube Relationships«external_system»Sources The source code«container»Issues[NewIssue/NewExternalIssue]«container»ProjectSensor[org.sonar.api.scanner.sensor.ProjectSensor] Client side«container»RulesDefinition[org.sonar.api.server.rule.RulesDefinition] On startup, server side«container»SonarWayProfiles[org.sonar.api.server.profile.BuiltInQualityProfilesDefinition] build-in active rules«container»Database[Sonarqube DB] files & issuesSensorActivateread by[HTTP]save()upload zip toCompute EngineWarning:Created for discussion, needs to be validated

Roadmap

We don’t recommend to create a lint tool only for Sonarqube. The better way is to create a standalone tool to gererate reports for sonarqube/IDEs.

$2Sonarqube plugin roadmap for developersHave an existing thrid-party reports?yesnoDo i need to manage all issues?yesnoExternal report sensorJavaGrok/XMLParserExample: See cxx-pluginNo plugin development requiredWriting some py scripts to generate issues.jsonsee'Generic Issue Import Format'parserParserGrammerLexerVisitorSensorXml/csv rule defination createdUsing NewExternalIssuefor double checknoWorth to ignore a unlisted issues?yesMetricsLines(Without comments)CPD(Copy Paste Detection, NewCpdTokens)Others MetricDefinition

Hint

  • If you have rules more than 10k, the default H2 database will lose some rules.