@@ -32,21 +32,23 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules
3232#if ! CORECLR
3333[ Export ( typeof ( IScriptRule ) ) ]
3434#endif
35- public class CmdletSingularNoun : IScriptRule
35+ public class CmdletSingularNoun : ConfigurableRule
3636 {
37+ [ ConfigurableRuleProperty ( defaultValue : new string [ ] { "Data" , "Windows" } ) ]
38+ public string [ ] NounAllowList { get ; set ; }
3739
38- private readonly string [ ] nounAllowList =
40+ public CmdletSingularNoun ( )
3941 {
40- "Data"
41- } ;
42+ Enable = true ;
43+ }
4244
4345 /// <summary>
4446 /// Checks that all defined cmdlet use singular noun
4547 /// </summary>
4648 /// <param name="ast"></param>
4749 /// <param name="fileName"></param>
4850 /// <returns></returns>
49- public IEnumerable < DiagnosticRecord > AnalyzeScript ( Ast ast , string fileName )
51+ public override IEnumerable < DiagnosticRecord > AnalyzeScript ( Ast ast , string fileName )
5052 {
5153 if ( ast == null ) throw new ArgumentNullException ( Strings . NullCommandInfoError ) ;
5254
@@ -70,7 +72,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
7072
7173 if ( pluralizer . CanOnlyBePlural ( noun ) )
7274 {
73- if ( nounAllowList . Contains ( noun , StringComparer . OrdinalIgnoreCase ) )
75+ if ( NounAllowList . Contains ( noun , StringComparer . OrdinalIgnoreCase ) )
7476 {
7577 continue ;
7678 }
@@ -99,7 +101,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
99101 /// GetName: Retrieves the name of this rule.
100102 /// </summary>
101103 /// <returns>The name of this rule</returns>
102- public string GetName ( )
104+ public override string GetName ( )
103105 {
104106 return string . Format ( CultureInfo . CurrentCulture , Strings . NameSpaceFormat , GetSourceName ( ) , Strings . UseSingularNounsName ) ;
105107 }
@@ -108,7 +110,7 @@ public string GetName()
108110 /// GetName: Retrieves the common name of this rule.
109111 /// </summary>
110112 /// <returns>The common name of this rule</returns>
111- public string GetCommonName ( )
113+ public override string GetCommonName ( )
112114 {
113115 return string . Format ( CultureInfo . CurrentCulture , Strings . UseSingularNounsCommonName ) ;
114116 }
@@ -117,15 +119,15 @@ public string GetCommonName()
117119 /// GetDescription: Retrieves the description of this rule.
118120 /// </summary>
119121 /// <returns>The description of this rule</returns>
120- public string GetDescription ( )
122+ public override string GetDescription ( )
121123 {
122124 return string . Format ( CultureInfo . CurrentCulture , Strings . UseSingularNounsDescription ) ;
123125 }
124126
125127 /// <summary>
126128 /// GetSourceType: Retrieves the type of the rule: builtin, managed or module.
127129 /// </summary>
128- public SourceType GetSourceType ( )
130+ public override SourceType GetSourceType ( )
129131 {
130132 return SourceType . Builtin ;
131133 }
@@ -134,15 +136,15 @@ public SourceType GetSourceType()
134136 /// GetSeverity: Retrieves the severity of the rule: error, warning of information.
135137 /// </summary>
136138 /// <returns></returns>
137- public RuleSeverity GetSeverity ( )
139+ public override RuleSeverity GetSeverity ( )
138140 {
139141 return RuleSeverity . Warning ;
140142 }
141143
142144 /// <summary>
143145 /// GetSourceName: Retrieves the module/assembly name the rule is from.
144146 /// </summary>
145- public string GetSourceName ( )
147+ public override string GetSourceName ( )
146148 {
147149 return string . Format ( CultureInfo . CurrentCulture , Strings . SourceName ) ;
148150 }
0 commit comments