PowerShell / PowerShell/PSScriptAnalyzer
Rule request: `AvoidNewObjectCmdlet`
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2.2k
- Forks
- 414
- Avg merge
- 13h 1m
- Merged PRs (30d)
- 2
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the linked PowerShell documentation on object creation and the related “Avoid New-Object Hashtable” issue. Compare the proposed rule with existing PSScriptAnalyzer rule patterns and determine how the ComObject exception should be handled. Done means the rule’s scope and exceptions are agreed and covered by implementation tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100