Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-3529

StyleCop support in Violations plugin can't deal with absolute paths.

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • violations-plugin
    • None
    • Platform: PC, OS: Windows XP

      Using version 0.7.3 of the Violations plugin.

      I'm building a .Net project and using Stylecop 4.3. I've generated the stylecop
      XML report using StyleCopCmd on my Visual Studio 2k5 solution file and it
      generated XML like this:

      stylecop-output.xml:
      <?xml version="1.0" standalone="yes"?>
      <StyleCopReport xmlns="http://stylecopcmd.sourceforge.net/StyleCopReport.xsd">
      <Solutions>
      <ID>0</ID>
      <Location>D:\CI\jobs\TW
      COMS\workspace\twcoms_v\Order_Management_Products_VOB\TraderWorkstationMS\Dev\OrderManagement\OrderManagement.sln</Location>
      <Name>OrderManagement</Name>
      <Projects>
      <ID>0</ID>
      <Location>D:\CI\jobs\TW
      COMS\workspace\twcoms_v\Order_Management_Products_VOB\TraderWorkstationMS\Dev\OrderManagement\OrderManagement\OrderManagement.csproj</Location>
      <Name>OrderManagement</Name>
      <SolutionID>0</SolutionID>
      <SourceCodeFiles>
      <ID>0</ID>
      <Path>D:\CI\jobs\TW
      COMS\workspace\twcoms_v\Order_Management_Products_VOB\TraderWorkstationMS\Dev\OrderManagement\OrderManagement\config\IOperatorIdManagerConfiguration.cs</Path>
      <TimeStamp>2009-04-16T08:35:49+10:00</TimeStamp>
      <Type>CS</Type>
      <Name>IOperatorIdManagerConfiguration.cs</Name>
      <CodeProjectID>0</CodeProjectID>
      </SourceCodeFiles>
      ... etc

      stylecop-output.violations.xml:
      <StyleCopViolations>
      <Violation
      Section="Root.com.gsjbw.traderworkstation.services.clientordermanagement.config.ConfigUtils.CreateConfigurationException%string%string[]"
      LineNumber="18" Source="D:\CI\jobs\TW
      COMS\workspace\twcoms_v\Order_Management_Products_VOB\TraderWorkstationMS\Dev\OrderManagement\OrderManagement\config\ConfigUtils.cs"
      RuleNamespace="Microsoft.StyleCop.CSharp.DocumentationRules"
      Rule="ElementsMustBeDocumented" RuleId="SA1600">The method must have a
      documentation header.</Violation>
      <Violation
      Section="Root.com.gsjbw.traderworkstation.services.clientordermanagement.config.ISonicJmsConfiguration.JmsDelayEnabled"
      LineNumber="34" Source="D:\CI\jobs\TW
      COMS\workspace\twcoms_v\Order_Management_Products_VOB\TraderWorkstationMS\Dev\OrderManagement\OrderManagement\config\ISonicJmsConfiguration.cs"
      RuleNamespace="Microsoft.StyleCop.CSharp.DocumentationRules"
      Rule="ElementsMustBeDocumented" RuleId="SA1600">The property must have a
      documentation header.</Violation>

      Etc...

      NOTE the absolute path names for the Source attribute.

      With the violations plugin enabled for the build and "XML filename pattern"
      set to "*/build/stylecop-output.xml" I get the following exception. Note I
      have not set the "Faux Project Directory" or "Source Path Pattern" settings to
      anything. If this is the problem what should I be setting them to? They
      documentation is not clear. My code does not existing in a single directory
      like Java code usually does. All code is beneath this directory though:
      D:\CI\jobs\TW
      COMS\workspace\twcoms_v\Order_Management_Products_VOB\TraderWorkstationMS\Dev

      The exception text:

      FATAL: D:\CI\jobs\TW
      COMS\builds\2009-04-21_15-23-54\violations\file\twcoms_v\Order_Management_Products_VOB\TraderWorkstationMS\Dev\OrderManagement\build\D:\CI\jobs\TW
      COMS\workspace\twcoms_v\Order_Management_Products_VOB\TraderWorkstationMS\Dev\Shared\ServiceUtility\exception\GSJBWTimeoutException.cs.xml
      (The filename, directory name, or volume label syntax is incorrect)
      java.io.FileNotFoundException: D:\CI\jobs\TW
      COMS\builds\2009-04-21_15-23-54\violations\file\twcoms_v\Order_Management_Products_VOB\TraderWorkstationMS\Dev\OrderManagement\build\D:\CI\jobs\TW
      COMS\workspace\twcoms_v\Order_Management_Products_VOB\TraderWorkstationMS\Dev\Shared\ServiceUtility\exception\GSJBWTimeoutException.cs.xml
      (The filename, directory name, or volume label syntax is incorrect)
      at java.io.FileOutputStream.open(Native Method)
      at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
      at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
      at hudson.FilePath.write(FilePath.java:906)
      at
      hudson.plugins.violations.generate.ExecuteFilePath.execute(ExecuteFilePath.java:40)
      at hudson.plugins.violations.generate.GenerateXML.execute(GenerateXML.java:47)
      at
      hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:124)
      at
      hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:27)
      at hudson.FilePath.act(FilePath.java:552)
      at
      hudson.plugins.violations.ViolationsPublisher.perform(ViolationsPublisher.java:77)
      at
      hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:56)
      at
      hudson.model.AbstractBuild$AbstractRunner.performAllBuildStep(AbstractBuild.java:372)
      at
      hudson.model.AbstractBuild$AbstractRunner.performAllBuildStep(AbstractBuild.java:360)
      at hudson.model.Build$RunnerImpl.post2(Build.java:183)
      at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:345)
      at hudson.model.Run.run(Run.java:943)
      at hudson.model.Build.run(Build.java:112)
      at hudson.model.ResourceController.execute(ResourceController.java:93)
      at hudson.model.Executor.run(Executor.java:119)

          [JENKINS-3529] StyleCop support in Violations plugin can't deal with absolute paths.

          pvandervelde added a comment -

          Same problem here. Using:
          Huson 1.354
          Violations: 0.7.5
          StyleCop 4.3

          Stack trace:
          ERROR: Publisher hudson.plugins.violations.ViolationsPublisher aborted due to exception
          java.io.FileNotFoundException: E:\integration\hudson\jobs\Apollo-Unstable\builds\2010-05-22_23-08-43\violations\file\modules\ui\projectexplorer\bin\reports\E:\integration\hudson\jobs\Apollo-Unstable\workspace\modules\Ui\projectexplorer\src\ProjectExplorer\Services\EnvironmentService.cs.xml (The filename, directory name, or volume label syntax is incorrect)
          at java.io.FileOutputStream.open(Native Method)
          at java.io.FileOutputStream.<init>(Unknown Source)
          at java.io.FileOutputStream.<init>(Unknown Source)
          at hudson.FilePath.write(FilePath.java:1235)
          at hudson.plugins.violations.generate.ExecuteFilePath.execute(ExecuteFilePath.java:40)
          at hudson.plugins.violations.generate.GenerateXML.execute(GenerateXML.java:47)
          at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:124)
          at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:27)
          at hudson.FilePath.act(FilePath.java:747)
          at hudson.FilePath.act(FilePath.java:729)
          at hudson.plugins.violations.ViolationsPublisher.perform(ViolationsPublisher.java:74)
          at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36)
          at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:582)
          at hudson.model.AbstractBuild$AbstractRunner.performAllBuildStep(AbstractBuild.java:563)
          at hudson.model.AbstractBuild$AbstractRunner.performAllBuildStep(AbstractBuild.java:550)
          at hudson.model.Build$RunnerImpl.post2(Build.java:152)
          at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:528)
          at hudson.model.Run.run(Run.java:1267)
          at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
          at hudson.model.ResourceController.execute(ResourceController.java:88)
          at hudson.model.Executor.run(Executor.java:122)

          Is there any progress on solving this issue?

          pvandervelde added a comment - Same problem here. Using: Huson 1.354 Violations: 0.7.5 StyleCop 4.3 Stack trace: ERROR: Publisher hudson.plugins.violations.ViolationsPublisher aborted due to exception java.io.FileNotFoundException: E:\integration\hudson\jobs\Apollo-Unstable\builds\2010-05-22_23-08-43\violations\file\modules\ui\projectexplorer\bin\reports\E:\integration\hudson\jobs\Apollo-Unstable\workspace\modules\Ui\projectexplorer\src\ProjectExplorer\Services\EnvironmentService.cs.xml (The filename, directory name, or volume label syntax is incorrect) at java.io.FileOutputStream.open(Native Method) at java.io.FileOutputStream.<init>(Unknown Source) at java.io.FileOutputStream.<init>(Unknown Source) at hudson.FilePath.write(FilePath.java:1235) at hudson.plugins.violations.generate.ExecuteFilePath.execute(ExecuteFilePath.java:40) at hudson.plugins.violations.generate.GenerateXML.execute(GenerateXML.java:47) at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:124) at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:27) at hudson.FilePath.act(FilePath.java:747) at hudson.FilePath.act(FilePath.java:729) at hudson.plugins.violations.ViolationsPublisher.perform(ViolationsPublisher.java:74) at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36) at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:582) at hudson.model.AbstractBuild$AbstractRunner.performAllBuildStep(AbstractBuild.java:563) at hudson.model.AbstractBuild$AbstractRunner.performAllBuildStep(AbstractBuild.java:550) at hudson.model.Build$RunnerImpl.post2(Build.java:152) at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:528) at hudson.model.Run.run(Run.java:1267) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:122) Is there any progress on solving this issue?

          jagalves added a comment -

          I gave up waiting and looked through the code (knowing nothing about java, so forgive my mistakes).

          In file StyleCopParser.java (package hudson.plugins.violations.types.stylecop), I made the following change (starting from line 131):

              // Add the violation to the model
              String displayName;
              //if (reportParentFile != null) {
                  displayName = ParseUtil.resolveAbsoluteName(
                  projectPath, getString(element,"Source"));
              //} else {
              //    displayName = projectPath + File.separator + getString(element,"Source");
              //}
              FullFileModel fileModel = model.getFileModel(displayName);
              fileModel.addViolation(violation);
          

          (the commented lines are my changes)

          It assumes the path comes absolute but that's always the case for me.

          jagalves added a comment - I gave up waiting and looked through the code (knowing nothing about java, so forgive my mistakes). In file StyleCopParser.java (package hudson.plugins.violations.types.stylecop), I made the following change (starting from line 131): // Add the violation to the model String displayName; // if (reportParentFile != null ) { displayName = ParseUtil.resolveAbsoluteName( projectPath, getString(element, "Source" )); //} else { // displayName = projectPath + File.separator + getString(element, "Source" ); //} FullFileModel fileModel = model.getFileModel(displayName); fileModel.addViolation(violation); (the commented lines are my changes) It assumes the path comes absolute but that's always the case for me.

          How did you get the absolute path names baked into the @Source attribute? Is there a switch in the MSBuild task to do that?

          Kohsuke Kawaguchi added a comment - How did you get the absolute path names baked into the @Source attribute? Is there a switch in the MSBuild task to do that?

          Code changed in hudson
          User: : kohsuke
          Path:
          trunk/hudson/plugins/violations/src/main/java/hudson/plugins/violations/types/stylecop/StyleCopParser.java
          http://jenkins-ci.org/commit/35527
          Log:
          [FIXED JENKINS-3529] fixed the path handling.

          SCM/JIRA link daemon added a comment - Code changed in hudson User: : kohsuke Path: trunk/hudson/plugins/violations/src/main/java/hudson/plugins/violations/types/stylecop/StyleCopParser.java http://jenkins-ci.org/commit/35527 Log: [FIXED JENKINS-3529] fixed the path handling.

          Code changed in hudson
          User: : kohsuke
          Path:
          trunk/hudson/plugins/violations/src/main/java/hudson/plugins/violations/types/stylecop/StyleCopParser.java
          http://jenkins-ci.org/commit/35528
          Log:
          [FIXED JENKINS-3529] fixed the path handling.

          SCM/JIRA link daemon added a comment - Code changed in hudson User: : kohsuke Path: trunk/hudson/plugins/violations/src/main/java/hudson/plugins/violations/types/stylecop/StyleCopParser.java http://jenkins-ci.org/commit/35528 Log: [FIXED JENKINS-3529] fixed the path handling.

          jagalves added a comment -

          Confirmed fixed. Thanks for tackling this.

          To answer your question, I'm using an external command line runner to execute stylecop and maybe its path relative to the source files has an influence on how the pathnames are built. In my case, as you can see from the "fix" I implemented, they were always absolute.

          I'm sorry for not noticing your question earlier.

          Thanks again.

          jagalves added a comment - Confirmed fixed. Thanks for tackling this. To answer your question, I'm using an external command line runner to execute stylecop and maybe its path relative to the source files has an influence on how the pathnames are built. In my case, as you can see from the "fix" I implemented, they were always absolute. I'm sorry for not noticing your question earlier. Thanks again.

          jagalves added a comment -

          Actually, it still doesn't work, I had problems with hudson's update process and it wasn't successful.

          As an example, here's the same file referenced by both fxcop and stylecop in the reports:

          FxCop (works)
          http://<server>/job/Pulse/9/violations/file/sourcecode/Pulse.Web.Website/Controllers/AccountController.cs

          StyleCop (fails)
          http://<server>/job/Pulse/9/violations/file/Hudson/jobs/Pulse/workspace/sourcecode/Pulse.Web.Website/Controllers/AccountController.cs/?

          The full filesystem path to the file is:
          D:\Hudson\jobs\Pulse\workspace\sourcecode\Pulse.Web.Website\Controllers\AccountController.cs

          Hope it helps,
          Jorge

          jagalves added a comment - Actually, it still doesn't work, I had problems with hudson's update process and it wasn't successful. As an example, here's the same file referenced by both fxcop and stylecop in the reports: FxCop (works) http://<server>/job/Pulse/9/violations/file/sourcecode/Pulse.Web.Website/Controllers/AccountController.cs StyleCop (fails) http://<server>/job/Pulse/9/violations/file/Hudson/jobs/Pulse/workspace/sourcecode/Pulse.Web.Website/Controllers/AccountController.cs/? The full filesystem path to the file is: D:\Hudson\jobs\Pulse\workspace\sourcecode\Pulse.Web.Website\Controllers\AccountController.cs Hope it helps, Jorge

          kflorian added a comment -

          I'm seeing the same (or similar) issue when using a custom workspace location for my job:
          ERROR: Processing failed due to a bug in the code. Please report this to jenkinsci-users@googlegroups.com
          /home/hudson/workspace/ipms_tests/ipms/home/hudson/workspace/ipms_tests/ipms does not exist.
          at org.apache.tools.ant.types.AbstractFileSet.getDirectoryScanner(AbstractFileSet.java:474)
          at hudson.plugins.violations.ViolationsCollector.findFiles(ViolationsCollector.java:213)
          at hudson.plugins.violations.ViolationsCollector.doType(ViolationsCollector.java:164)
          at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:108)
          at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:25)
          at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2022)
          at hudson.remoting.UserRequest.perform(UserRequest.java:118)
          at hudson.remoting.UserRequest.perform(UserRequest.java:48)
          at hudson.remoting.Request$2.run(Request.java:287)
          at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
          at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
          at java.util.concurrent.FutureTask.run(FutureTask.java:138)
          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
          at java.lang.Thread.run(Thread.java:619)

          The custom workspace location points to "/home/hudson/workspace/ipms_tests/ipms"; obviously this path is duplicated somewhere within the violations plugin.
          Worked fine for the same project before switching to the custom workspace setup.

          Jenkins version 1.432
          Violations plugin version: 0.7.10

          kflorian added a comment - I'm seeing the same (or similar) issue when using a custom workspace location for my job: ERROR: Processing failed due to a bug in the code. Please report this to jenkinsci-users@googlegroups.com /home/hudson/workspace/ipms_tests/ipms/home/hudson/workspace/ipms_tests/ipms does not exist. at org.apache.tools.ant.types.AbstractFileSet.getDirectoryScanner(AbstractFileSet.java:474) at hudson.plugins.violations.ViolationsCollector.findFiles(ViolationsCollector.java:213) at hudson.plugins.violations.ViolationsCollector.doType(ViolationsCollector.java:164) at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:108) at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:25) at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2022) at hudson.remoting.UserRequest.perform(UserRequest.java:118) at hudson.remoting.UserRequest.perform(UserRequest.java:48) at hudson.remoting.Request$2.run(Request.java:287) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) The custom workspace location points to "/home/hudson/workspace/ipms_tests/ipms"; obviously this path is duplicated somewhere within the violations plugin. Worked fine for the same project before switching to the custom workspace setup. Jenkins version 1.432 Violations plugin version: 0.7.10

          Hi,

          I know this issue is old but I think I'm having a similar if not the same issue. The source paths reported by the Violations plugin make the files not accessible from the Jenkins UI. They are relative to the root of the volume :S. So, if my .cs file is in C:\SourceCodeFolder\MySolution\MyProject\Namespace\SourceCode.cs, then the link in Jenkins is: http://<jenkins_server>/job/<job_name>/violations/file/SourceCodeFolder/MySolution/Namespace/SourceCode.cs/

          This happens even after setting the faux project path to "C:\SourceCodeFolder\MySolution", and no matter what I try to set in the source code patterns.

          Fernando Borrego Polo added a comment - Hi, I know this issue is old but I think I'm having a similar if not the same issue. The source paths reported by the Violations plugin make the files not accessible from the Jenkins UI. They are relative to the root of the volume :S. So, if my .cs file is in C:\SourceCodeFolder\MySolution\MyProject\Namespace\SourceCode.cs, then the link in Jenkins is: http://<jenkins_server>/job/<job_name>/violations/file/SourceCodeFolder/MySolution/Namespace/SourceCode.cs/ This happens even after setting the faux project path to "C:\SourceCodeFolder\MySolution", and no matter what I try to set in the source code patterns.

          Andrew Gray added a comment -

          This issue is still happening in

          Jenkins 1.627
          Violations 0.7.11
          Static Analysis Collector 1.43
          Static Analysis Utilities 1.72

          This really sucks. Please fix.

          Andrew Gray added a comment - This issue is still happening in Jenkins 1.627 Violations 0.7.11 Static Analysis Collector 1.43 Static Analysis Utilities 1.72 This really sucks. Please fix.

            kohsuke Kohsuke Kawaguchi
            orj76 orj76
            Votes:
            11 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated: