File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import * as xml2js from 'xml2js';
55
66import { documentationLinkMap } from './util/documentation' ;
77import { runCommand } from './util/scripts' ;
8- import { resolvePath , findWorkspaceRoot } from './util/path' ;
8+ import { looksLikePath , resolvePath , findWorkspaceRoot } from './util/path' ;
99
1010enum SeverityNumber {
1111 Info = 0 ,
@@ -30,6 +30,14 @@ const criticalWarningTypes = [
3030 'unknownMacro'
3131] ;
3232
33+ const pathVariableArgs = [
34+ '--project' ,
35+ '--addon' ,
36+ '--suppressions-list' ,
37+ '--include' ,
38+ '--rule-file' ,
39+ ] ;
40+
3341function parseSeverity ( str : string ) : vscode . DiagnosticSeverity {
3442 const lower = str . toLowerCase ( ) ;
3543 if ( lower . includes ( "error" ) ) {
@@ -187,7 +195,9 @@ async function runCppcheckOnFileXML(
187195
188196 // Resolve paths for arguments where applicable
189197 const argsParsed = processedArgs . split ( " " ) . map ( ( arg ) => {
190- if ( arg . startsWith ( '--project' ) ) {
198+ const isPathArgument = pathVariableArgs . some ( a => arg . startsWith ( a ) ) ;
199+ // Some arguments such as addon may be either a path or the name of a built in addon
200+ if ( isPathArgument && looksLikePath ( arg ) ) {
191201 const splitArg = arg . split ( '=' ) ;
192202 return `${ splitArg [ 0 ] } =${ resolvePath ( splitArg [ 1 ] ) } ` ;
193203 }
Original file line number Diff line number Diff line change @@ -2,6 +2,18 @@ import * as path from "path";
22import * as os from "os" ;
33import * as vscode from 'vscode' ;
44
5+ export function looksLikePath ( arg : string ) : boolean {
6+ if (
7+ arg . includes ( '/' )
8+ || arg . includes ( '\\' )
9+ || arg . startsWith ( '.' )
10+ || / \. [ ^ / \\ ] + $ / . test ( arg ) // filename with extension
11+ ) {
12+ return true ;
13+ }
14+ return false ;
15+ }
16+
517export function findWorkspaceRoot ( ) : string {
618 const folders = vscode . workspace . workspaceFolders ;
719 const workspaceRoot = folders && folders . length > 0
You can’t perform that action at this time.
0 commit comments