Skip to content

Commit

Permalink
Fix returned line numbers in McCabe plugin (#710)
Browse files Browse the repository at this point in the history
  • Loading branch information
LexSong authored and ccordoba12 committed Dec 4, 2019
1 parent 30a995a commit 48eedea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pyls/plugins/mccabe_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def pyls_lint(config, document):
diags.append({
'source': 'mccabe',
'range': {
'start': {'line': graph.lineno, 'character': graph.column},
'end': {'line': graph.lineno, 'character': len(document.lines[graph.lineno])},
'start': {'line': graph.lineno - 1, 'character': graph.column},
'end': {'line': graph.lineno - 1, 'character': len(document.lines[graph.lineno])},
},
'message': 'Cyclomatic complexity too high: %s (threshold %s)' % (graph.complexity(), threshold),
'severity': lsp.DiagnosticSeverity.Warning
Expand Down
4 changes: 2 additions & 2 deletions test/plugins/test_mccabe_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def test_mccabe(config):
mod_import = [d for d in diags if d['message'] == msg][0]

assert mod_import['severity'] == lsp.DiagnosticSeverity.Warning
assert mod_import['range']['start'] == {'line': 1, 'character': 0}
assert mod_import['range']['end'] == {'line': 1, 'character': 6}
assert mod_import['range']['start'] == {'line': 0, 'character': 0}
assert mod_import['range']['end'] == {'line': 0, 'character': 6}
finally:
config._settings = old_settings

Expand Down

0 comments on commit 48eedea

Please sign in to comment.