-
Notifications
You must be signed in to change notification settings - Fork 394
WIP Warn when using += on array objects #933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…s because SSA is not fully implemented (i.e. $a=@();$a+=$foo does not get caught or determining that the type is of type string.
…nalyzer into WarnPlusEquals resolved by taking both # Conflicts: # Rules/Strings.resx
…nalyzer into WarnPlusEquals Resolved by taking both. # Conflicts: # Rules/Strings.resx
…nalyzer into WarnPlusEquals # Conflicts: # Rules/Strings.resx
…nalyzer into WarnPlusEquals # Conflicts: # Rules/Strings.resx
Is there any chance of progressing this so it's included? |
I don't think so because of the issues encountered that are fundamental due to limitation of variable analysis framework in PSSA, which was a fork of PowerShell code in the first place anyway. It only works for simple cases where the += isn't in a function, etc. |
Closing as there is no path to get this working as-is and therefore no point in keeping open |
PR Summary
Fixes #806 and #904
It is well know that PowerShell's
+=
operator always creates a new array under the hood even if the array type is not of fixed size.Because SSA (single statement analysis) is not fully implemented at the moment, the detection for the object type can not catch all cases. For example it does not work inside function definitions or cannot determine if the object is of type string at the moment or cases like
$a=@(); $a+=$foo
.The rule documentation includes all possible info even if strings cannot be caught at the moment.
PR Checklist
Note: Tick the boxes below that apply to this pull request by putting an
x
between the square brackets. Please mark anything not applicable to this PRNA
.WIP:
to the beginning of the title and remove the prefix when the PR is ready