@@ -28,11 +28,16 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules
2828#endif
2929 public class PlaceCloseBrace : ConfigurableScriptRule
3030 {
31+ /// <summary>
32+ /// Indicates if there should or should not be an empty line before a close brace.
33+ ///
34+ /// Default value if false.
35+ /// </summary>
3136 [ ConfigurableRuleProperty ( defaultValue : false ) ]
3237 public bool NoEmptyLineBefore { get ; protected set ; }
3338
3439 /// <summary>
35- /// Analyzes the given ast to find the [violation]
40+ /// Analyzes the given ast to find violations.
3641 /// </summary>
3742 /// <param name="ast">AST to be analyzed. This should be non-null</param>
3843 /// <param name="fileName">Name of file that corresponds to the input AST.</param>
@@ -102,6 +107,67 @@ public override IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string file
102107 return diagnosticRecords ;
103108 }
104109
110+ /// <summary>
111+ /// Retrieves the common name of this rule.
112+ /// </summary>
113+ public override string GetCommonName ( )
114+ {
115+ return string . Format ( CultureInfo . CurrentCulture , Strings . PlaceCloseBraceCommonName ) ;
116+ }
117+
118+ /// <summary>
119+ /// Retrieves the description of this rule.
120+ /// </summary>
121+ public override string GetDescription ( )
122+ {
123+ return string . Format ( CultureInfo . CurrentCulture , Strings . PlaceCloseBraceDescription ) ;
124+ }
125+
126+ /// <summary>
127+ /// Retrieves the name of this rule.
128+ /// </summary>
129+ public override string GetName ( )
130+ {
131+ return string . Format (
132+ CultureInfo . CurrentCulture ,
133+ Strings . NameSpaceFormat ,
134+ GetSourceName ( ) ,
135+ Strings . PlaceCloseBraceName ) ;
136+ }
137+
138+ /// <summary>
139+ /// Retrieves the severity of the rule: error, warning or information.
140+ /// </summary>
141+ public override RuleSeverity GetSeverity ( )
142+ {
143+ return RuleSeverity . Information ;
144+ }
145+
146+ /// <summary>
147+ /// Gets the severity of the returned diagnostic record: error, warning, or information.
148+ /// </summary>
149+ /// <returns></returns>
150+ public DiagnosticSeverity GetDiagnosticSeverity ( )
151+ {
152+ return DiagnosticSeverity . Information ;
153+ }
154+
155+ /// <summary>
156+ /// Retrieves the name of the module/assembly the rule is from.
157+ /// </summary>
158+ public override string GetSourceName ( )
159+ {
160+ return string . Format ( CultureInfo . CurrentCulture , Strings . SourceName ) ;
161+ }
162+
163+ /// <summary>
164+ /// Retrieves the type of the rule, Builtin, Managed or Module.
165+ /// </summary>
166+ public override SourceType GetSourceType ( )
167+ {
168+ return SourceType . Builtin ;
169+ }
170+
105171 private DiagnosticRecord GetViolationForBraceShouldNotFollowEmptyLine (
106172 Token [ ] tokens ,
107173 int closeBracePos ,
@@ -258,75 +324,9 @@ private List<Token> GetTokens(Ast ast, List<Token> tokens, ref Dictionary<Ast, L
258324 return tokenSet ;
259325 }
260326
261- /// <summary>
262- /// Retrieves the error message of this rule
263- /// </summary>
264- private string GetError ( string errorString )
327+ private static string GetError ( string errorString )
265328 {
266329 return string . Format ( CultureInfo . CurrentCulture , errorString ) ;
267330 }
268-
269- /// <summary>
270- /// Retrieves the common name of this rule.
271- /// </summary>
272- public override string GetCommonName ( )
273- {
274- return string . Format ( CultureInfo . CurrentCulture , Strings . PlaceCloseBraceCommonName ) ;
275- }
276-
277- /// <summary>
278- /// Retrieves the description of this rule.
279- /// </summary>
280- public override string GetDescription ( )
281- {
282- return string . Format ( CultureInfo . CurrentCulture , Strings . PlaceCloseBraceDescription ) ;
283- }
284-
285- /// <summary>
286- /// Retrieves the name of this rule.
287- /// </summary>
288- public override string GetName ( )
289- {
290- return string . Format (
291- CultureInfo . CurrentCulture ,
292- Strings . NameSpaceFormat ,
293- GetSourceName ( ) ,
294- Strings . PlaceCloseBraceName ) ;
295- }
296-
297- /// <summary>
298- /// Retrieves the severity of the rule: error, warning or information.
299- /// </summary>
300- public override RuleSeverity GetSeverity ( )
301- {
302- return RuleSeverity . Information ;
303- }
304-
305- /// <summary>
306- /// Gets the severity of the returned diagnostic record: error, warning, or information.
307- /// </summary>
308- /// <returns></returns>
309- public DiagnosticSeverity GetDiagnosticSeverity ( )
310- {
311- return DiagnosticSeverity . Information ;
312- }
313-
314- /// <summary>
315- /// Retrieves the name of the module/assembly the rule is from.
316- /// </summary>
317- public override string GetSourceName ( )
318- {
319- return string . Format ( CultureInfo . CurrentCulture , Strings . SourceName ) ;
320- }
321-
322- /// <summary>
323- /// Retrieves the type of the rule, Builtin, Managed or Module.
324- /// </summary>
325- public override SourceType GetSourceType ( )
326- {
327- return SourceType . Builtin ;
328- }
329-
330-
331331 }
332332}
0 commit comments