Skip to content

Commit 48eedea

Browse files
LexSongccordoba12
authored andcommitted
Fix returned line numbers in McCabe plugin (#710)
1 parent 30a995a commit 48eedea

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pyls/plugins/mccabe_lint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def pyls_lint(config, document):
3030
diags.append({
3131
'source': 'mccabe',
3232
'range': {
33-
'start': {'line': graph.lineno, 'character': graph.column},
34-
'end': {'line': graph.lineno, 'character': len(document.lines[graph.lineno])},
33+
'start': {'line': graph.lineno - 1, 'character': graph.column},
34+
'end': {'line': graph.lineno - 1, 'character': len(document.lines[graph.lineno])},
3535
},
3636
'message': 'Cyclomatic complexity too high: %s (threshold %s)' % (graph.complexity(), threshold),
3737
'severity': lsp.DiagnosticSeverity.Warning

test/plugins/test_mccabe_lint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def test_mccabe(config):
2626
mod_import = [d for d in diags if d['message'] == msg][0]
2727

2828
assert mod_import['severity'] == lsp.DiagnosticSeverity.Warning
29-
assert mod_import['range']['start'] == {'line': 1, 'character': 0}
30-
assert mod_import['range']['end'] == {'line': 1, 'character': 6}
29+
assert mod_import['range']['start'] == {'line': 0, 'character': 0}
30+
assert mod_import['range']['end'] == {'line': 0, 'character': 6}
3131
finally:
3232
config._settings = old_settings
3333

0 commit comments

Comments
 (0)