Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info
iconfalse
titleTable of Contents
Table of Contents

I have projects that do not use the required versions of PHPUnit, PHP Depend, etc. What can I do?

If you are able to have several versions of code analysis tool on the same machine, just make sure that the correct one will be used.

You also have to make sure that the output file log is compatible with the one specified by the version of the tool you want to use.

 

I have created my own PHP_CodeSniffer Standard or PHPMD ruleset. Can I use it with the Sonar PHP plugin?

Yes, but with some extra work. Two possible cases :

1) Your work consisted in pure configuration: modify a ruleset for PHPMD or create a PHPCS Standard including Sniffs from existing standards.

In this case you'll be able to recreate your work directly from the Sonar UI for Quality Profiles

You must check for the presence of your rules in Sonar profiles, as some PHPCS rule descriptions are still missing.

If you don't find all of your rules, you simply fall in case 2.

2) You added code to the solutions: you developed Sniffs or PHP PMD Rules

In this case you will have to Extend the PHP Coding Rules

 

How do I prevent external tools from analyzing some source files?

Most of the time, using the sonar.exclusions property will be enough to exclude files from being reported by Sonar. However, there might be some cases where one really wants to exclude files from being analyzed by an external tool (may it be PHP_CodeSniffer,  PHPMD or PHP Depend):

  • a file is badly written and the tool is crashing when analyzing this file, thus preventing Sonar from completing the analysis
  • a big number of files must be excluded and there's no need for the external tools to spend time analyzing files that won't be reported by Sonar

In these specific cases, you should use the 'sonar.xxxx.argumentLine' property of the external tools to manually add the exclusions you want. For instance, for PHP_CodeSniffer, you would add the following property:

 

Code Block
sonar.phpCodesniffer.argumentLine=--ignore=Database/*.php

This would tell PHP_CodeSniffer to ignore every PHP file located in the "Database" folder.

Note
titleBe carefull!

When specifying exclusions directly for each tool, you should also consider to set the 'sonar.exclusions' property accordingly. Otherwise, you may have files with incomplete analysis.

 

How do I disable unit test & coverage reporting?

The easiest way to disable unit test reporting is to use the following standard Sonar property:

Code Block
sonar.dynamicAnalysis=false

If you want to disable only unit test reporting or coverage reporting, you can use the following properties instead:

Code Block
sonar.phpUnit.skip=true
sonar.phpUnit.coverage.skip=true