Skip to content

Commit

Permalink
Fixes #276: correct regular expression for multi_line_violation_regex
Browse files Browse the repository at this point in the history
  • Loading branch information
kozlovsky authored and Bachmann1234 committed Apr 16, 2022
1 parent d9efc6c commit 6479057
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion diff_cover/violationsreporters/violations_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def __init__(self):
# Match lines of the form:
# path/to/file.py:123: [C0111] Missing docstring
# path/to/file.py:456: [C0111, Foo.bar] Missing docstring
self.multi_line_violation_regex = re.compile(r"==(\w|.+):(.*)")
self.multi_line_violation_regex = re.compile(r"==((?:\w|\.)+?):\[?(\d+)")
self.dupe_code_violation_regex = re.compile(r"Similar lines in (\d+) files")

def _process_dupe_code_violation(self, lines, current_line, message):
Expand Down
6 changes: 6 additions & 0 deletions tests/test_violations_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,11 @@ def test_quality(self, process_patcher):
import json
import logging
import random
file2.py:170: [R0801] Similar lines in 2 files
==file1:[170:172]
==student.views:[4:6]
import foo
import bar
path/to/file2.py:100: [W0212, openid_login_complete] Access to a protected member
"""
)
Expand All @@ -1300,6 +1305,7 @@ def test_quality(self, process_patcher):
),
Violation(149, "C0324: Foo.__dict__: Comma not followed by a space"),
Violation(162, "R0801: Similar lines in 2 files"),
Violation(170, "R0801: Similar lines in 2 files"),
Violation(113, "W0613: cache_relation.clear_pk: Unused argument 'cls'"),
]

Expand Down

0 comments on commit 6479057

Please # to comment.