@@ -265,6 +265,9 @@ protected override void BeginProcessing()
265
265
ProcessPath ( ) ;
266
266
}
267
267
268
+ string [ ] combRulePaths = null ;
269
+ var combRecurseCustomRulePath = RecurseCustomRulePath . IsPresent ;
270
+ var combIncludeDefaultRules = IncludeDefaultRules . IsPresent ;
268
271
try
269
272
{
270
273
var settingsObj = PSSASettings . Create (
@@ -274,7 +277,26 @@ protected override void BeginProcessing()
274
277
if ( settingsObj != null )
275
278
{
276
279
ScriptAnalyzer . Instance . UpdateSettings ( settingsObj ) ;
280
+
281
+ // For includeDefaultRules and RecurseCustomRulePath we override the value in the settings file by
282
+ // command line argument.
283
+ combRecurseCustomRulePath = combRecurseCustomRulePath || settingsObj . RecurseCustomRulePath ;
284
+ combIncludeDefaultRules = combIncludeDefaultRules || settingsObj . IncludeDefaultRules ;
277
285
}
286
+
287
+ // Ideally we should not allow the parameter to be set from settings and command line
288
+ // simultaneously. But since, this was done before with IncludeRules, ExcludeRules and Severity,
289
+ // we use the same strategy for CustomRulePath. So, we take the union of CustomRulePath provided in
290
+ // the settings file and if provided on command line.
291
+ var settingsCustomRulePath = Helper . ProcessCustomRulePaths (
292
+ settingsObj ? . CustomRulePath ? . ToArray ( ) ,
293
+ this . SessionState ,
294
+ combRecurseCustomRulePath ) ;
295
+ combRulePaths = rulePaths == null
296
+ ? settingsCustomRulePath
297
+ : settingsCustomRulePath == null
298
+ ? rulePaths
299
+ : rulePaths . Concat ( settingsCustomRulePath ) . ToArray ( ) ;
278
300
}
279
301
catch
280
302
{
@@ -285,11 +307,11 @@ protected override void BeginProcessing()
285
307
286
308
ScriptAnalyzer . Instance . Initialize (
287
309
this ,
288
- rulePaths ,
310
+ combRulePaths ,
289
311
this . includeRule ,
290
312
this . excludeRule ,
291
313
this . severity ,
292
- null == rulePaths ? true : this . includeDefaultRules ,
314
+ combRulePaths == null || combIncludeDefaultRules ,
293
315
this . suppressedOnly ) ;
294
316
}
295
317
0 commit comments