How would I start integrating pyflakes with Hudson

2019-04-24 10:48发布

问题:

We use Hudson for continuous integration with the Violations Plugin which parses our output from pylint. However, pylint is a bit too strict, and hard to configure. What we'd rather use is pyflakes which would give us the right level of "You're doing it wrong."

回答1:

You can adapt pyflakes and pep8 output to work with the Violations pylint plugin.

pyflakes path/to/src | awk -F\: '{printf "%s:%s: [E]%s\n", $1, $2, $3}' > violations.pyflakes.txt

pep8 path/to/src | awk -F\: '{printf "%s:%s: [%s]%s\n", $1, $2, substr($4,2,4), substr($4,6)}' > violations.pep8.txt

You could use a regex or concatenate the output to generate a report that includes multiple metrics.

For more details see http://hustoknow.blogspot.com/2011/01/integration-pyflakes-into-hudson.html



回答2:

The Violations plugin requires xml output from the various checkers that it supports.

I'm not familiar with pyflakes, but from my brief scan, it doesn't appear to support xml as an output type. So you'll have to post-process the pyflakes output before letting Violations try to parse it (or you could modify pyflakes and write your own Message output class). You'll probably want to capture the pylint output and use that to figure out the appropriate xml format that the Violations plugin likes.



回答3:

The Violations plugin requires xml output from the various checkers

This is wrong: Some checkers like "checkstyle" output XML, some others like "pylint" and "pep8" output "text" files with one record per line. The heading in Jenkins "XML filename pattern" is plain misleading.