Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fc11f8d

Browse files
committed
Fix flake8 linting
1 parent ba359fe commit fc11f8d

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/server/src/linter/flake8.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,23 @@ export class Flake8 extends BaseLinter {
2929
// destructuring not yet supported in vscode
3030
// must be done manually
3131
{
32+
//TODO: parse null better
3233
let match = lint.match(this.getRegExp());
34+
if (match == null) {
35+
this.warn("unparsed line:");
36+
this.warn(lint);
37+
return;
38+
}
3339
matchProperties = {
3440
completeMatch: match[0],
3541
filepath: match[1],
3642
line: parseInt(match[2]) - 1,
37-
column: parseInt(match[3]),
43+
column: parseInt(match[3]) - 1,
3844
severityKey: match[4],
3945
message: match[5]
4046
};
4147
}
4248

43-
if (matchProperties.completeMatch == null) {
44-
this.warn("unparsed line:");
45-
this.warn(lint);
46-
return;
47-
}
48-
4949
let severity = this._severityMap.has(matchProperties.severityKey.substring(0, 1))
5050
? this._severityMap.get(matchProperties.severityKey.substring(0, 1))
5151
: DiagnosticSeverity.Error;

src/server/src/server.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ function validateTextDocument(textDocument: ITextDocument): void {
137137
linter.setDocument(textDocument);
138138
let cmd: string = linter.getCmd();
139139

140-
//TODO: Flake8 outputs to stderr, need to determine output buffer to parse
141140
exec(cmd, function(error: Error, stdout: ArrayBuffer, stderr: ArrayBuffer) {
142141
if (error.toString().length !== 0) {
143142
connection.console.warn(`[ERROR] File: ${linter.getFilepath()} - Error message: ${error.toString()}`);
@@ -147,7 +146,7 @@ function validateTextDocument(textDocument: ITextDocument): void {
147146
let results: string[] = stdout.toString().split(/\r?\n/g);
148147
results = linter.fixResults(results);
149148

150-
// log error messages
149+
// process linter output
151150
let diagnostics: Diagnostic[] = [];
152151
for (let result of results) {
153152
let diagnostic = linter.parseLintResult(result);

0 commit comments

Comments
 (0)