@@ -29,11 +29,42 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules
29
29
class AlignAssignmentStatement : ConfigurableRule
30
30
{
31
31
32
+ private List < Func < TokenOperations , IEnumerable < DiagnosticRecord > > > violationFinders
33
+ = new List < Func < TokenOperations , IEnumerable < DiagnosticRecord > > > ( ) ;
34
+
32
35
[ ConfigurableRuleProperty ( defaultValue : true ) ]
33
- public bool AlignInHashtable { get ; set ; }
36
+ public bool CheckHashtable { get ; set ; }
34
37
35
38
[ 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
+ }
37
68
38
69
/// <summary>
39
70
/// 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
47
78
{
48
79
throw new ArgumentNullException ( "ast" ) ;
49
80
}
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
+
50
85
51
86
// your code goes here
52
87
yield break ;
0 commit comments