Skip to content

Commit 6470d2e

Browse files
committed
Make rule optional, disabled by default
1 parent 889363e commit 6470d2e

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

Rules/UseConsistentParameterSetName.cs

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules
2222
#if !CORECLR
2323
[Export(typeof(IScriptRule))]
2424
#endif
25-
public class UseConsistentParameterSetName : IScriptRule
25+
public class UseConsistentParameterSetName : ConfigurableRule
2626
{
2727

2828
private const string AllParameterSetsName = "__AllParameterSets";
2929

3030
/// <summary>
3131
/// AnalyzeScript: Check for parameter set name issues.
3232
/// </summary>
33-
public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
33+
public override IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
3434
{
3535
if (ast == null)
3636
{
@@ -341,20 +341,6 @@ private static string GetNamedArgumentValue(AttributeAst attributeAst, string ar
341341
private static IScriptExtent GetParameterSetNameValueExtent(AttributeAst attributeAst)
342342
{
343343
return GetAttributeNamedArgumentValueExtent(attributeAst, "ParameterSetName", "Parameter");
344-
// if (attributeAst == null || attributeAst.NamedArguments == null)
345-
// return null;
346-
347-
// if (!string.Equals(attributeAst.TypeName?.Name, "Parameter", StringComparison.OrdinalIgnoreCase))
348-
// return null;
349-
350-
// foreach (var namedArg in attributeAst.NamedArguments)
351-
// {
352-
// if (string.Equals(namedArg.ArgumentName, "ParameterSetName", StringComparison.OrdinalIgnoreCase))
353-
// {
354-
// return namedArg.Argument?.Extent;
355-
// }
356-
// }
357-
// return null;
358344
}
359345

360346
/// <summary>
@@ -421,7 +407,7 @@ public ParameterSetInfo(string parameterName, string parameterSetName, Attribute
421407
/// GetName: Retrieves the name of this rule.
422408
/// </summary>
423409
/// <returns>The name of this rule</returns>
424-
public string GetName() => string.Format(
410+
public override string GetName() => string.Format(
425411
CultureInfo.CurrentCulture,
426412
Strings.NameSpaceFormat,
427413
GetSourceName(),
@@ -432,7 +418,7 @@ public string GetName() => string.Format(
432418
/// GetCommonName: Retrieves the common name of this rule.
433419
/// </summary>
434420
/// <returns>The common name of this rule</returns>
435-
public string GetCommonName() => string.Format(
421+
public override string GetCommonName() => string.Format(
436422
CultureInfo.CurrentCulture,
437423
Strings.UseConsistentParameterSetNameCommonName
438424
);
@@ -441,26 +427,26 @@ public string GetCommonName() => string.Format(
441427
/// GetDescription: Retrieves the description of this rule.
442428
/// </summary>
443429
/// <returns>The description of this rule</returns>
444-
public string GetDescription() => string.Format(
430+
public override string GetDescription() => string.Format(
445431
CultureInfo.CurrentCulture,
446432
Strings.UseConsistentParameterSetNameDescription
447433
);
448434

449435
/// <summary>
450436
/// Method: Retrieves the type of the rule: builtin, managed or module.
451437
/// </summary>
452-
public SourceType GetSourceType() => SourceType.Builtin;
438+
public override SourceType GetSourceType() => SourceType.Builtin;
453439

454440
/// <summary>
455441
/// GetSeverity: Retrieves the severity of the rule: error, warning of information.
456442
/// </summary>
457443
/// <returns></returns>
458-
public RuleSeverity GetSeverity() => RuleSeverity.Warning;
444+
public override RuleSeverity GetSeverity() => RuleSeverity.Warning;
459445

460446
/// <summary>
461447
/// Method: Retrieves the module/assembly name the rule is from.
462448
/// </summary>
463-
public string GetSourceName() => string.Format(
449+
public override string GetSourceName() => string.Format(
464450
CultureInfo.CurrentCulture, Strings.SourceName
465451
);
466452
}

0 commit comments

Comments
 (0)