Closed codinghipster closed 12 years ago
I've been hacking on a fork of pep8 for a little while, and based on my experience, I think this would be pretty tricky to do. The reason is that the patch might not provide enough context to perform all checks, particularly those checks that require being able to tokenize the source. In the general case, that requires being able to look back/forward an arbitrary number of lines (you can spread a multi-line statement onto any number of lines).
It should be possible to run a reduced subset of checks, but I'm not sure whether that's sufficient for your needs.
The way I have been looking at doing it (though I haven't started) is to make pep8 analyse the entire codebase, but only report the errors for the lines that have changed. I don't know how hard this would be given the fact that pep8 currently only reports the first error of a certain type that it finds.
@ebrius "pep8 currently only reports the first error of a certain type" -- there's a command line flag to change this behavior. The only challenging bit left is correlating the line numbers with the diff.
Something that would nice for pep8 to implement would be code checking for diffs, This would allow developers to only check the sections of code that they modified rather then the entire file.
A good example of this is the checkpatch.pl script that is maintained for the linux kernel tree. This script is diff aware so that a user can call it with a diff and it will only analyse the code that has changed as part of this diff.
The idea being that pep8 would be executed from a sandbox, have a diff passed to it, and only check the lines that have been modified in the diff.