Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 0.2
    • Fix Version/s: 0.2
    • Component/s: None
    • Labels:
      None
    • Environment:
      Debian Lenny, PHP 5.2.13-0.dotdeb.1 with Suhosin-Patch 0.9.7, maven 2, PDepend 0.9.13, Sonar 2.1.1, latest sonar-php (built with maven from svn)
    • Number of attachments :
      1

      Description

      Hi,

      I tried to run an analyze on a simple symfony project, and I got this error just after the pdepend analyze:

      [INFO]  pdepend ended with returned code '0'.
      [INFO]  Collecting measures...
      [WARN]  The following file doesn't belong to current project sources or tests :
      [ERROR]  Report file is invalid or can't be found, plugin will stop.
      java.lang.IllegalArgumentException: This measure has already been saved: org.sonar.api.measures.Measure@1e11d82[id=<null>,metric=org.sonar.api.measures.Metric@586ac6[key=class_complexity_distribution,name=Classes distribution /complexity,type=DISTRIB,enabled=true,qualitative=true,direction=0,domain=Complexity,worstValue=<null>,bestValue=<null>,optimizedBestValue=<null>,hidden=false],value=<null>,data=0=1;5=0;10=0;20=0;30=0;60=0;90=0,description=<null>,alertStatus=<null>,alertText=<null>,tendency=<null>,diff1=<null>,diff2=<null>,diff3=<null>],resource: org.sonar.plugins.php.core.resources.PhpFile@bac048fd
              at org.sonar.batch.indexer.DefaultSonarIndex.addMeasure(DefaultSonarIndex.java:266) [sonar-batch-2.1.1.jar:na]
              at org.sonar.batch.indexer.DefaultSonarIndex.saveMeasure(DefaultSonarIndex.java:257) [sonar-batch-2.1.1.jar:na]
              at org.sonar.batch.DefaultSensorContext.saveMeasure(DefaultSensorContext.java:94) [sonar-batch-2.1.1.jar:na]
      ...
      

      After some search, it's seems this problem occured when several files have the save base name: in a symfony project, all the controllers files are named actions.class.php. If I have only one module, or if I rename the file (e.g actionsA.class.php), this issue disappear.

      How to reproduce the bug:

      create a simple symfony project:
      symfony generate:project test_project
      symfony generate:app frontend
      symfony generate:module frontend foo
      symfony generate:module frontend bar

      My pom.xml:

      <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.test.app</groupId>
        <artifactId>test_project</artifactId>
        <name>test_project</name>
        <packaging>php</packaging>
        <version>0.1</version>
        <build>
              <sourceDirectory>./</sourceDirectory>
              <plugins>
                 <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.5</source>
                        <target>1.5</target>
                    </configuration>
                 </plugin>
              </plugins>
        </build>
        <properties>
          <sonar.language>php</sonar.language>
          <sonar.cpd.php.skip>true</sonar.cpd.php.skip>
          <!--sonar.dynamicAnalysis>false</sonar.dynamicAnalysis-->
        </properties>
      </project>
      

      And then run `maven sonar:sonar`.

        Issue Links

          Activity

          Hide
          Noel GUILBERT added a comment -

          I resolved this issue by modifying the following code in PhpDependResultsParser:

          Index: php-depend/src/main/java/org/sonar/plugins/php/phpdepend/sensor/PhpDependResultsParser.java
          ===================================================================
          --- php-depend/src/main/java/org/sonar/plugins/php/phpdepend/sensor/PhpDependResultsParser.java (révision 1649)
          +++ php-depend/src/main/java/org/sonar/plugins/php/phpdepend/sensor/PhpDependResultsParser.java (copie de travail)
          @@ -218,8 +218,9 @@
                   collectFunctionsMeasures(funcNode, file, methodComplexityDistribution);
                 }
               }
          -    context.saveMeasure(new PhpFile(file.getName()), classComplexityDistribution.build().setPersistenceMode(PersistenceMode.MEMORY));
          -    context.saveMeasure(new PhpFile(file.getName()), methodComplexityDistribution.build().setPersistenceMode(PersistenceMode.MEMORY));
          +
          +    context.saveMeasure(new PhpFile(fileNode.getFileName()), classComplexityDistribution.build().setPersistenceMode(PersistenceMode.MEMORY));
          +    context.saveMeasure(new PhpFile(fileNode.getFileName()), methodComplexityDistribution.build().setPersistenceMode(PersistenceMode.MEMORY));
             }
          
             /**
          

          Hope this help.

          Noel

          Show
          Noel GUILBERT added a comment - I resolved this issue by modifying the following code in PhpDependResultsParser : Index: php-depend/src/main/java/org/sonar/plugins/php/phpdepend/sensor/PhpDependResultsParser.java =================================================================== --- php-depend/src/main/java/org/sonar/plugins/php/phpdepend/sensor/PhpDependResultsParser.java (révision 1649) +++ php-depend/src/main/java/org/sonar/plugins/php/phpdepend/sensor/PhpDependResultsParser.java (copie de travail) @@ -218,8 +218,9 @@ collectFunctionsMeasures(funcNode, file, methodComplexityDistribution); } } - context.saveMeasure( new PhpFile(file.getName()), classComplexityDistribution.build().setPersistenceMode(PersistenceMode.MEMORY)); - context.saveMeasure( new PhpFile(file.getName()), methodComplexityDistribution.build().setPersistenceMode(PersistenceMode.MEMORY)); + + context.saveMeasure( new PhpFile(fileNode.getFileName()), classComplexityDistribution.build().setPersistenceMode(PersistenceMode.MEMORY)); + context.saveMeasure( new PhpFile(fileNode.getFileName()), methodComplexityDistribution.build().setPersistenceMode(PersistenceMode.MEMORY)); } /** Hope this help. Noel
          Hide
          Olivier Gaudin added a comment -

          I believe there is no need to do a new PhpFile actually as it is passed to the method as a parameter already.

          I had a similar issue when analyzing phpMyAdmin-3.3.2-all-languages. In the phpdepend result file, it has an entry with <file name="" classes="78" functions="0">. The fix should also fix this but I have not verified.

          Show
          Olivier Gaudin added a comment - I believe there is no need to do a new PhpFile actually as it is passed to the method as a parameter already. I had a similar issue when analyzing phpMyAdmin-3.3.2-all-languages. In the phpdepend result file, it has an entry with <file name="" classes="78" functions="0">. The fix should also fix this but I have not verified.
          Hide
          Noel GUILBERT added a comment -

          Here is my pdepend result file, and as you can see the "name" attributes are correctly filled.

          Show
          Noel GUILBERT added a comment - Here is my pdepend result file, and as you can see the "name" attributes are correctly filled.
          Hide
          Olivier Gaudin added a comment -

          Sorry I was not clear. The same error happens for two different reasons : if there are 2 files with the same name in the project (that is your case and your patch is perfect) and also when there is a name="" in the original file. It might be better actually to fill an other Jira issue...

          Show
          Olivier Gaudin added a comment - Sorry I was not clear. The same error happens for two different reasons : if there are 2 files with the same name in the project (that is your case and your patch is perfect) and also when there is a name="" in the original file. It might be better actually to fill an other Jira issue...

            People

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

              Dates

              • Created:
                Updated:
                Resolved: