It is cool to see Travis automatically testing commits I push to the collective, but when Travis says the test build fails because of a flake8 error, how can I view the flake8.log that it creates? Or must I just run flake8 locally?
...and should I fix all flake8 errors in other parts of the repo that I didn't change?
For the first question, you could run bin/code-analysis locally and you should see all flake8 errors.
If you used plone.recipe.codeanalysis, it should have created a pre-commit hook in your local repo that runs bin/code-analysis script before every commit.
And yes, if travis runs that script, it will fail until all errors are fixed.
Funny, I fixed what I thought were all the flake8 errors but after running code-analysis locally to see what Travis was complaining about it had this to say:
Flake8..........................[ FAILURE ] in 2.653s
/Users/kim/PloneBuilds/Plone-5.0.4-unified-clean/zinstance/src/collective.easyform/src/collective/easyform/actions.py:200:5: C901 'Mailer.get_addresses' is too complex (11)
It seems excessive (and dangerous) that I have to fix logic that isn't broken but is only stylistically objected to by this tool...
the error message seems to say that the complexity level is too high at 11 while in master the max-complexity-level is set to 11 in buildout.cfg. This does not seem right. What's the level in the flake8 script in your local tree ?
Yeah, I don't understand why on GitHub the max complexity level should have prevented Travis from flagging complexity 11, so either that directive wasn't working or there was another problem reported by flake8, but since in Jenkins mode Travis ignores the directive to show the errors (instead it creates a log file that I don't know how to view, if it's at all possible) I have no way of knowing what the flake8 error was.
From the Travis doc, there are 2 ways:
- get the Docker image and reproduce the build
- get a 30 minutes ssh access to the build image but it needs a special debug mode that is enabled only on demand by mail to travis (obviously from the repo admin)
What I don't understand is your local error message. I git cloned the master and built it locally, there were no errors from flake8. I changed the bin/code-analysis to set the flake8-max-complexity to 10 and then I got your error message. Last modification date for master is 4 dec 2017 and at this date the repo was tested in Travis without any flake8 problem. That's why I think that there is something wrong in your local tree.
We have a nice / hacky thing for this issue - only lint the files the user actually touched. While not perfect, people tend to find it less annoying.
And the configs are (mostly) defined here (or you can follow the buildout extends on
opengever.core when actually interested):
We're slowly introducing new linters to that stack, but it's not been completely trouble-free of an entry curve as we're also pulling in the configs via buildout and the next step up would be to figure out some unified frontend for the linters to replace our pile of shell (I prefer pylama, but the discussion is still open and we're not actively pursuing that currently).
We'll also need to figure out a way to merge config files via buildout before that can go all out as we want company-wide, product-wide and software-wide rulesets. Would anyone have something for that?
Bringing this up as out of that stack you could actually nick the "touch only changed files" bit for Plone.