jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
Signup
Sonar Plugins
  • Sonar Plugins
  • SONARPLUGINS-514

PDepend analyze fails

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: PHP-0.2
  • Fix Version/s: PHP-0.2
  • Component/s: PHP
  • 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`.

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. XML File
    pdepend.xml
    14/May/10 2:25 AM
    4 kB
    Noel GUILBERT

Issue Links

is duplicated by

Bug - A problem which impairs or prevents the functions of the product. SONARPLUGINS-518 sonar-php-depend failed

  • Major - Major loss of function.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Noel GUILBERT added a comment - 12/May/10 5:08 AM

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 - 12/May/10 5:08 AM 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
Permalink
Olivier Gaudin added a comment - 13/May/10 7:15 AM

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 - 13/May/10 7:15 AM 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
Permalink
Noel GUILBERT added a comment - 14/May/10 2:25 AM

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

Show
Noel GUILBERT added a comment - 14/May/10 2:25 AM Here is my pdepend result file, and as you can see the "name" attributes are correctly filled.
Hide
Permalink
Olivier Gaudin added a comment - 14/May/10 12:50 PM

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 - 14/May/10 12:50 PM 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:
    Noel GUILBERT
Vote (0)
Watch (0)

Dates

  • Created:
    11/May/10 8:53 AM
    Updated:
    15/Jul/10 6:59 AM
    Resolved:
    27/May/10 4:15 AM
  • Atlassian JIRA (v5.2.7#850-sha1:b2af0c8)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.