Commit 791ee64
Add UseUsingScopeModifierInNewRunspaces rule (#1419)
* Add tests for AvoidUnInitializedVarsInNewRunspaces
* Add strings for AvoidUnInitializedVarsInNewRunspaces
* Add documentation
* wrestling with Ast in C# - not working
* Add sensible warning message
* remove unnecessary boilerplate from test
* clean up and finetune rule
* Add RuleToTest parameter to Test-ScriptAnalyzer to aid with test driven rule development
* increment rule count to fix test
* add reference to rule documentation
* exclude built-in variables
* change using directive => scoope modifier
* add tests for InlineScript, Invoke-Command and Start-(Thread)Job
* add rule implementation for InlineScript, Invoke-Command and Start-(Thread)Job
* Refactor and cleanup
* small cleanup
* explain all applicable situations in documentation
* simplify code for adding sessions to dict
* Revert "Add RuleToTest parameter to Test-ScriptAnalyzer to aid with test driven rule development"
This reverts commit 99c2bea.
Undo -RuleToTest param
* Rename rule to UseUsingScopeModifierInNewRunspaces
Because this has a posive ring to it and points the user to the solution
* refactor grouping of script blocks by session name
* Add suggested correction implementation
* Add test for suggested corrections, fix typos
* Refactor to AstVisitor/AstVisitor2 WIP
TODO: finish refactor for `Invoke-Command -Session` logic
* Update Rules/UseUsingScopeModifierInNewRunspaces.cs
Co-Authored-By: Robert Holt <[email protected]>
* Update Rules/UseUsingScopeModifierInNewRunspaces.cs
Co-Authored-By: Robert Holt <[email protected]>
* Process review comments
- Always use braces with if statements
- Use ast.VariablePath.UserPath instead of ast.Extent.Text
- simplify return list of corrections
- add TODO's fo invoke-command-session code
- Add TODO for commandAst.GetCommandName() can be null
- Invert if for readability
* Add tests for command name and icm -session
* Add icm -session logic to visitor and tidy up
* fix build for windows powershell
* Revert "fix build for windows powershell"
This reverts commit 921c1d2.
revert fix, because multiple unintended changes were pushed along with it.
* Change private class to internal class for Windows PowerShell
* Add logic to detect DSCScriptResource
* Add tests for DSC Script resource
* Enhance label test topic
Co-Authored-By: Robert Holt <[email protected]>
* repair test indentation and add newline at eof
* Move testcases to BeforeAll blocks
* Add documentation that DSC Script resource is supported
* change string[] to IReadOnlyList<string>
Co-Authored-By: Robert Holt <[email protected]>
* extract scriptBlockPosition as a variable for readability
Co-Authored-By: Robert Holt <[email protected]>
* put arguments on their own line for readability
* make visitor class a private, nested class in rule
* change 'var' to type name for method calls
* fix indentation for nested visitor class
* Remove explicit 'ToList()' for performance
Co-Authored-By: Robert Holt <[email protected]>
* add check for strongly typed assignments
* Add todo comments
* refactor FindAll predicates to static methods
to avoid closure allocation
* Refactor GetSessionName for performance.
* use full type for string expression variable
Co-Authored-By: Robert Holt <[email protected]>
* use full type name for foreach variable initialization
Co-Authored-By: Robert Holt <[email protected]>
* refactor diagnostic message out to local variable
Co-Authored-By: Robert Holt <[email protected]>
* WIP: apply review suggestions
refactoring FindVarsInAssignmentAsts to return a dictionary in progress
* apply review suggestions
refactoredFindVarsInAssignmentAsts to return a dictionary
* Fix CR/LF -> LF
Co-authored-by: Jos Koelewijn <[email protected]>
Co-authored-by: Robert Holt <[email protected]>1 parent c49fb06 commit 791ee64
File tree
7 files changed
+940
-10
lines changed- RuleDocumentation
- Rules
- Tests
- Engine
- Rules
7 files changed
+940
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1114 | 1114 | | |
1115 | 1115 | | |
1116 | 1116 | | |
1117 | | - | |
1118 | | - | |
1119 | | - | |
1120 | | - | |
1121 | | - | |
1122 | | - | |
1123 | | - | |
1124 | | - | |
1125 | | - | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
0 commit comments