@@ -32,21 +32,23 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules
32
32
#if ! CORECLR
33
33
[ Export ( typeof ( IScriptRule ) ) ]
34
34
#endif
35
- public class CmdletSingularNoun : IScriptRule
35
+ public class CmdletSingularNoun : ConfigurableRule
36
36
{
37
+ [ ConfigurableRuleProperty ( defaultValue : new string [ ] { "Data" , "Windows" } ) ]
38
+ public string [ ] NounAllowList { get ; set ; }
37
39
38
- private readonly string [ ] nounAllowList =
40
+ public CmdletSingularNoun ( )
39
41
{
40
- "Data"
41
- } ;
42
+ Enable = true ;
43
+ }
42
44
43
45
/// <summary>
44
46
/// Checks that all defined cmdlet use singular noun
45
47
/// </summary>
46
48
/// <param name="ast"></param>
47
49
/// <param name="fileName"></param>
48
50
/// <returns></returns>
49
- public IEnumerable < DiagnosticRecord > AnalyzeScript ( Ast ast , string fileName )
51
+ public override IEnumerable < DiagnosticRecord > AnalyzeScript ( Ast ast , string fileName )
50
52
{
51
53
if ( ast == null ) throw new ArgumentNullException ( Strings . NullCommandInfoError ) ;
52
54
@@ -70,7 +72,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
70
72
71
73
if ( pluralizer . CanOnlyBePlural ( noun ) )
72
74
{
73
- if ( nounAllowList . Contains ( noun , StringComparer . OrdinalIgnoreCase ) )
75
+ if ( NounAllowList . Contains ( noun , StringComparer . OrdinalIgnoreCase ) )
74
76
{
75
77
continue ;
76
78
}
@@ -99,7 +101,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
99
101
/// GetName: Retrieves the name of this rule.
100
102
/// </summary>
101
103
/// <returns>The name of this rule</returns>
102
- public string GetName ( )
104
+ public override string GetName ( )
103
105
{
104
106
return string . Format ( CultureInfo . CurrentCulture , Strings . NameSpaceFormat , GetSourceName ( ) , Strings . UseSingularNounsName ) ;
105
107
}
@@ -108,7 +110,7 @@ public string GetName()
108
110
/// GetName: Retrieves the common name of this rule.
109
111
/// </summary>
110
112
/// <returns>The common name of this rule</returns>
111
- public string GetCommonName ( )
113
+ public override string GetCommonName ( )
112
114
{
113
115
return string . Format ( CultureInfo . CurrentCulture , Strings . UseSingularNounsCommonName ) ;
114
116
}
@@ -117,15 +119,15 @@ public string GetCommonName()
117
119
/// GetDescription: Retrieves the description of this rule.
118
120
/// </summary>
119
121
/// <returns>The description of this rule</returns>
120
- public string GetDescription ( )
122
+ public override string GetDescription ( )
121
123
{
122
124
return string . Format ( CultureInfo . CurrentCulture , Strings . UseSingularNounsDescription ) ;
123
125
}
124
126
125
127
/// <summary>
126
128
/// GetSourceType: Retrieves the type of the rule: builtin, managed or module.
127
129
/// </summary>
128
- public SourceType GetSourceType ( )
130
+ public override SourceType GetSourceType ( )
129
131
{
130
132
return SourceType . Builtin ;
131
133
}
@@ -134,15 +136,15 @@ public SourceType GetSourceType()
134
136
/// GetSeverity: Retrieves the severity of the rule: error, warning of information.
135
137
/// </summary>
136
138
/// <returns></returns>
137
- public RuleSeverity GetSeverity ( )
139
+ public override RuleSeverity GetSeverity ( )
138
140
{
139
141
return RuleSeverity . Warning ;
140
142
}
141
143
142
144
/// <summary>
143
145
/// GetSourceName: Retrieves the module/assembly name the rule is from.
144
146
/// </summary>
145
- public string GetSourceName ( )
147
+ public override string GetSourceName ( )
146
148
{
147
149
return string . Format ( CultureInfo . CurrentCulture , Strings . SourceName ) ;
148
150
}
0 commit comments