Skip to content

Commit 771f5c3

Browse files
committed
Fix prospector linter to not fail on unset line number.
1 parent 96f71ab commit 771f5c3

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/client/linters/prospector.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ export class Linter extends baseLinter.BaseLinter {
5353
let diagnostics: baseLinter.ILintMessage[] = [];
5454
parsedData.messages.filter((value, index) => index <= this.pythonSettings.linting.maxNumberOfProblems).forEach(msg => {
5555

56-
let sourceLine = txtDocumentLines[msg.location.line - 1];
56+
let lineNumber = msg.location.line === null || isNaN(msg.location.line) ? 1 : msg.location.line;
57+
let sourceLine = txtDocumentLines[lineNumber - 1];
5758
let sourceStart = sourceLine.substring(msg.location.character);
58-
let endCol = txtDocumentLines[msg.location.line - 1].length;
59+
let endCol = txtDocumentLines[lineNumber - 1].length;
5960

6061
// try to get the first word from the starting position
6162
let possibleProblemWords = sourceStart.match(/\w+/g);
@@ -68,7 +69,7 @@ export class Linter extends baseLinter.BaseLinter {
6869
code: msg.code,
6970
message: msg.message,
7071
column: msg.location.character,
71-
line: msg.location.line,
72+
line: lineNumber,
7273
possibleWord: possibleWord,
7374
type: msg.code,
7475
provider: `${this.Id} - ${msg.source}`

0 commit comments

Comments
 (0)