@@ -64,7 +64,7 @@ export abstract class BaseLinter {
6464
6565 return new Promise < ILintMessage [ ] > ( ( resolve , reject ) => {
6666 execPythonFile ( command , args , cwd , true ) . then ( data => {
67- outputChannel . clear ( ) ;
67+ outputChannel . append ( "#" . repeat ( 10 ) + "Linting Output - " + this . Id + "#" . repeat ( 10 ) ) ;
6868 outputChannel . append ( data ) ;
6969 var outputLines = data . split ( / \r ? \n / g) ;
7070 var diagnostics : ILintMessage [ ] = [ ] ;
@@ -108,10 +108,29 @@ export abstract class BaseLinter {
108108
109109 resolve ( diagnostics ) ;
110110 } ) . catch ( error => {
111- outputChannel . appendLine ( `Linting with ${ linterId } failed. If not installed please turn if off in settings.\n ${ error } ` ) ;
112- window . showInformationMessage ( `Linting with ${ linterId } failed. If not installed please turn if off in settings. View Python output for details.` ) ;
111+ this . handleError ( this . Id , command , error ) ;
113112 return [ ] ;
114113 } ) ;
115114 } ) ;
116115 }
116+
117+ protected handleError ( expectedFileName : string , fileName : string , error : Error ) {
118+ let customError = "Linting with ${this.Id} failed. Please install the linter or turn it off.\n" ;
119+
120+ if ( typeof ( error ) === "object" && error !== null && ( ( < any > error ) . code === "ENOENT" || ( < any > error ) . code === 127 ) ) {
121+ // Check if we have some custom arguments such as "pylint --load-plugins pylint_django"
122+ // Such settings are no longer supported
123+ let stuffAfterFileName = fileName . substring ( fileName . toUpperCase ( ) . lastIndexOf ( expectedFileName ) + expectedFileName . length ) ;
124+
125+ // Ok if we have a space after the file name, this means we have some arguments defined and this isn't supported
126+ if ( stuffAfterFileName . trim ( ) . indexOf ( " " ) ) {
127+ customError = `Linting failed, custom arguments in the 'python.linting.${ this . Id } Path' is not supported.\n` +
128+ `Custom arguments to the linters can be defined in 'python.linting.${ this . Id } Args' setting of settings.json.\n` +
129+ "For further details, please see https://github.com/DonJayamanne/pythonVSCode/wiki/Troubleshooting-Linting#2-linting-with-xxx-failed-" ;
130+ }
131+ }
132+
133+ this . outputChannel . appendLine ( `${ customError } \n${ error } ` ) ;
134+ window . showInformationMessage ( `${ customError } . View Python output for details.` ) ;
135+ }
117136}
0 commit comments