forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpylama.ts
More file actions
35 lines (29 loc) · 1.46 KB
/
Copy pathpylama.ts
File metadata and controls
35 lines (29 loc) · 1.46 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
32
33
34
35
'use strict';
import * as baseLinter from './baseLinter';
import {OutputChannel} from 'vscode';
import { Product } from '../common/installer';
const REGEX = '(?<file>.py):(?<line>\\d+):(?<column>\\d+): \\[(?<type>\\w+)\\] (?<code>\\w\\d+) (?<message>.*)\\r?(\\n|$)';
export class Linter extends baseLinter.BaseLinter {
constructor(outputChannel: OutputChannel, workspaceRootPath: string) {
super('pylama', Product.pylama, outputChannel, workspaceRootPath);
}
public isEnabled(): Boolean {
return this.pythonSettings.linting.pylamaEnabled;
}
public runLinter(filePath: string, txtDocumentLines: string[]): Promise<baseLinter.ILintMessage[]> {
if (!this.pythonSettings.linting.pylamaEnabled) {
return Promise.resolve([]);
}
let pylamaPath = this.pythonSettings.linting.pylamaPath;
let pylamaArgs = Array.isArray(this.pythonSettings.linting.pylamaArgs) ? this.pythonSettings.linting.pylamaArgs : [];
return new Promise<baseLinter.ILintMessage[]>(resolve => {
this.run(pylamaPath, pylamaArgs.concat(['--format=parsable', filePath]), filePath, txtDocumentLines, this.workspaceRootPath, REGEX).then(messages => {
// All messages in pylama are treated as warnings for now
messages.forEach(msg => {
msg.severity = baseLinter.LintMessageSeverity.Information;
});
resolve(messages);
});
});
}
}