Details
Description
It is desirable to be able to import an existing code coverage report (from a Flex project) and display it in Sonar. Currently, the Sonar core only allows for Java based reports to be displayed.
-
- coverage.xml
- 28/Mar/11 3:19 PM
- 1 kB
- Tony Georgiev
-
- sonar-flex-cobertura-patch
- 23/Mar/11 5:24 PM
- 17 kB
- Tony Georgiev
-
Hide
- sonar-flex-plugin-0.3.1-Cobertura.jar
- 23/Mar/11 11:53 AM
- 73 kB
- Tony Georgiev
-
- META-INF/MANIFEST.MF 0.7 kB
- org/.../AbstractCoberturaParser$1.class 2 kB
- org/.../AbstractCoberturaParser$FileData.class 4 kB
- org/sonar/.../AbstractCoberturaParser.class 7 kB
- org/.../CoberturaMavenPluginHandler.class 3 kB
- org/sonar/.../CoberturaSensor$1.class 1 kB
- org/sonar/.../CoberturaSensor.class 3 kB
- org/sonar/.../cobertura/CoberturaUtils.class 2 kB
- org/sonar/.../FlexColorizerFormat.class 1 kB
- org/sonar/.../colorizer/FlexKeywords.class 2 kB
- org/.../FlexCpdMavenPluginHandler.class 2 kB
- org/sonar/.../cpd/FlexCpdMavenSensor$1.class 0.3 kB
- org/.../FlexCpdMavenSensor$ClassDuplicationData.class 4 kB
- org/sonar/.../cpd/FlexCpdMavenSensor.class 7 kB
- org/sonar/plugins/flex/Flex.class 1 kB
- org/sonar/plugins/flex/FlexFile.class 5 kB
- org/.../FlexMetricsMavenPluginHandler.class 1 kB
- org/sonar/.../FlexMetricsSensor.class 9 kB
- org/sonar/plugins/flex/FlexPackage.class 2 kB
- org/sonar/plugins/flex/FlexPlugin.class 3 kB
- org/sonar/.../default-flex-profile.xml 42 kB
- org/.../FlexPmdMavenPluginHandler.class 3 kB
- org/.../FlexPmdRulePriorityMapper.class 2 kB
- org/sonar/.../FlexPmdRulesRepository.class 9 kB
- org/sonar/.../flexpmd/FlexPmdSensor.class 3 kB
- org/.../FlexPmdViolationsXmlParser.class 3 kB
- org/sonar/plugins/flex/flexpmd/rules.xml 41 kB
- org/sonar/plugins/.../xml/FlexRule.class 3 kB
- org/sonar/.../xml/FlexRulesUtils.class 3 kB
- org/sonar/plugins/.../xml/Property.class 0.8 kB
-
Hide
- SonarFlexPluginWithCobertura.zip
- 23/Mar/11 11:53 AM
- 62 kB
- Tony Georgiev
-
- pom.properties 0.1 kB
- pom.xml 7 kB
- src/main/.../AbstractCoberturaParser.java 7 kB
- src/.../CoberturaMavenPluginHandler.java 2 kB
- src/main/.../cobertura/CoberturaSensor.java 3 kB
- src/main/.../cobertura/CoberturaUtils.java 3 kB
- src/main/.../FlexColorizerFormat.java 2 kB
- src/main/.../colorizer/FlexKeywords.java 3 kB
- src/main/.../FlexCpdMavenPluginHandler.java 2 kB
- src/main/.../cpd/FlexCpdMavenSensor.java 7 kB
- src/main/java/org/.../plugins/flex/Flex.java 2 kB
- src/main/java/.../plugins/flex/FlexFile.java 6 kB
- src/.../FlexMetricsMavenPluginHandler.java 1 kB
- src/main/.../FlexMetricsSensor.java 8 kB
- src/main/java/.../flex/FlexPackage.java 2 kB
- src/main/java/.../flex/FlexPlugin.java 3 kB
- src/main/.../FlexPmdMavenPluginHandler.java 2 kB
- src/main/.../FlexPmdRulePriorityMapper.java 2 kB
- src/main/.../FlexPmdRulesRepository.java 6 kB
- src/main/java/.../flexpmd/FlexPmdSensor.java 3 kB
- src/main/.../FlexPmdViolationsXmlParser.java 3 kB
- src/main/java/.../flexpmd/xml/FlexRule.java 3 kB
- src/main/java/.../xml/FlexRulesUtils.java 3 kB
- src/main/java/.../flexpmd/xml/Property.java 1 kB
- src/main/java/.../flexpmd/xml/Ruleset.java 2 kB
- src/main/.../flex/FlexSourceImporter.java 1 kB
- src/main/java/.../flex/FlexUtils.java 1 kB
- src/main/java/.../squid/FlexFootprint.java 1 kB
- src/main/.../squid/FlexNoSonarFilter.java 2 kB
- src/main/java/.../squid/FlexRecognizer.java 1 kB
-
Hide
- TestSonarFlexProject.zip
- 28/Mar/11 3:19 PM
- 23 kB
- Tony Georgiev
-
- .actionScriptProperties 1 kB
- .flexProperties 0.2 kB
- .project 0.5 kB
- html-template/history/history.css 0.4 kB
- html-template/history/history.js 26 kB
- html-template/history/historyFrame.html 0.8 kB
- html-template/index.template.html 6 kB
- html-template/playerProductInstall.swf 0.6 kB
- html-template/swfobject.js 26 kB
- pom.xml 3 kB
- src/main/.../BasicArithmeticOperations.as 0.4 kB
- src/main/flex/TestSonar.mxml 0.4 kB
- src/.../BasicArithmeticOperationsTest.as 0.6 kB
Issue Links
- relates to
-
SONARPLUGINS-667
Show code coverage
-
Activity
Might be useful : https://docs.sonatype.org/display/FLEXMOJOS/Test+coverage+support
Flexmojos 4.x has some nice coverage support but is still missing some essential goals from previous versions of FlexMojos (i.e. flexbuilder).
Vincen,
Thank you for the notification, but I've already created issue for integration with Flexmojos 4.x - SONARPLUGINS-667.
I've tried to use flexmojos-maven-plugin 4.0-alpha-6, but unsuccessfully. So, I don't think that we should try to integrate it right now - it's better to wait official release.
Moreover flexmojos 4.x requires Maven 3.x, but Sonar didn't support it yet.
Even though flex mojos will support test coverage I think it's still important to support the reusing of reports (especially surefire and cobertura, but pmd, cpd and ncss would be nice bonus).
Why? Well, many flex projects use Ant and generate surefire / pmd reports already (i'm looking on how to get cobertura working too). It would be very nice if those projects could use all features of this very cool Sonar plugin! I.e. let the plugin use the reports available instead of generating them. This would be more efficient as the reports don't have to be regenerated. By allowing configuration like Vincen described in it's first comment this would be possible.
Much more Flex projects could benefit this way. (Just add a small sonar pom with reuse reports config).
Arnoud
Hi Arnoud,
I perfectly understanding your motivation for reusing reports, but have a look to the following ticket to understand why we have started to depreciate all mechanisms to import existing reports : SONAR-1873
Hi Evgeny,
Thanks for the fast reply!
I looked at the issue you mentioned and understand the reasons for removing sonar.reuseExistingRulesConfiguration. But I don't understand why this is considered the same as reusing reports. So yeah, I definitely agree that rules should be managed in Sonar and that you want to manage the quality profiles in sonar too. This is described in the issue you mentioned. But I think this is a different issue (or maybe i just don't understand it
).
Let me explain:
Suppose that vanilla flex-mojos (without sonar) generates a cobertura.xml report. That will be the same as the one generated by Sonar using flex-mojos, right? But after this step the processing (sonar rules + standard reports = advanced quality control) takes place. At least this is how I understand it.
Why then reusing standardized reports like cobertura and surefire could be any harm or break consistency I fail to understand. (pmd is a different story as it has rules as input, which you probably want to manage / control in the sonar IDE).
all the best,
Arnoud
Correct – I too don't see how removing the ability to reuse unit test and coverage reports will cause problems with consistency.
Josh
Hi guys,
Sorry - that was my mistake : reuse of rules configuration was deprecated, but not reuse of coverage reports. So we can implement this feature.
I also want this feature in the Flex plugin for Sonar. In the meantime I have modified the original plugin so that it adds this support. I have used the the latest code for the flex plugin (sonar-flex-plugin-0.3.1) and the source from the cobertura plugin (sonar-cobertura-plugin-2.4.1). It is not much, it is just a small modification in the cobertura source files as I followed what was done with surefire to make this. I am attaching binary and also source files. I don't think it is the best solution, but it is more like a workaround while an official release appears. I will post some instructions on how to use it later today or tomorrow on my blog (http://tgeorgiev.blogspot.com), you can check it.
Tony
Hi Tony,
Could you please provide real patch for trunk version instead of full sources? In this case it would be much easy to review and integrate.
Hi Evgeny,
My bad, I am providing the patch against the trunk version
Hi Tony,
I reworked your patch in order to not duplicate code from Sonar Cobertura Plugin - r3587. Could you please provide example of Cobertura report for Flex project to test this implementation?
Hi Evgeny,
I am really glad that things are going on. I am attaching the Flex test project and the Cobertura coverage.xml that was generated from it. It should display 66% coverage for BasicArithmeticOperations class
Best
Not very clear for me - why provided report mentions files with extension ".java", whereas should be ".as" and ".mxml" ?
However I've added unit test - r3595.
So could you please try to use version from trunk?
I have tried but it seems that the Cobertura Sensor doesn't execute. I assume that also the Cobertura handler has to be added to the list of extensions in FlexPlugin.java
As for the coverage.xml, it is not clear to me also, as it is generated by FlexMojos. I assume that it is like that to keep consistency. However it does not interfere with the report
If you talk about MavenPluginHandler, then you're wrong, because it's used for Maven plugin execution, but we talk about report reuse mode.
Seems that I know why Sensor not executed - I'll take some time tomorrow to investigate this. Any way thanks for your help.
Awesome – THANKS guys! I'm looking very forward to reusing Cobertura reports for flex!
So can I use Cobertura for Flex now? Is this fixed in 0.4? If so, can you provide some sample config? I have tried using flexmojos 4.x <coverage>true</coverage> but this generates a parse exception as follows:
net.sourceforge.cobertura.javancss.parser.ParseException: Encountered " "<" "< "" at line 1, column 1.
Was expecting one of:
"abstract" ...
"class" ...
"enum" ...
"final" ...
"import" ...
"interface" ...
"native" ...
"package" ...
"private" ...
"protected" ...
"public" ...
"static" ...
"strictfp" ...
"synchronized" ...
"transient" ...
"volatile" ...
";" ...
"@" ...
"@" ...
"@" ...
"@" ...
"package" ...
at net.sourceforge.cobertura.javancss.parser.JavaParser.generateParseException(JavaParser.java:10296)
at net.sourceforge.cobertura.javancss.parser.JavaParser.jj_consume_token(JavaParser.java:10172)
at net.sourceforge.cobertura.javancss.parser.JavaParser.CompilationUnit(JavaParser.java:455)
at net.sourceforge.cobertura.javancss.parser.JavaParser.parse(JavaParser.java:137)
at net.sourceforge.cobertura.javancss.Javancss._measureSource(Javancss.java:256)
at net.sourceforge.cobertura.javancss.Javancss._measureRoot(Javancss.java:339)
at net.sourceforge.cobertura.javancss.Javancss.(Javancss.java:419)
at net.sourceforge.cobertura.reporting.ComplexityCalculator.getAccumlatedCCNForSource(ComplexityCalculator.java:102)
Hi,
This was implemented in 0.4 and was tested with Flex Mojos 3.6.1.
If you have problems, then please switch to users mailing list in order to investigate them.
We are also seeing this issue. Setting sonar.dynamicAnalysis to reuseReports does not work with a sonar.language of flex.
<sonar.language>flex</sonar.language>
{instrument.report.cobertura}<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis><sonar.cobertura.reportPath>$
</sonar.cobertura.reportPath>
{report.xunit.loc}<sonar.surefire.reportsPath>$
</sonar.surefire.reportsPath>