@@ -29,11 +29,42 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules
2929 class AlignAssignmentStatement : ConfigurableRule
3030 {
3131
32+ private List < Func < TokenOperations , IEnumerable < DiagnosticRecord > > > violationFinders
33+ = new List < Func < TokenOperations , IEnumerable < DiagnosticRecord > > > ( ) ;
34+
3235 [ ConfigurableRuleProperty ( defaultValue : true ) ]
33- public bool AlignInHashtable { get ; set ; }
36+ public bool CheckHashtable { get ; set ; }
3437
3538 [ ConfigurableRuleProperty ( defaultValue : true ) ]
36- public bool AlignInDSCConfiguration { get ; set ; }
39+ public bool CheckDSCConfiguration { get ; set ; }
40+
41+ public override void ConfigureRule ( IDictionary < string , object > paramValueMap )
42+ {
43+ base . ConfigureRule ( paramValueMap ) ;
44+ if ( CheckHashtable )
45+ {
46+ violationFinders . Add ( FindHashtableViolations ) ;
47+ }
48+
49+ if ( CheckDSCConfiguration )
50+ {
51+ violationFinders . Add ( FindDSCConfigurationViolations ) ;
52+ }
53+ }
54+
55+ private IEnumerable < DiagnosticRecord > FindDSCConfigurationViolations ( TokenOperations arg )
56+ {
57+ throw new NotImplementedException ( ) ;
58+ }
59+
60+ private IEnumerable < DiagnosticRecord > FindHashtableViolations ( TokenOperations tokenOps )
61+ {
62+ var hashtableAsts = tokenOps . Ast . FindAll ( ast => ast is HashtableAst , true ) ;
63+ if ( hashtableAsts == null )
64+ {
65+ yield break ;
66+ }
67+ }
3768
3869 /// <summary>
3970 /// Analyzes the given ast to find if consecutive assignment statements are aligned.
@@ -47,6 +78,10 @@ public override IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string file
4778 {
4879 throw new ArgumentNullException ( "ast" ) ;
4980 }
81+ // only handles one line assignments
82+ // if the rule encounters assignment statements that are multi-line, the rule will ignore that block
83+
84+
5085
5186 // your code goes here
5287 yield break ;
0 commit comments