Rate This Document
Findability
Accuracy
Completeness
Readability

Coding Specification Check

The Kunpeng native development pipeline uses SonarQube to check the coding specification compliance. SonarQube is an open platform for managing code quality. It offers comprehensive quality analysis covering architecture & design, comments, coding specification, potential defects, code complexity, duplicated code, and other. SonarQube is suited for multiple programming languages, including Java, C, C++, and JavaScript.

SonarQube checks code quality from seven dimensions:

  • Complexity: High code complexity usually increases code risks and error probability. SonarQube uses a complexity measurement tool (such as Cyclomatic Complexity) to calculate code complexity.
  • Duplications: A program may contain a large amount of copy-and-paste code, resulting in code bloat. SonarQube can display the severe duplications in source code.
  • Unit tests: SonarQube collects statistics on and displays the unit test coverage, helping the development or test personnel optimize tests.
  • Coding rules: The FindBugs, PMD, and CheckStyle analyzers check whether the code complies with the coding standards.
  • Comments: If code comments are too few, it is difficult for others to take over the code from the original writers. If code comments are too many, it is difficult to read the code.
  • Potential bugs: The FindBugs, PMD, and CheckStyle analyzers can combine to detect hidden bugs.
  • Architecture & design: SonarQube finds out loops, displays dependencies between packages and between classes, and checks the coupling degree between programs.
    Figure 1 Code check