forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake8.ts
More file actions
31 lines (28 loc) · 1.2 KB
/
Copy pathflake8.ts
File metadata and controls
31 lines (28 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { CancellationToken, OutputChannel, TextDocument } from 'vscode';
import '../common/extensions';
import { Product } from '../common/types';
import { IServiceContainer } from '../ioc/types';
import { BaseLinter } from './baseLinter';
import { ILintMessage } from './types';
const COLUMN_OFF_SET = 1;
export class Flake8 extends BaseLinter {
constructor(outputChannel: OutputChannel, serviceContainer: IServiceContainer) {
super(Product.flake8, outputChannel, serviceContainer, COLUMN_OFF_SET);
}
protected async runLinter(document: TextDocument, cancellation: CancellationToken): Promise<ILintMessage[]> {
const messages = await this.run(
['--format=%(row)d,%(col)d,%(code).1s,%(code)s:%(text)s', document.uri.fsPath],
document,
cancellation
);
messages.forEach((msg) => {
msg.severity = this.parseMessagesSeverity(msg.type, this.pythonSettings.linting.flake8CategorySeverity);
// flake8 uses 0th line for some file-wide problems
// but diagnostics expects positive line numbers.
if (msg.line === 0) {
msg.line = 1;
}
});
return messages;
}
}