dealertrack / flake8-diff

Run flake8 across a set of changed files and filter out violations occurring only on the lines that were changed.
MIT License
20 stars 8 forks source link

flake8diff doesn't seem to catch all whitespace errors that flake8 catches #24

Open rbranche opened 9 years ago

rbranche commented 9 years ago
lekonia:tests.git{test_flake8} ryan$ ryan$ flake8-diff
Found violations: restore.py
    E265 @ 89:1 - block comment should start with '# '
    W391 @ 1248:1 - blank line at end of file
1 ↵    
lekonia:tests.git{test_flake8} ryan$ flake8 restore.py
restore.py:89:1: E265 block comment should start with '# '
restore.py:92:1: E302 expected 2 blank lines, found 1
restore.py:1248:1: W391 blank line at end of file
1 ↵  
lekonia:tests.git{test_flake8} ryan$ git diff origin/master 2>/dev/null    
diff --git a/restore.py b/restore.py
index 84ba0e8..a91e473 100755
--- a/restore.py
+++ b/restore.py
@@ -86,6 +86,8 @@ CANARIES = [

 _FILE_SCHEMA = u"file://"

+#super bad flake8 code
+foo = True

 class RestoreTest(BaseTest):
     # Restore requires a device,
@@ -1243,3 +1245,4 @@ class RestoreTest(BaseTest):

 RestoreTest().execute_tests()
+

While the E302 was not in the changes per-se, it was introduced by the changes. flake8-diff should take into account the changed lines along with the immediately adjacent lines:

flake8-diff currently only looks at:

#super bad flake8 code
foo = True

But it should look at:

#super bad flake8 code
foo = True

class RestoreTest(BaseTest):
gregarmer commented 9 years ago

@rbranche thanks for the bug report!

We have something in the works that will help with this, in #22 - it'll hopefully land soon and I'll push a new version up to PyPI.

We'll also look into some ways to catch this in a less brute-force sort of way. I'm sure there are a few other cases very similar to this.