SonarQube PHP
  1. SonarQube PHP
  2. SONARPHP-58

Settings for exclude directorys and files not honored

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 0.3, 0.4
    • Fix Version/s: 0.4
    • Component/s: None
    • Labels:
      None
    • Environment:
      Ubuntu 10.04
    • Number of attachments :
      0

      Description

      The exclude directory settings are not being respected:

      1. By the php tools (pdepend, phpcs, etc)
      2. By Sonar (excluded code is appearing in the project, even if tools are run manually)

      
      

      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.neoscopio</groupId>
      <artifactId>Drupal.Baan</artifactId>
      <name>Drupal Baan</name>
      <version>6.0</version>
      <!-- For the moment, specify pom as packaging for php projects -->
      <packaging>pom</packaging>

      <!-- some properties that you may want to change -->
      <properties>
      <sonar.language>php</sonar.language>
      <!-- <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis> -->

      <sonar.phpPmd.shouldRun >true</sonar.phpPmd.shouldRun>
      <sonar.phpPmd.analyzeOnly >false</sonar.phpPmd.analyzeOnly>
      <sonar.phpCodesniffer.shouldRun>true</sonar.phpCodesniffer.shouldRun>
      <sonar.phpCodesniffer.analyzeOnly>false</sonar.phpCodesniffer.analyzeOnly>
      <sonar.phpDepend.shouldRun>true</sonar.phpDepend.shouldRun>
      <sonar.phpDepend.analyzeOnly>false</sonar.phpDepend.analyzeOnly>
      <sonar.phpUnit.coverage.analyzeOnly>true</sonar.phpUnit.coverage.analyzeOnly>
      <sonar.phpUnit.analyzeOnly>true</sonar.phpUnit.analyzeOnly>
      <sonar.phpcpd.analyzeOnly>false</sonar.phpcpd.analyzeOnly>
      <sonar.phpcpd.shouldRun>true</sonar.phpcpd.shouldRun>
      <sonar.exclusions>/home/alienation/projects/sonar/drupal-core-drupal/sites/all/modules/drupal-core/baan/baan_representante/php5-ofc-library,/home/alienation/projects/sonar/drupal-core-drupal/sites/all/modules/drupal-core/baan/baan_representa$
      <sonar.php.file.suffixes>php,inc,module</sonar.php.file.suffixes>
      </properties>

      <build>
      <!-- You cannot omit this one, because maven will implicitely add src/main/java
      to it -->
      <sourceDirectory>$

      {basedir}</sourceDirectory>
      <testSourceDirectory>${basedir}

      /sonardir</testSourceDirectory>

      </build>

      </project>

      
      
       
      $ mvn -e sonar:sonar
      + Error stacktraces are turned on.
      [INFO] Scanning for projects...
      [INFO] Searching repository for plugin with prefix: 'sonar'.
      [INFO] Ignoring available plugin update: 2.0-beta-2 as it requires Maven version 3.0
      [INFO] Ignoring available plugin update: 2.0-beta-1 as it requires Maven version 3.0
      [INFO] ------------------------------------------------------------------------
      [INFO] Building Drupal Baan
      [INFO]    task-segment: [sonar:sonar] (aggregator-style)
      [INFO] ------------------------------------------------------------------------
      [INFO] [sonar:sonar {execution: default-cli}]
      [INFO] Sonar host: http://localhost:9000
      [INFO] Sonar version: 2.5
      [INFO] Execute: org.codehaus.sonar:sonar-maven-plugin:2.5:sonar
      [INFO] [sonar:sonar {execution: default-sonar}]
      [INFO]  Database dialect class org.sonar.jpa.dialect.Derby
      [INFO]  -------------  Analyzing Drupal Baan
      [INFO]  Excluded sources : [/home/alienation/projects/sonar/drupal-core-drupal/sites/all/modules/drupal-core/baan/baan_representante/php5-ofc-library, /home/alienation/projects/sonar/drupal-core-drupal/sites/all/modules/drupal-core/baan/baan_representante/php-ofc-library]
      [INFO]  Selected quality profile : [name=PHP_CodeSniffer rules,language=php]
      [INFO]  Compare to previous analysis  (2011-02-13 17:44:18.178)
      [INFO]  Compare over 5 days (2011-02-13 17:31:19.453)
      [INFO]  Compare over 30 days (2011-02-13 17:31:19.453)
      [INFO]  Detection of duplication code is not supported for PHP.
      [INFO]  Configure maven plugins...
      [INFO]  Sensor AsynchronousMeasuresSensor...
      [INFO]  Sensor AsynchronousMeasuresSensor done: 284 ms
      [INFO]  Sensor PhpSourceImporter[getLanguage()=PHP,getClass()=class org.sonar.plugins.php.core.PhpSourceImporter]...
      [INFO]  Importing files from project Drupal Baan
      [INFO]  drupal-core
      [INFO]  sonardir
      [INFO]  Sensor PhpSourceImporter[getLanguage()=PHP,getClass()=class org.sonar.plugins.php.core.PhpSourceImporter] done: 4653 ms
      [INFO]  Sensor org.sonar.plugins.php.core.NoSonarAndCommentedOutLocSensor@d77f83...
      [INFO]  Sensor org.sonar.plugins.php.core.NoSonarAndCommentedOutLocSensor@d77f83 done: 637 ms
      [INFO]  Sensor ProfileSensor...
      [INFO]  Sensor ProfileSensor done: 0 ms
      [INFO]  Sensor ProjectLinksSensor...
      [INFO]  Sensor ProjectLinksSensor done: 28 ms
      [INFO]  Sensor VersionEventsSensor...
      [INFO]  Sensor VersionEventsSensor done: 42 ms
      [INFO]  Sensor Maven dependencies...
      [INFO]  Sensor Maven dependencies done: 6 ms
      [INFO]  Sensor PhpCodesnifferSensor...
      [INFO]  Report file for: phpcs : /home/alienation/projects/sonar/drupal-core-drupal/sites/all/modules/drupal-core/target/logs/codesniffer.xml
      [INFO]  Executing PHPCodeSniffer with command 'phpcs --report-file=/home/alienation/projects/sonar/drupal-core-drupal/sites/all/modules/drupal-core/target/logs/codesniffer.xml --report=checkstyle --standard=Pear --extensions=php,inc,module /home/alienation/projects/sonar/drupal-core-drupal/sites/all/modules/drupal-core'
      [INFO]  PHPCodeSniffer ended with returned code '1'.
      [INFO]  Report file for: phpcs : /home/alienation/projects/sonar/drupal-core-drupal/sites/all/modules/drupal-core/target/logs/codesniffer.xml
      [INFO]  PhpCodeSniffer  report file: /home/alienation/projects/sonar/drupal-core-drupal/sites/all/modules/drupal-core/target/logs/codesniffer.xml
      [INFO]  No violation found in repository php_codesniffer_rules for violation PEAR.WhiteSpace.ScopeIndent.Incorrect
      [INFO]  No violation found in repository php_codesniffer_rules for violation Generic.ControlStructures.InlineControlStructure.Discouraged
      [INFO]  Sensor PhpCodesnifferSensor done: 225948 ms
      [INFO]  Sensor PHP Depend Sensor...
      [INFO]  Report file for: pdepend : /home/alienation/projects/sonar/drupal-core-drupal/sites/all/modules/drupal-core/target/logs/pdepend.xml
      [INFO]  Executing pdepend with command 'pdepend --phpunit-xml=/home/alienation/projects/sonar/drupal-core-drupal/sites/all/modules/drupal-core/target/logs/pdepend.xml --suffix=php,inc,module /home/alienation/projects/sonar/drupal-core-drupal/sites/all/modules/drupal-core'
      [INFO]  pdepend ended with returned code '0'.
      [INFO]  Report file for: pdepend : /home/alienation/projects/sonar/drupal-core-drupal/sites/all/modules/drupal-core/target/logs/pdepend.xml
      [INFO]  Collecting measures...
      [WARN]  The following file doesn't belong to current project sources or tests :
      [INFO]  Saving measures...
      [INFO]  Sensor PHP Depend Sensor done: 103784 ms
      [INFO]  Sensor org.sonar.plugins.php.cpd.PhpCpdSensor@1ab8f3f...
      [INFO]  Report file for: phpcpd : /home/alienation/projects/sonar/drupal-core-drupal/sites/all/modules/drupal-core/target/logs/php-cpd.xml
      [INFO]  Executing phpcpd with command 'phpcpd --min-lines 3 --min-tokens 5 --log-pmd /home/alienation/projects/sonar/drupal-core-drupal/sites/all/modules/drupal-core/target/logs/php-cpd.xml --suffixes php,inc,module /home/alienation/projects/sonar/drupal-core-drupal/sites/all/modules/drupal-core'
      [INFO]  phpcpd ended with returned code '1'.
      [INFO]  Report file for: phpcpd : /home/alienation/projects/sonar/drupal-core-drupal/sites/all/modules/drupal-core/target/logs/php-cpd.xml
      [INFO]  Collecting measures...
      [INFO]  Sensor org.sonar.plugins.php.cpd.PhpCpdSensor@1ab8f3f done: 23937 ms
      [INFO]  Execute decorators...
      [INFO]  ANALYSIS SUCCESSFUL, you can browse http://localhost:9000
      [INFO]  Executing post-job class org.sonar.plugins.dbcleaner.runner.PurgeRunner
      [INFO]  Database optimization...
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.PurgeOrphanResources...
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.PurgeOrphanResources done: 28 ms
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.PurgeEntities...
      [INFO]  Deleting files data before Sun Feb 13 07:37:05 WET 2011
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.PurgeEntities done: 83 ms
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.PurgeRuleMeasures...
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.PurgeRuleMeasures done: 35613 ms
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.PurgeUnprocessed...
      [INFO]  Deleting unprocessed data before Sun Feb 13 07:37:41 WET 2011
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.PurgeUnprocessed done: 31 ms
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.PurgeDeletedResources...
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.PurgeDeletedResources done: 14 ms
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.PurgeDeprecatedLast...
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.PurgeDeprecatedLast done: 23 ms
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.UnflagLastDoublons...
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.UnflagLastDoublons done: 32 ms
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.PurgeDisabledResources...
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.PurgeDisabledResources done: 27 ms
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.PurgeResourceRoles...
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.PurgeResourceRoles done: 31 ms
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.PurgeEventOrphans...
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.PurgeEventOrphans done: 47 ms
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.PurgePropertyOrphans...
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.PurgePropertyOrphans done: 107 ms
      [INFO]  Purge org.sonar.plugins.dbcleaner.period.PeriodPurge...
      [INFO]  There are no snapshots to purge
      [INFO]  Purge org.sonar.plugins.dbcleaner.period.PeriodPurge done: 93 ms
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.PurgeDependencies...
      [INFO]  Purge org.sonar.plugins.dbcleaner.purges.PurgeDependencies done: 41 ms
      [INFO]  Database optimization done: 36190 ms
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD SUCCESSFUL
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 8 minutes 46 seconds
      [INFO] Finished at: Sun Feb 13 19:37:41 WET 2011
      [INFO] Final Memory: 18M/295M
      [INFO] ------------------------------------------------------------------------
      

        Issue Links

          Activity

          Hide
          Akram Ben Aissi added a comment -

          Starting to implement it properly on pdepend tool.
          Checking why metrics are also inserted if the file is excluded by sonar source importer.

          Show
          Akram Ben Aissi added a comment - Starting to implement it properly on pdepend tool. Checking why metrics are also inserted if the file is excluded by sonar source importer.
          Hide
          Akram Ben Aissi added a comment -

          Rely on projectFileSystem.getSourceFiles() to determine if a file is in a project or not
          The sonar.phpDepend.ignore now works in conjunction with the sonar.exclusions option.
          If one or both are set, the file patterns to exclude are passed to pdepend.

          This causes pdepend to not compute metrics on file pointed by these patterns.
          And in case of reusing existing reports, files that are marked as sonar exclusions are not added to dahsboard.

          Show
          Akram Ben Aissi added a comment - Rely on projectFileSystem.getSourceFiles() to determine if a file is in a project or not The sonar.phpDepend.ignore now works in conjunction with the sonar.exclusions option. If one or both are set, the file patterns to exclude are passed to pdepend. This causes pdepend to not compute metrics on file pointed by these patterns. And in case of reusing existing reports, files that are marked as sonar exclusions are not added to dahsboard.
          Hide
          Miguel Andrade added a comment -

          thanks!

          Show
          Miguel Andrade added a comment - thanks!

            People

            • Assignee:
              Akram Ben Aissi
              Reporter:
              Anonymous
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: