-
Notifications
You must be signed in to change notification settings - Fork 393
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
Rule request: AvoidNewObjectCmdlet
#2046
Comments
You might also consider to link this type of rules to the |
Agree with it, feel free to contribute a rule for it :-) |
Might that be a PowerShell based rule? (FYI: I don't have enough C# known to write something like that in C#) |
To be included with PSScriptAnalyzer, it would be C# because PowerShell based ones are too slow and CPU intensive to run by default for the millions of PSSA users. Alternatively you could write your custom PowerShell rule and open source it for the community to use. |
The
New-Object
cmdlet is basically* legacy.Since PowerShell V3.0 (12 years ago), PowerShell supports type accelerators which perform much better, see: PowerShell scripting performance considerations / object creation.
*) Exceptions left there (e.g. with the use of the
[-ComObject] <String>
parameter)Therefore I think that it makes sense to have a
AvoidNewObjectCmdlet
rule.related: Avoid New-Object Hashtable
#60
The text was updated successfully, but these errors were encountered: