0

I would like to create a quality profile in SonarQube that extends PSR2 rules. When I create one using this xml below, sonar shows me the following error:

Unable to import unknown PhpCodeSniffer rule 'PSR2' consider adding an extension in sonar extenions directory

<?xml version="1.0"?>
<ruleset name="test">
    <description>test coding standard (extend PSR2).</description>

    <!-- Include the whole PSR-2 standard -->
    <rule ref="PSR2">
        <exclude name="Generic.Files.LineLength" />
    </rule>

    <!-- Include pear commenting standards -->
    <rule ref="PEAR.Commenting.InlineComment"/>

</ruleset>

I have installed sonar 3.7.4 with PHP plugin and PHP_CodeSniffer using pear. CodeSniffer came with following standards:

$ phpcs -i
The installed coding standards are MySource, PEAR, PHPCS, PSR1, PSR2, Squiz and Zend

Am I missing some configuration in sonar? What should I do to be able to create the quality profile I want?

Michał Nowak
  • 1,686
  • 1
  • 12
  • 17

1 Answers1

0

Sonar php plugin 2.2 supports PSR-2.

Also, from plugin version 2.0,

Dependency on external tools has been removed: i.e PHPDepend, PHPCodeSniffer, PHPMD, PHPUnit.

These work with sonar-3.7 and above.

Raghuram
  • 51,854
  • 11
  • 110
  • 122