-
Bug
-
Resolution: Fixed
-
Major
-
Powered by SuggestiMate -
5.0.0-beta2
ScalaStyle is a tool fulfilling more or less the same role as CheckStyle. But then for the Scala programming language.
It seems to piggyback on the format of Checkstyle. An example is provided in this ticket.
Those warnings are not picked up by the plugin. Presumably because it is a separate file ?
Merging the warnings into checkstyle-result.xml via scripting in a post-build step does not help either. For some reason the scala files are not shown. Maybe it's because ScalaStyle uses warning id unknown to CheckStyle.
merged.xml : an example of CheckStyle and ScalaStyle warnings merged into one file. An attempt to sneak in the Scala warnings. Alas, they don't appear.
scalastyle-output.xml : an example of the warnings ScalaStyle generates.
[JENKINS-17287] Provide support for ScalaStyle warnings
Jan, can you please check the console log of your build (there should be some [CHECKSTYLE] messages). I added a unit test that simply parses your file: it worked out of the box! I.e., it should already work in your case. What file pattern did you specify? (Or did you use a maven job type?)
It is a maven job indeed.
This is what I get on the console:
[CHECKSTYLE] Parsing file /home/jenkins/.jenkins/jobs/Static_code_analysis/workspace/web/target/checkstyle-result.xml
[CHECKSTYLE] Successfully parsed file /home/jenkins/.jenkins/jobs/Static_code_analysis/workspace/web/target/checkstyle-result.xml of module Optimus web application with 4 warnings.
[CHECKSTYLE] Computing warning deltas based on reference build #134
ScalaStyle generates scalastyle_output.xml in the same directory as checkstyle-result.xml.
Maybe it a matter of precedence ? It surely looks like I'm patching checkstyle-result.xml on time. But maybe that's not the case.
Ok, then I understand why it does not work In maven, I read information from the pom to determine the goal and the filename. Can you please attach the corresponding logging output from your maven build, so I can adapt that part of the code (something like checkstyle:checkstyle ...).
In the meantime as a workaround: switch to a freestyle project. There you can specify the correct file name.
(What still is missing: support for the message texts. Since these are in a different format this needs a new message parser).
I'm not exactly sure what you mean - the output of checkstyle:checkstyle is always those three lines, for each module. (it's a multi-module btw)
But since you parse the pom for the name of the file, I guess this is what you want ?
<plugin>
<groupId>org.scalastyle</groupId>
<artifactId>scalastyle-maven-plugin</artifactId>
<version>0.2.0</version>
<configuration>
<verbose>true</verbose>
<failOnViolation>false</failOnViolation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<failOnWarning>false</failOnWarning>
<sourceDirectory>${basedir}/src/main/scala</sourceDirectory>
<testSourceDirectory>${basedir}/src/test/scala</testSourceDirectory>
<configLocation>${scalastyle.config}</configLocation>
<outputFile>${project.basedir}/target/scalastyle-output.xml</outputFile>
<outputEncoding>UTF-8</outputEncoding>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
Actually I need the output of your build when you invoke the scalastyle goal:
[INFO] [INFO] --- maven-checkstyle-plugin:2.9.1:checkstyle (default-cli) @ checkstyle --- [INFO] [WARNING] Unable to locate Source XRef to link to - DISABLED [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 19.944s [INFO] Finished at: Wed Mar 20 17:13:10 CET 2013 [INFO] Final Memory: 26M/229M
Or is there an example maven project somewhere available that I can use for tests (since I don't have a Scala maven project yet).
There you are
[INFO] — scalastyle-maven-plugin:0.2.0:check (default-cli) @ web —
Processing Configuration for child elements
Processing child [configLocation]
Processing child [outputFile]
Processing child [outputEncoding]
Processing child [failOnViolation]
Processing child [failOnWarning]
Processing child [skip]
Processing child [verbose]
Processing child [quiet]
Processing child [sourceDirectory]
Processing child [testSourceDirectory]
Processing child [includeTestSourceDirectory]
Processing child [buildDirectory]
Processing child [baseDirectory]
Processing child [inputEncoding]
[WARNING] sourceDirectory is not specified or does not exist value=/home/jenkins/.jenkins/jobs/Static_code_analysis/workspace/web/src/main/scala
Starting scalastyle
start file /home/jenkins/.jenkins/jobs/Static_code_analysis/workspace/web/src/test/scala/com/noesis/optimus/web/ScalatestLearningTest.scala
warning file=/home/jenkins/.jenkins/jobs/Static_code_analysis/workspace/web/src/test/scala/com/noesis/optimus/web/ScalatestLearningTest.scala message=Header does not match expected text line=1
warning file=/home/jenkins/.jenkins/jobs/Static_code_analysis/workspace/web/src/test/scala/com/noesis/optimus/web/ScalatestLearningTest.scala message=Whitespace at end of line line=33 column=20
end file /home/jenkins/.jenkins/jobs/Static_code_analysis/workspace/web/src/test/scala/com/noesis/optimus/web/ScalatestLearningTest.scala
Saving to outputFile=/home/jenkins/.jenkins/jobs/Static_code_analysis/workspace/web/target/scalastyle-output.xml
Processed 1 file(s)
Found 0 errors
Found 2 warnings
Finished in 590 ms
Ok, thanks! That should be enough to fix that problem in maven jobs...
@Jan: sorry that I didn't manage to look at this bug until now. After reading the code I'm not sure why the scala warning are not picked up correctly. Do you have a small sample scala project (or OSS project) that I can use to reproduce that bug?
Please reopen if you have more information so that I can reproduce that bug...
Problem mentioned in last comments still seems to exist in current version of the plugin. Checkstyle seems to not recognize ScalaStyle warnings. To reproduce the issue you could use the version 0.5.0 of ScalaStyle and Scala version 2.11.2. I think this is a generic Scala problem so code of an arbitary github project would do the trick to reproduce the issue. Contact me if you need any other info or support. thx
Can you please provide a link to such a project and the build command line I need to start? (I don't use Scala on my own so...)
Pending I presume. Does somebody know a good large Scala project build with Maven ? Such that it generates loads of warnings ?
If no one is providing an example project that exposes the bug I can't help.
Coming up. I have asked the local Scala use group to propose a project.
Basically you need a large code base to run this plugin on it ?
http://www.scalastyle.org/maven.html
Actually a simple project is enough (that contains a pom with scalastyle enabled, and that contains some warnings). For this project I may need some help on how to configure the Jenkins job and then I can debug it locally...
Let's try with Dick Wall's Subcut project: https://github.com/dickwall/subcut
(1) Make- and change to a directory.
(2) Run 'git clone https://github.com/dickwall/subcut.git'.
(3) Replace pom.xml with the one provided. (There's an error in the scalatest dependency + added scalastyle)
(4) Run 'mvn scalastyle:check'
(5) Check the output file 'scalastyle-output.xml'
I'm including the output file so you can check right now this is what you need. Is it ?
Hmm, interesting. I followed your example steps: and now I get a Jenkins maven job with Checkstyle warnings from Scala
[CHECKSTYLE] Parsing file /Users/hafner/Development/jenkins/jobs/JENKINS-17287/workspace/subcut/scalastyle-output.xml [CHECKSTYLE] Successfully parsed file /Users/hafner/Development/jenkins/jobs/JENKINS-17287/workspace/subcut/scalastyle-output.xml of module subcut with 353 unique warnings and 0 duplicates. [CHECKSTYLE] Im pom.xml wurde keine Dateikodierung festgelegt, daher wird die vorgegebene Kodierung UTF-8 des aktuellen Systems verwendet. Damit wird der Build abhängig vom System, auf dem er läuft (siehe auch <a href="http://docs.codehaus.org/
Maybe something is broken in your configuration. I'll add my configuration as screenshot...
Something else must be going on. I've made sure to have EXACTLY the same configuration. And yet it doesn't make a difference. I've got load of Java related Checkstyle warnings. But none for Scala files.
This is the instruction I run:
clean package jxr:jxr pmd:cpd pmd:pmd checkstyle:checkstyle scalastyle:check findbugs:findbugs -DskipTests=true -Djava.awt.headless=false
Maybe because I'm also running CheckStyle ? Or because it is a multi-module project ? The out files would be scattered in the different module directories.
Ah, I see. Yes, the reason is that you also run CheckStyle. For all of my plugins I'm checking if there is already a result present. If there is one there then I'm skipping the step. You can check this by running the goals in the opposite order: mvn scalastyle:check checkstyle:checkstyle. Then you will get Scala warnings but no Java warnings.
That means I need to run the checkstyle reporter multiple times. I.e. in the end there will be multiple Checkstyle results available for a build.
Indeed, that's it. It works when running only ScalaStyle.
Problem is ... it's a Java AND Scala project.
Wouldn't it be easier to have a ScalaStyle plugin instead ? Now those two coincide more or less. And their data can be merged. But how long will it remain that way ?
Anyway, any idea what I might try to actually merge the data ? I thought I was already doing that. But it looks like the results of one is erased.
The problem only occurs with the maven project type, freestyle project should already pick both files. I think it is not possible to merge these files since the maven build type invokes Checkstyle directly after the goal has been finished.
An additional plug-in is also somewhat an overkill, since the parser still is the same.
There are two possibilities:
- Add a new reporter class responsible for ScalaStyle (This is then an additional post build step with separate configuration). Then there will be two results (and links) available, one for Java and one for Scala.
- Aggregate the results. I'm not sure how easy that approach is since I need to load and discard the first action...
I am already doing (2) but wasn't aware one *Style would erase the results of the other one. So I might ask both to dump into separate files and merge manually. I'll have a go at that. At least now the cause is known. However, I have no clue as to how durably fix this really. I guess apply (1).
What I am surprised though is why the results are erased at the first place. How come CheckStyle erases a file named scalastyle-output.xml ?
My plug-in does not erase anything Checkstyle creates the checkstyle.xml file that is read by my plugin afterwards. After that, Scalastyle creates scalastyle.cml. This file is not read anymore since there is already a result available. So it won't help to merge the results. With the maven project type, you can change the file names of the results since these information is read from the pom.
Would it help to run the two in separate invocations ? First 'mvn scalastyle:check' followed by 'mvn checkstyle:checkstyle'. As a workaround of course.
I have no clue how to durably fix this - as I never wrote a Jenkins- or Maven plugin.
Code changed in jenkins
User: Ulli Hafner
Path:
src/test/java/hudson/plugins/checkstyle/parser/CheckStyleParserTest.java
src/test/resources/hudson/plugins/checkstyle/parser/scalastyle-output.xml
http://jenkins-ci.org/commit/checkstyle-plugin/0c1c01107d4868abde597cb9c880de538b65f725
Log:
JENKINS-17287Added testcase that parses a Scala Style file.–
You received this message because you are subscribed to the Google Groups "Jenkins Commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-commits+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.