Skip to content
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

Merged
merged 101 commits into from
Mar 2, 2018
Merged

Conversation

MikhailArkhipov
Copy link

@MikhailArkhipov MikhailArkhipov commented Feb 28, 2018

Fixes #911 - Backslash escape for underscores in Markdown docstrings

  • escape underscore only when it is in the beginning of the line OR there is a space before it.

Fixes #913 - Multiple linters not working as expected

  • Fix error when message collection was emptied for every linter in the loop
  • Add test

Fixes search for .pyenv/versions for #847

  • Add actual home folder to .pyenv/versions to make it into the absolute path

@DonJayamanne
Copy link

@MikhailArkhipov
Please could you also fix #916 (related to linterEngine).
We're linting files that we shouldn't be

We're missing the following check in lintingEngine.lintOpenPythonFiles
https://github.com/Microsoft/vscode-python/blob/master/src/client/providers/linterProvider.ts#L84

// Exclude files opened by vscode when showing a diff view.
        if (uriSchemesToIgnore.indexOf(document.uri.scheme) >= 0) {
            return;
        }

Here are the file schemes that need to be excluded (found in lintingProvider)

const uriSchemesToIgnore = ['git', 'showModifications', 'svn'];

Copy link

@DonJayamanne DonJayamanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix #916 in this PR if possible (easy fix)

@MikhailArkhipov
Copy link
Author

MikhailArkhipov commented Feb 28, 2018

Sure. We probably want all checks from onDocumentOpened

@brettcannon
Copy link
Member

@MikhailArkhipov Yes, the issue numbers are linked in the message, but the title isn't and that's what I see in the GitHub notifications to determine if this PR is something I need to look at.

@codecov
Copy link

codecov bot commented Feb 28, 2018

Codecov Report

Merging #920 into master will decrease coverage by 0.29%.
The diff coverage is 87.23%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #920     +/-   ##
=========================================
- Coverage   64.34%   64.04%   -0.3%     
=========================================
  Files         260      260             
  Lines       12042    12025     -17     
  Branches     2133     2131      -2     
=========================================
- Hits         7748     7701     -47     
- Misses       4285     4315     +30     
  Partials        9        9
Impacted Files Coverage Δ
src/client/linters/types.ts 100% <ø> (ø) ⬆️
src/client/common/markdown/restTextConverter.ts 84.67% <ø> (ø) ⬆️
...reter/locators/services/globalVirtualEnvService.ts 100% <100%> (ø) ⬆️
src/client/linters/linterCommands.ts 88.46% <100%> (ø) ⬆️
src/client/providers/linterProvider.ts 75.43% <66.66%> (-2.18%) ⬇️
src/client/linters/lintingEngine.ts 91.22% <91.42%> (+2.33%) ⬆️
src/client/linters/errorHandlers/notInstalled.ts 33.33% <0%> (-61.12%) ⬇️
src/client/linters/errorHandlers/errorHandler.ts 77.77% <0%> (-22.23%) ⬇️
src/client/common/logger.ts 33.33% <0%> (-20%) ⬇️
src/client/common/application/applicationShell.ts 23.07% <0%> (-7.7%) ⬇️
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1f471e...588313b. Read the comment docs.

@MikhailArkhipov
Copy link
Author

Fixed #916 + tests. Need to watch one test stability on AppVeyor

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) {

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

}

public async lintDocument(document: vscode.TextDocument, trigger: LinterTrigger): Promise<void> {
public async lintDocument(document: vscode.TextDocument, trigger: LinterTrigger): Promise<vscode.DiagnosticCollection> {

Choose a reason for hiding this comment

The 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.
Feels unnecessary to return the whole collection.
E.g. if you line a document, you'd expect to get errors related to that document, not all documents.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shoudn't the method public async lintOpenPythonFiles(): Promise<vscode.DiagnosticCollection> collect everything and send a consolidated view?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for tests only, to get the active collection via vscode.commands.executeCommand('python.runLinting'). Currently linting of documents is completely non-blocking and I didn't want to wait until the entire collection is populated. However, it is doable.

@MikhailArkhipov
Copy link
Author

OK, Multiple linters (23846ms) it just times out. Travis passed since test took below 25s and Appveyor failed. Should we increase timeout, or make test manual run only? Increase to 35s would work I think.

@DonJayamanne
Copy link

You can increase timeout for a single test as follows:

test('Ensure non-existing files are not linted', async function () {
    this.timeout(40000)

@DonJayamanne
Copy link

Hmm, taking 35 seconds for linting, sounds something is wrong, that's an awfully long time.
I'll try to have a look tonight, couldnt' check earlier today was busy with debugger fixes.

@MikhailArkhipov
Copy link
Author

MikhailArkhipov commented Mar 2, 2018

Local result: Multiple linters (1207ms)
Travis: Multiple linters (10455ms) (previous run 23s).
Appveyor: Multiple linters (29014ms)

Local Set single linter (495ms)
Travis Set single linter (908ms)
Appveyor Set single linter (2821ms)

What is VM configuration on the test machine? RAM/Cores?

@DonJayamanne
Copy link

Yay 👍 all tests pass

@@ -21,7 +21,7 @@ const grep = IS_CI_SERVER && IS_CI_SERVER_TEST_DEBUGGER ? 'Debug' : undefined;
const options: MochaSetupOptions & { retries: number } = {
ui: 'tdd',
useColors: true,
timeout: 25000,
timeout: 35000,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please could we increase the timeout of the individual test rather than doing this for all.
The problem with this approach is, it affects all tests.
This was necessary earlier, when most of the tests were running actual python code.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a sample:

test('Ensure non-existing files are not linted', async function () {
    this.timeout(40000)

@MikhailArkhipov MikhailArkhipov merged commit 29a0cae into microsoft:master Mar 2, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jul 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple linters not working as expected Backslash escape for underscores in Markdown docstrings
3 participants