Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Violations plugin not showing code #17

Open
cangove opened this issue May 24, 2012 · 25 comments
Open

Violations plugin not showing code #17

cangove opened this issue May 24, 2012 · 25 comments

Comments

@cangove
Copy link

cangove commented May 24, 2012

When you drill down into the violations it should show the line of code in violation. However on our Jenkins install we see the violation graphs but selecting a file results in an empty page. Could it be that it cannot find the source code? How does it find the source code?

@nwittstruck
Copy link

I'm having the same issue. Maybe it's path related?

@nwittstruck
Copy link

Had a bit more time to investigate: The problem is that the path is wrong, it seems to ignore the Project Base Directory set in the project configuration. When I set up a job that does not use the Project Base Directory everything works fine.

@shish
Copy link

shish commented Nov 15, 2012

I'm seeing the same as in saily's issue -- I can see the source for my pep8 warnings, but not my jslint ones

@shish
Copy link

shish commented Nov 15, 2012

EDIT: actually, Pep8parser overrides getFileModel locally, which explains the differing paramaters

The main difference I can see is that Pep8Parser does this:

FullFileModel fileModel = getFileModel(model, 
    pep8Violation.getFileName(), 
    absoluteFileFinder.getFileForName(pep8Violation.getFileName()));

while JsLintParser does this:

FullFileModel fileModel = getFileModel(absoluteFileName);

@hashar
Copy link

hashar commented Jan 16, 2013

I get a similar issue with pep8 report:

stat("/run/jenkins/war/job/operations-puppet-pep8/541/violations/file/files/ganglia/plugins/mysql.py",
0x7f4b3044edb0) = -1 ENOENT (No such file or directory)

Though the workspace is in /var/lib/jenkins/job/operations-puppet-pep8/workspace and the mysql.py.xml report is at /var/lib/jenkins/jobs/operations-puppet-pep8/builds/541/violations/file/files/ganglia/plugins/mysql.py.xml

The filename in the pep8 output is simply 'files/ganglia/plugins/mysql.py'

@hashar
Copy link

hashar commented Jan 16, 2013

Might be related to https://issues.jenkins-ci.org/browse/JENKINS-14291

@johnrengelman
Copy link
Contributor

I'm having the same issue on the Codenarc reporting. I get the following stack trace:
WARNING: Publisher hudson.plugins.violations.ViolationsPublisher aborted due to exception java.io.EOFException: no more data available - expected end tags </Rules></CodeNarc> to close start tag <Rules> from line 2 and start tag <CodeNarc> from line 2, parser stopped on START_TAG seen ...ns=\'0\' priority1=\'0\' priority2=\'0\' priority3=\'0\'></Package><Rules>... @2:977 at org.xmlpull.mxp1.MXParser.fillBuf(MXParser.java:3035) at org.xmlpull.mxp1.MXParser.more(MXParser.java:3046) at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1144) at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093) at hudson.plugins.violations.parse.AbstractParser.skipTag(AbstractParser.java:227) at hudson.plugins.violations.parse.AbstractParser.skipToTag(AbstractParser.java:195) at hudson.plugins.violations.types.codenarc.CodenarcParser.execute(CodenarcParser.java:42) at hudson.plugins.violations.parse.AbstractTypeParser.parse(AbstractTypeParser.java:57) at hudson.plugins.violations.ViolationsCollector.doType(ViolationsCollector.java:187) at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:114) at hudson.plugins.violations.ViolationsCollector.invoke(ViolationsCollector.java:25) at hudson.FilePath.act(FilePath.java:865) at hudson.FilePath.act(FilePath.java:838) at hudson.plugins.violations.ViolationsPublisher.perform(ViolationsPublisher.java:74) at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:36) at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:810) at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:785) at hudson.model.Build$BuildExecution.post2(Build.java:183) at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:732) at hudson.model.Run.execute(Run.java:1582) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:236)

This plugin is using a pretty old copy of xpp3 (version 1.1.3.3 from 2005). There is a less older 1.1.4c from 2007 that might help.

@jochenberger
Copy link

Same issue for PMD and Findbugs.

@jochenberger
Copy link

Sorry, PMD works fine, my bad.

@delicb
Copy link

delicb commented Oct 4, 2013

I believe that I bumped into similar problem.
I run pep8 like this: pep8 . > pep8.out and in output i get lines like this: .\myFile.py:1:11: E... and Violations can not find files in per-file report.
My current workaround is to run python script that strips .\ from start of each line after running pep8. With that - Violations can find source files just fine.

Also, this problem only happens when build is executed on windows (slave is on windows, master is on Linux), but it happens when both master and slave are on windows and does not happen when master and slave are on linux.

I hope that this helps and that this will be fixed soon.

@skiedrowski
Copy link
Contributor

@jochenberger
though it's been a while: a common problem related to findbugs is not specifying the "Source Path Pattern" in the Job Config (as described here: https://wiki.jenkins-ci.org/display/JENKINS/Violations)

@jochenberger
Copy link

I've abandoned the Violations plugin some time ago, but thanks for the hint.

@hashar
Copy link

hashar commented Mar 11, 2014

@jochenberger Do you have any plugin recommandation to replace its functionalities?

@jochenberger
Copy link

I switched to using the stand-alone PMD and Findbugs plug-ins.

@CeeJayCee
Copy link

I found the same problem using PyLint on Windows - the path separator "" seemed to be getting replaced with "/" by the browser, which meant the report file was never found.

I've forked the violations plugin and made my own (very hacky, temporary) change to get it to work for me.

Have a look here: https://github.com/CeeJayCee/violations-plugin/commit/ccbf77b2f49ecbb03950333e3e980500bb9183d6

@gregwym
Copy link

gregwym commented Jul 14, 2014

I'm having the same issue with JSHint generated jslint.xml

@childnode
Copy link

see https://issues.jenkins-ci.org/browse/JENKINS-17548 and pull request #33 perhaps this will work for others too?

@doctaphred
Copy link

Thanks @delicb, that fixed it for me: flake8 | sed 's|^./||' > flake8-output on Linux. Seems like that shouldn't be necessary, though...

@atdiff
Copy link

atdiff commented Feb 16, 2016

This still seems to be an issue. When I click the link to go to the code, it goes to /jenkins/job/my_job_name/29/violations/file/src/main/modules/app.js/. Any update on getting this fixed?

@hashar
Copy link

hashar commented Feb 17, 2016

When I looked at he code, the violation plugin (or whatever other plugin it relies on) has terrible code with handling paths in the lint output. An absolute path in the output is actually relative to the workspace, and iirc it tries to account that by using the workspace path on the master instead of the one on the slave.

I have quit using violation in favor of https://wiki.jenkins-ci.org/display/JENKINS/Checkstyle+Plugin

@atdiff
Copy link

atdiff commented Feb 17, 2016

Thanks for the info @hashar. My one concern in going solely to Checkstyle is that it didn't seem to support jshint reporting very well. I'll play with it some more and see - maybe I had something wrong in the config.
I'm looking for a plugin that handles static analysis reporting of jshint and jscs. And then long term goal is a plugin that aggregates results from that as well as coverage and quality reports.

@hashar
Copy link

hashar commented Feb 28, 2016

For jshint you can pass it --reporter checkstyle which causes it to produce XML output suitable for .. checkstyle :) Example:

bla.js

function () {
    alert("foo")
}

jshint --reporter checkstyle bla.js

<?xml version="1.0" encoding="utf-8"?>
<checkstyle version="4.3">
    <file name="bla.js">
        <error line="1" column="10" severity="warning" message="Missing name in function declaration." source="jshint.W025" />
        <error line="2" column="17" severity="warning" message="Missing semicolon." source="jshint.W033" />
    </file>
</checkstyle>

Or with unix reporter suitable for emacs: jshint --reporter unix bla.js

bla.js:1:10: Missing name in function declaration.
bla.js:2:17: Missing semicolon.

2 errors

@atdiff
Copy link

atdiff commented Feb 29, 2016

@hashar, I was able to do something similar to that as well and it's working great. I'll end up going a custom route with the plugin due to the visual look/feel that they want.
Side question - do you know if it's possible with jshint to have it output 2 files? I'd like it to report an XML file and then another file in a different format.

@hashar
Copy link

hashar commented Mar 2, 2016

@atdiff jshint only accept a single reporter and always output to stdout so no. Potentially you could write your own reporter that would write two different formats. An example of a basic reporter is in the source code at https://github.com/jshint/jshint/blob/master/examples/reporter.js

@sasinda
Copy link

sasinda commented Aug 2, 2017

It needs to have the path relative to the working directory for the job. For pylint and pep8 you can augment the path printed in the analysis output using the format options, to fix the path issues for Violations plugin. Then it correctly shows the code with the style error messages popping up on hover.

pep8 mymodule --format '/%(path)s:%(row)d:%(col)d: %(code)s %(text)s'
pylint mymodule --output-format=parseable --msg-template='/{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests