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

Remove setting linting.lintOnTextChange as it was never implemented #315

Merged
merged 34 commits into from
Nov 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ecc1ca9
Fix Microsoft/vscode#37627 (#1368)
octref Nov 3, 2017
7c5778c
Version 0.7.0 of extension (#1381)
DonJayamanne Nov 9, 2017
9d1bf82
Update README.md
DonJayamanne Nov 9, 2017
ffba179
Update README.md
DonJayamanne Nov 9, 2017
905c713
sync fork with upstream
DonJayamanne Nov 10, 2017
acc2109
fix readme
DonJayamanne Nov 10, 2017
d470523
Merge branch 'master' of https://github.com/Microsoft/vscode-python
DonJayamanne Nov 16, 2017
d392e8b
merged upstream
DonJayamanne Nov 16, 2017
92f775f
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 20, 2017
32a6e53
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 21, 2017
4b30f2c
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 22, 2017
e396752
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 22, 2017
eff4792
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
4553c28
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
3c6520a
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
9e9db48
move files around
DonJayamanne Nov 28, 2017
ed5748b
remove format on save
DonJayamanne Nov 28, 2017
966e516
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
4961c3f
Merge branch 'master' into removeFormatOnSave
DonJayamanne Nov 28, 2017
b312df7
merged with master
DonJayamanne Nov 28, 2017
129ae06
merged with master
DonJayamanne Nov 28, 2017
03f6de3
move browser file
DonJayamanne Nov 28, 2017
6875d63
updated error message
DonJayamanne Nov 28, 2017
05156cc
moved registry into platform directory
DonJayamanne Nov 28, 2017
8c476b2
removed unused file
DonJayamanne Nov 28, 2017
60d0b05
one setting per deprecation message
DonJayamanne Nov 28, 2017
346b3bb
notify gulp is alive
DonJayamanne Nov 28, 2017
d4d9458
remove setting lintOnTextChange
DonJayamanne Nov 28, 2017
3d267cb
remove unused variable
DonJayamanne Nov 28, 2017
58bacb2
renamed variable as per code review
DonJayamanne Nov 28, 2017
6d24a0a
merged changes from branch
DonJayamanne Nov 28, 2017
957e69a
fix linter
DonJayamanne Nov 28, 2017
63d2d65
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
29fbe94
fixed name of setting
DonJayamanne Nov 28, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const hygiene = exports.hygiene = (some, options) => {
}
};
}
const tsProject = ts.createProject('tsconfig.json', { strict: true, noImplicitAny: false });
const tsProject = ts.createProject('tsconfig.json', { strict: true, noImplicitAny: false, noImplicitThis: false });
const reporter = customReporter();
return tsProject(reporter);
}
Expand Down Expand Up @@ -231,7 +231,7 @@ function run(lintOnlyModifiedFiles, doNotExit) {
if (lintOnlyModifiedFiles && doNotExit) {
console.log('Watching for changes...');
}
}
}
process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
exitProcessOnError();
Expand Down
6 changes: 0 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -957,12 +957,6 @@
"description": "Whether to lint Python files using mypy.",
"scope": "resource"
},
"python.linting.lintOnTextChange": {
"type": "boolean",
"default": true,
"description": "Whether to lint Python files when modified.",
"scope": "resource"
},
"python.linting.lintOnSave": {
"type": "boolean",
"default": true,
Expand Down
3 changes: 1 addition & 2 deletions src/client/common/configSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export interface ILintingSettings {
flake8Args: string[];
pydocstyleEnabled: boolean;
pydocstyleArgs: string[];
lintOnTextChange: boolean;
lintOnSave: boolean;
maxNumberOfProblems: number;
pylintCategorySeverity: IPylintCategorySeverity;
Expand Down Expand Up @@ -242,7 +241,7 @@ export class PythonSettings extends EventEmitter implements IPythonSettings {
enabledWithoutWorkspace: false,
ignorePatterns: [],
flake8Args: [], flake8Enabled: false, flake8Path: 'flake',
lintOnSave: false, lintOnTextChange: false, maxNumberOfProblems: 100,
lintOnSave: false, maxNumberOfProblems: 100,
mypyArgs: [], mypyEnabled: false, mypyPath: 'mypy',
outputWindow: 'python', pep8Args: [], pep8Enabled: false, pep8Path: 'pep8',
pylamaArgs: [], pylamaEnabled: false, pylamaPath: 'pylama',
Expand Down
35 changes: 25 additions & 10 deletions src/client/common/featureDeprecationManager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import { commands, Disposable, window, workspace } from 'vscode';
import { commands, Disposable, window, workspace, WorkspaceConfiguration } from 'vscode';
import { launch } from './net/browser';
import { IPersistentStateFactory } from './persistentState';

Expand All @@ -10,7 +10,12 @@ type deprecatedFeatureInfo = {
message: string;
moreInfoUrl: string;
commands?: string[];
setting?: string;
setting?: deprecatedSettingAndValue;
};

type deprecatedSettingAndValue = {
setting: string;
values?: {}[];
};

const jupyterDeprecationInfo: deprecatedFeatureInfo = {
Expand All @@ -27,7 +32,13 @@ const deprecatedFeatures: deprecatedFeatureInfo[] = [
doNotDisplayPromptStateKey: 'SHOW_DEPRECATED_FEATURE_PROMPT_FORMAT_ON_SAVE',
message: 'The setting \'python.formatting.formatOnSave\' is deprecated, please use \'editor.formatOnSave\'.',
moreInfoUrl: 'https://github.com/Microsoft/vscode-python/issues/309',
setting: 'formatting.formatOnSave'
setting: { setting: 'formatting.formatOnSave', values: ['true', true] }
},
{
doNotDisplayPromptStateKey: 'SHOW_DEPRECATED_FEATURE_PROMPT_LINT_ON_TEXT_CHANGE',
message: 'The setting \'python.linting.lintOnTextChange\' is deprecated, please enable \'python.linting.lintOnSave\' and \'files.autoSave\'.',
moreInfoUrl: 'https://github.com/Microsoft/vscode-python/issues/313',
setting: { setting: 'linting.lintOnTextChange', values: ['true', true] }
}
];

Expand All @@ -37,7 +48,6 @@ export interface IFeatureDeprecationManager extends Disposable {

export class FeatureDeprecationManager implements IFeatureDeprecationManager {
private disposables: Disposable[] = [];
private settingDeprecationNotified: string[] = [];
constructor(private persistentStateFactory: IPersistentStateFactory, private jupyterExtensionInstalled: boolean) { }
public dispose() {
this.disposables.forEach(disposable => disposable.dispose());
Expand All @@ -59,26 +69,31 @@ export class FeatureDeprecationManager implements IFeatureDeprecationManager {
}
}
private checkAndNotifyDeprecatedSetting(deprecatedInfo: deprecatedFeatureInfo) {
const setting = deprecatedInfo.setting!;
let notify = false;
if (Array.isArray(workspace.workspaceFolders) && workspace.workspaceFolders.length > 0) {
workspace.workspaceFolders.forEach(workspaceFolder => {
if (notify) {
return;
}
const pythonConfig = workspace.getConfiguration('python', workspaceFolder.uri);
notify = pythonConfig.has(setting) && this.settingDeprecationNotified.indexOf(setting) === -1;
notify = this.isDeprecatedSettingAndValueUsed(workspace.getConfiguration('python', workspaceFolder.uri), deprecatedInfo.setting!);
});
} else {
const pythonConfig = workspace.getConfiguration('python');
notify = pythonConfig.has(setting) && this.settingDeprecationNotified.indexOf(setting) === -1;
notify = this.isDeprecatedSettingAndValueUsed(workspace.getConfiguration('python'), deprecatedInfo.setting!);
}

if (notify) {
this.settingDeprecationNotified.push(setting);
this.notifyDeprecation(deprecatedInfo);
}
}
private isDeprecatedSettingAndValueUsed(pythonConfig: WorkspaceConfiguration, deprecatedSetting: deprecatedSettingAndValue) {
if (!pythonConfig.has(deprecatedSetting.setting)) {
return false;
}
if (!Array.isArray(deprecatedSetting.values) || deprecatedSetting.values.length === 0) {
return true;
}
return deprecatedSetting.values.indexOf(pythonConfig.get(deprecatedSetting.setting)!) >= 0;
}
private async notifyDeprecation(deprecatedInfo: deprecatedFeatureInfo) {
const notificationPromptEnabled = this.persistentStateFactory.createGlobalPersistentState(deprecatedInfo.doNotDisplayPromptStateKey, true);
if (!notificationPromptEnabled.value) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const fileInNonRootWorkspace = path.join(__dirname, '..', '..', 'src', 'test', '
export const rootWorkspaceUri = getWorkspaceRoot();

export type PythonSettingKeys = 'workspaceSymbols.enabled' | 'pythonPath' |
'linting.lintOnSave' | 'linting.lintOnTextChange' |
'linting.lintOnSave' |
'linting.enabled' | 'linting.pylintEnabled' |
'linting.flake8Enabled' | 'linting.pep8Enabled' | 'linting.pylamaEnabled' |
'linting.prospectorEnabled' | 'linting.pydocstyleEnabled' | 'linting.mypyEnabled' |
Expand Down
11 changes: 2 additions & 9 deletions src/test/linters/lint.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as assert from 'assert';
import * as fs from 'fs-extra';
import * as path from 'path';
import * as vscode from 'vscode';
import { PythonSettings } from '../../client/common/configSettings';
Expand All @@ -22,7 +21,6 @@ const pep8ConfigPath = path.join(pythoFilesPath, 'pep8config');
const pydocstyleConfigPath27 = path.join(pythoFilesPath, 'pydocstyleconfig27');
const pylintConfigPath = path.join(pythoFilesPath, 'pylintconfig');
const fileToLint = path.join(pythoFilesPath, 'file.py');
let pylintFileToLintLines: string[] = [];

const pylintMessagesToBeReturned: baseLinter.ILintMessage[] = [
{ line: 24, column: 0, severity: baseLinter.LintMessageSeverity.Information, code: 'I0011', message: 'Locally disabling no-member (E1101)', provider: '', type: '' },
Expand Down Expand Up @@ -114,7 +112,6 @@ suite('Linting', () => {
const isPython3Deferred = createDeferred<boolean>();
const isPython3 = isPython3Deferred.promise;
suiteSetup(async () => {
pylintFileToLintLines = fs.readFileSync(fileToLint).toString('utf-8').split(/\r?\n/g);
await initialize();
const version = await execPythonFile(fileToLint, PythonSettings.getInstance(vscode.Uri.file(fileToLint)).pythonPath, ['--version'], __dirname, true);
isPython3Deferred.resolve(version.indexOf('3.') >= 0);
Expand All @@ -135,7 +132,6 @@ suite('Linting', () => {
await updateSetting('linting.enabled', true, rootWorkspaceUri, vscode.ConfigurationTarget.WorkspaceFolder);
}
await updateSetting('linting.lintOnSave', false, rootWorkspaceUri, vscode.ConfigurationTarget.Workspace);
await updateSetting('linting.lintOnTextChange', false, rootWorkspaceUri, vscode.ConfigurationTarget.Workspace);
await updateSetting('linting.pylintEnabled', false, rootWorkspaceUri, vscode.ConfigurationTarget.Workspace);
await updateSetting('linting.flake8Enabled', false, rootWorkspaceUri, vscode.ConfigurationTarget.Workspace);
await updateSetting('linting.pep8Enabled', false, rootWorkspaceUri, vscode.ConfigurationTarget.Workspace);
Expand All @@ -146,7 +142,6 @@ suite('Linting', () => {

if (IS_MULTI_ROOT_TEST) {
await updateSetting('linting.lintOnSave', false, rootWorkspaceUri, vscode.ConfigurationTarget.WorkspaceFolder);
await updateSetting('linting.lintOnTextChange', false, rootWorkspaceUri, vscode.ConfigurationTarget.WorkspaceFolder);
await updateSetting('linting.pylintEnabled', false, rootWorkspaceUri, vscode.ConfigurationTarget.WorkspaceFolder);
await updateSetting('linting.flake8Enabled', false, rootWorkspaceUri, vscode.ConfigurationTarget.WorkspaceFolder);
await updateSetting('linting.pep8Enabled', false, rootWorkspaceUri, vscode.ConfigurationTarget.WorkspaceFolder);
Expand All @@ -164,8 +159,7 @@ suite('Linting', () => {
const messages = await linter.lint(editor.document, cancelToken.token);
if (enabled) {
assert.notEqual(messages.length, 0, `No linter errors when linter is enabled, Output - ${output.output}`);
}
else {
} else {
assert.equal(messages.length, 0, `Errors returned when linter is disabled, Output - ${output.output}`);
}
}
Expand Down Expand Up @@ -217,8 +211,7 @@ suite('Linting', () => {
const messages = await linter.lint(editor.document, cancelToken.token);
if (messagesToBeReceived.length === 0) {
assert.equal(messages.length, 0, `No errors in linter, Output - ${outputChannel.output}`);
}
else {
} else {
if (outputChannel.output.indexOf('ENOENT') === -1) {
// Pylint for Python Version 2.7 could return 80 linter messages, where as in 3.5 it might only return 1.
// Looks like pylint stops linting as soon as it comes across any ERRORS.
Expand Down