Skip to content

Commit

Permalink
RadonBear: Handle col_offset==0 correctly
Browse files Browse the repository at this point in the history
Radon uses visitor.col_offset as 0 for results where column is not
given. As we use None, we simply map it appropriately.
(As suggested by blueyed)

Fixes #609
  • Loading branch information
AbdealiLoKo committed Aug 31, 2016
1 parent b7b42c5 commit 89f393f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion bears/python/RadonBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ def run(self, filename, file,
if severity is None:
continue

col = visitor.col_offset if visitor.col_offset else None
visitor_range = SourceRange.from_values(
filename, visitor.lineno, visitor.col_offset, visitor.endline)
filename, visitor.lineno, col, visitor.endline)
message = "{} has a cyclomatic complexity of {}".format(
visitor.name, rank)

Expand Down
17 changes: 12 additions & 5 deletions tests/python/RadonBearTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,21 @@ class class1():
pass
"""

test_file3 = "def f():\n" + (" assert True\n" * 50)

RadonBearNoReportsTest = verify_local_bear(

RadonBearDefaultsTest = verify_local_bear(
RadonBear,
valid_files=(test_file1, test_file2),
invalid_files=(),
settings={"radon_ranks_info": "",
"radon_ranks_normal": "",
"radon_ranks_major": ""})
invalid_files=(test_file3,))


RadonBearNoReportsTest = verify_local_bear(RadonBear,
valid_files=(test_file1, test_file2, test_file3),
invalid_files=(),
settings={"radon_ranks_info": "",
"radon_ranks_normal": "",
"radon_ranks_major": ""})


RadonBearReportsTest = verify_local_bear(
Expand Down

0 comments on commit 89f393f

Please sign in to comment.