-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix backslash escape, multiple linters output, .pyenv/versions folder search #920
Changes from 88 commits
7675901
eb42669
2756974
c2c1ced
a108c96
14864a5
0ed51d6
51b544c
3cd11e6
82e0ad1
9295c1a
06eb1a5
e9db8e0
d12ca03
d8ab041
db75cd0
9ab2c47
d587485
1da5e0a
7668cee
1ac4932
2aa5a6c
5db31bd
560d2af
c71024d
31aa087
593ae05
e6d69bb
b5a23d3
cd200f7
7c33228
c4a6b90
f85b848
37c210b
61a5650
a10305e
bfcae78
42a5f79
e4ba322
7baec1a
9cb43e7
5a9c3fd
9800c4a
3205d33
c1150d4
30519c7
96511cb
c8670b9
97f232f
768bffe
825f16b
eb36eef
bab4239
2a30201
e430ef8
1afa841
6bffb07
e436fde
c03e619
e52bcff
e6b8196
3a0cfb1
4616996
35838b9
656a56b
6a10786
d43f097
f8db935
a8dc597
3f5d492
f93a0f4
f8eaa93
e4372c6
469c8a7
609bbdd
7ea6fda
6546892
76af122
5d4d022
29edac2
1ee0be2
531c1d8
1969451
33efd6e
713983e
e64b371
afddcb3
73c9617
eea64de
5a0a553
2c635ba
f37c27c
8fd2d14
6ac00d8
a9c2708
5fbc703
46090c6
c54b0ee
8954180
f6707c1
588313b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,32 +51,31 @@ export class LintingEngine implements ILintingEngine { | |
this.diagnosticCollection = vscode.languages.createDiagnosticCollection('python'); | ||
} | ||
|
||
public lintOpenPythonFiles(): void { | ||
this.documents.textDocuments.forEach(async document => { | ||
public async lintOpenPythonFiles(): Promise<vscode.DiagnosticCollection> { | ||
this.documents.textDocuments.forEach(document => { | ||
if (document.languageId === PythonLanguage.language) { | ||
await this.lintDocument(document, 'auto'); | ||
this.lintDocument(document, 'auto').ignoreErrors(); | ||
} | ||
}); | ||
return this.diagnosticCollection; | ||
} | ||
|
||
public async lintDocument(document: vscode.TextDocument, trigger: LinterTrigger): Promise<void> { | ||
public async lintDocument(document: vscode.TextDocument, trigger: LinterTrigger): Promise<vscode.DiagnosticCollection> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method doesn't feel right. Its modifying the underlying collection and returning the same thing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shoudn't the method There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is for tests only, to get the active collection via |
||
// Check if we need to lint this document | ||
const workspaceFolder = this.workspace.getWorkspaceFolder(document.uri); | ||
const workspaceRootPath = (workspaceFolder && typeof workspaceFolder.uri.fsPath === 'string') ? workspaceFolder.uri.fsPath : undefined; | ||
const relativeFileName = typeof workspaceRootPath === 'string' ? path.relative(workspaceRootPath, document.fileName) : document.fileName; | ||
const settings = this.configurationService.getSettings(document.uri); | ||
if (document.languageId !== PythonLanguage.language) { | ||
return; | ||
return this.diagnosticCollection; | ||
} | ||
if (!this.linterManager.isLintingEnabled(document.uri)) { | ||
this.diagnosticCollection.set(document.uri, []); | ||
} | ||
const ignoreMinmatches = settings.linting.ignorePatterns.map(pattern => { | ||
return new Minimatch(pattern); | ||
}); | ||
|
||
const ignoreMinmatches = settings.linting.ignorePatterns.map(pattern => new Minimatch(pattern)); | ||
if (ignoreMinmatches.some(matcher => matcher.match(document.fileName) || matcher.match(relativeFileName))) { | ||
return; | ||
return this.diagnosticCollection; | ||
} | ||
|
||
if (this.pendingLintings.has(document.uri.fsPath)) { | ||
|
@@ -114,7 +113,6 @@ export class LintingEngine implements ILintingEngine { | |
break; | ||
} | ||
|
||
diagnostics = []; | ||
if (this.isDocumentOpen(document.uri)) { | ||
// Build the message and suffix the message with the name of the linter used. | ||
for (const m of msgs) { | ||
|
@@ -123,17 +121,17 @@ export class LintingEngine implements ILintingEngine { | |
(m.code === LinterErrors.pylint.InvalidSyntax || | ||
m.code === LinterErrors.prospector.InvalidSyntax || | ||
m.code === LinterErrors.flake8.InvalidSyntax)) { | ||
return; | ||
continue; | ||
} | ||
diagnostics.push(this.createDiagnostics(m, document)); | ||
} | ||
|
||
// Limit the number of messages to the max value. | ||
diagnostics = diagnostics.filter((value, index) => index <= settings.linting.maxNumberOfProblems); | ||
} | ||
// Set all diagnostics found in this pass, as this method always clears existing diagnostics. | ||
this.diagnosticCollection.set(document.uri, diagnostics); | ||
} | ||
// Set all diagnostics found in this pass, as this method always clears existing diagnostics. | ||
this.diagnosticCollection.set(document.uri, diagnostics); | ||
return this.diagnosticCollection; | ||
} | ||
|
||
// tslint:disable-next-line:no-any | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
print x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is no longer necessary as you now have
shouldLintDocument
method that does the necessary checking. Besides this only checks one condition and could be misleading about the logic.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes