Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
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 :
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
- is duplicated by
-
SONARPLUGINS-518
sonar-php-depend failed
-
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