Skip to content

ArvApu/phpcs-sonarqube-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Sonar PHPCS (PHP Codesniffer) plugin

This plugin can be used to import PHPCS reports into SonarQube.

The plugin will not run PHPCS but instead re-use the report generated by it. Here are the steps:

  1. Download and install PHPCS on the machine or project running the SonarQube analysis
  2. Get sonar-phpcs-plugin jar file:
    • Download from release
    • Or compile manually (Maven and at least JDK 17 is required):
      1. Clone project
      2. Run mvn verify
      3. Compiled jar file should be in target directory
  3. Install this SonarQube PHPCS plugin (see instructions to manually install a SonarQube plugin)
  4. Run PHPCS to create a json report e.g.:
phpcs --standard=PSR12 --report-json=output/phpcs.json src
  1. Set the sonar.php.phpcs.reportPaths analysis property to the path of the PHPCS json report, e.g.:
sonar.php.phpcs.reportPaths=output/analysis/phpcs.json
  1. Run the SonarQube analysis on your project