11import * as vscode from 'vscode' ;
22import * as cp from 'child_process' ;
3- import * as path from "path" ;
43import * as xml2js from 'xml2js' ;
54
65import { documentationLinkMap } from './util/documentation' ;
@@ -100,6 +99,11 @@ export async function activate(context: vscode.ExtensionContext) {
10099 const commandPath = userPath ? resolvePath ( userPath ) : "cppcheck" ;
101100
102101 var args = config . get < string > ( "cppcheck-official.arguments" , "" ) ;
102+ // If user enter arguments as array we parse them into space separated string format
103+ if ( args . startsWith ( "[" ) && args . endsWith ( "]" ) ) {
104+ args = args . replaceAll ( "[" , "" ) . replaceAll ( "]" , "" ) . replaceAll ( "," , " " ) ;
105+ }
106+
103107 var processedArgs = '' ;
104108 // If argument field contains command to run script we do so here
105109 if ( args . includes ( '@(' ) ) {
@@ -195,10 +199,11 @@ async function runCppcheckOnFileXML(
195199
196200 // Resolve paths for arguments where applicable
197201 const argsParsed = processedArgs . split ( " " ) . map ( ( arg ) => {
198- const isPathArgument = pathVariableArgs . some ( a => arg . startsWith ( a ) ) ;
202+ let cleanedArg = arg . replaceAll ( "\"" , "" ) ;
203+ const isPathArgument = pathVariableArgs . some ( a => cleanedArg . startsWith ( a ) ) ;
199204 // Some arguments such as addon may be either a path or the name of a built in addon
200- if ( isPathArgument && looksLikePath ( arg ) ) {
201- const splitArg = arg . split ( '=' ) ;
205+ if ( isPathArgument && looksLikePath ( cleanedArg ) ) {
206+ const splitArg = cleanedArg . split ( '=' ) ;
202207 return `${ splitArg [ 0 ] } =${ resolvePath ( splitArg [ 1 ] ) } ` ;
203208 }
204209 return arg ;
@@ -216,6 +221,8 @@ async function runCppcheckOnFileXML(
216221 ] . filter ( Boolean ) ;
217222 if ( processedArgs . includes ( "--project" ) ) {
218223 args . push ( `--file-filter=${ filePath } ` ) ;
224+ } else {
225+ args . push ( filePath ) ;
219226 }
220227 const cwd = findWorkspaceRoot ( ) ;
221228 proc = cp . spawn ( commandPath , args , {
0 commit comments