Code quality analysis of Drupal. Can I use Sonar?
For better understanding:
https://docs.acquia.com/article/tools-analyzing-your-drupal-codebase
Following artcle my experience with Sonar and Drupal.
https://docs.sonarqube.org/display/PLUG/SonarPHP has following number of rules.
Sonarway (for PHP) has following number of rules
1. Bug:15
2. Vulnerability:3
3. Code smell:45
Drupal has following number of rules
1. Bug: 3
2. Vulnerability: 0
3. Code smell: 10
Its possible that you can define following inheritance in Quality profile.
For example:
Sonarway=>Drupal
Drupal uses PHPCodeSniffer (Drupal standards) or Coder to verify its coding standards. Both of them dont have integration with Sonar.
3. Sonar comes up with some Drupal Coding Standards. But is is not same as what we do in PHPCodeSniffer and Coder.
4. It's still better to fix critical / blocker issues from Sonar Way and Drupal Quality profiles.
Its best to use PHPCodeSniffer with Drupal standards and some reporting tool can be associated with PHPCodeSniffer.
I cant find one single tool which integrate well with PHPCodeSniffer output.
But the result of PHPCodeSniffer can be put as a artifactory in CI build tool.
If you use bamboo:
PHPCodeSniffer should be installed in Bamboo. A bamboo task plan has to be created to run the phpcs in command line. Example:
I cant find one single tool which integrate well with PHPCodeSniffer output.
But the result of PHPCodeSniffer can be put as a artifactory in CI build tool.
If you use bamboo:
PHPCodeSniffer should be installed in Bamboo. A bamboo task plan has to be created to run the phpcs in command line. Example:
phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md /Applications/MAMP/htdocs/myproject/sites/all/modules/custom/ --report-summary
Also, the result should be created as a artifactory in every build. If we want to view the result, we can download the artificatory from the build result.
For example, we can generate a text or html file from phpcs output and it can be downloaded from bamboo plan
Comments
Post a Comment