PowerShell / PowerShell/PSScriptAnalyzer

New Rule Suggestion / Rule amendment - in response to #903

Open
#904 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue - Discussion Issue - New Rule
Dominant language
C#
Stars
2.2k
Forks
414
Avg merge
13h 1m
Merged PRs (30d)
2

Description

In Issue #903 the rule in my opinion correctly throws on a += for simple defined arrays using the $var = @() method of defining an array to the var variable

I would suggest that a new rule is created that correctly identifies this method as being an expensive action and that a recommendation to use a fully defined Array collection would be a better suggestion, initially suggesting using a System.Collections.ArrayList

This rule should look for both @() & += and suggest converting these calls better scripting practices

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading issue #903 and the existing rule that handles += for arrays. Determine how the analyzer should recognize both @() and +=, then define the recommendation and tests needed to confirm that fully defined collections, initially System.Collections.ArrayList, are suggested.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
devtools, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.