GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add UseConsistentParameterSetName Rule by liamjpeters · Pull Request #2124 · PowerShell/PSScriptAnalyzer

Conversation

@liamjpeters

@liamjpeters Liam Peters (liamjpeters) commented Aug 19, 2025

Copy link
Copy Markdown
Contributor

PR Summary

Add UseConsistentParameterSetName rule to detect potential parameter set issues

Parameter set names are case-sensitive in PowerShell (unlike most other elements), which can lead to runtime errors and unexpected behavior when not handled correctly.

The rule performs five key validations:

  1. Missing DefaultParameterSetName - Warns when parameter sets are defined but no default is specified
  2. Duplicate parameter declarations - Detects parameters declared multiple times in the same parameter set
  3. DefaultParameterSetName case mismatch - Warns when the DefaultParameterSetName matches the text but not case of a defined parameter set.
  4. ParameterSetName case inconsistency - Validates consistent casing across all references to the same parameter set
  5. Invalid characters - Prevents newline characters in parameter set names.

Fixes #396 with the exception of ParameterSets that don't have at least one unique parameter.

This won't help with Dynamic Parameters.

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Change is not breaking
  • Make sure all .cs, .ps1 and .psm1 files have the correct copyright header
  • Make sure you've added a new test if existing tests do not effectively test the code changed and/or updated documentation
  • This PR is ready to merge and is not Work in Progress.
    • If the PR is work in progress, please add the prefix WIP: to the beginning of the title and remove the prefix when the PR is ready.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@liamjpeters
Add UseConsistentParameterSetName Rule
10fb8b5
@liamjpeters
Liam Peters (liamjpeters) requested review from Andy Jordan (andyleejordan), Christoph Bergmeister (bergmeister), Mikey Lombardi (He/Him) (michaeltlombardi) and Sean Wheeler (sdwheeler) as code owners August 19, 2025 21:34
andyleejordan
Andy Jordan (andyleejordan) reviewed Oct 13, 2025
View reviewed changes
Comment thread docs/Rules/UseConsistentParameterSetName.md
Comment on lines +18 to +22
1. **Missing DefaultParameterSetName** - Warns when parameter sets are used but no default is specified
2. **Multiple parameter declarations** - Detects when a parameter is declared multiple times in the same parameter set. This is ultimately a runtime exception - this check helps catch it sooner.
3. **Case mismatch between DefaultParameterSetName and ParameterSetName** - Ensures consistent casing
4. **Case mismatch between different ParameterSetName values** - Ensures all references to the same parameter set use identical casing
5. **Parameter set names containing newlines** - Warns against using newline characters in parameter set names

@andyleejordan Andy Jordan (andyleejordan) Oct 13, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to verify our understanding of parameter sets to review this better, we'll get back to it Liam!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

liamjpeters reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@bergmeister

Christoph Bergmeister (bergmeister) commented Jan 30, 2026

Copy link
Copy Markdown
Collaborator

Liam Peters (@liamjpeters) can you resolve merge conflict please so we can run CI?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@liamjpeters
Merge branch 'main' into #396ParameterSetNameMismatch
fc553fa
@liamjpeters
Liam Peters (liamjpeters) requested a review from a team as a code owner January 30, 2026 17:45
@liamjpeters

Liam Peters (liamjpeters) commented Jan 30, 2026

Copy link
Copy Markdown
Contributor Author

Liam Peters (@liamjpeters) can you resolve merge conflict please so we can run CI?

Done. If you approve the CI runs, I'll fix any issues that may have cropped up

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bergmeister

Christoph Bergmeister (bergmeister) commented Jan 30, 2026

Copy link
Copy Markdown
Collaborator

Liam Peters (@liamjpeters) can you resolve merge conflict please so we can run CI?

Done. If you approve the CI runs, I'll fix any issues that may have cropped up

Thanks for quick turnaround, approved just now. You should be able to run the tests in your fork as well btw (at least that was the case when we were in Azure DevOps before we moved CI to GitHub). If not, let me know, we can look into enabling that generally or just for you as a regular contributor

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bergmeister
Update GetScriptAnalyzerRule.tests.ps1 to fix test about number of rules
889363e
bergmeister
Christoph Bergmeister (bergmeister) reviewed Jan 30, 2026
View reviewed changes
Comment thread docs/Rules/README.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

@liamjpeters

Liam Peters (liamjpeters) commented Jan 30, 2026

Copy link
Copy Markdown
Contributor Author

Liam Peters (@liamjpeters) can you resolve merge conflict please so we can run CI?

Done. If you approve the CI runs, I'll fix any issues that may have cropped up

Thanks for quick turnaround, approved just now. You should be able to run the tests in your fork as well btw (at least that was the case when we were in Azure DevOps before we moved CI to GitHub). If not, let me know, we can look into enabling that generally or just for you as a regular contributor

The triggers for the CI are a push or PR to main. My fork is old enough that it still has master as the default branch and I'm honestly not too sure how to change it 😅. Even still, I probably wouldn't do little PRs for testing on my fork. I can, and do, run the tests locally (on windows at least). It'd need workflow_dispatch as a trigger to enable the "Run Workflow" option in the GUI.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Liam Peters (liamjpeters) added 4 commits February 1, 2026 14:35
@liamjpeters
Make rule optional, disabled by default
6470d2e
@liamjpeters
Update tests to reflect need to enable rule
7a82c61
@liamjpeters
Update docs to refelct that the rule is not enabeld by default
3f571b8
@liamjpeters
Fix alignment of README markdown table
27e83ca
@bergmeister

Christoph Bergmeister (bergmeister) commented Feb 2, 2026

Copy link
Copy Markdown
Collaborator

Liam Peters (@liamjpeters) can you resolve merge conflict please so we can run CI?

Done. If you approve the CI runs, I'll fix any issues that may have cropped up

Thanks for quick turnaround, approved just now. You should be able to run the tests in your fork as well btw (at least that was the case when we were in Azure DevOps before we moved CI to GitHub). If not, let me know, we can look into enabling that generally or just for you as a regular contributor

The triggers for the CI are a push or PR to main. My fork is old enough that it still has master as the default branch and I'm honestly not too sure how to change it 😅. Even still, I probably wouldn't do little PRs for testing on my fork. I can, and do, run the tests locally (on windows at least). It'd need workflow_dispatch as a trigger to enable the "Run Workflow" option in the GUI.

I just updated default branch in my fork to main, you go to settings and rename it here and it then even gives you instructions how to update your local clone, if you didn't want to re-clone. But it's not required for your fork in order to run tests or sync, I've done it with master until now.
image
image

In the meantime you should be able to run tests for future work by opening PR in your fork against your fork's default branch but I opened a PR to add workflow_dispatch: #2153

liamjpeters reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bergmeister
Christoph Bergmeister (bergmeister) approved these changes Feb 3, 2026
View reviewed changes
Comment thread Rules/UseConsistentParameterSetName.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Rules/UseConsistentParameterSetName.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bergmeister Christoph Bergmeister (bergmeister) mentioned this pull request Feb 3, 2026
Add PSAvoidUsingNewObject Rule #2109
Closed
6 tasks done
@liamjpeters @bergmeister
Update Rules/UseConsistentParameterSetName.cs
c97d312
Co-authored-by: Christoph Bergmeister <[email protected]>
bergmeister
Christoph Bergmeister (bergmeister) approved these changes Feb 6, 2026
View reviewed changes
Liam Peters (liamjpeters) and others added 3 commits February 19, 2026 08:56
@liamjpeters
Merge branch 'main' into #396ParameterSetNameMismatch
56ecfff
@bergmeister
Merge branch 'main' into #396ParameterSetNameMismatch
cae2d3f
@andyleejordan
Merge branch 'main' into #396ParameterSetNameMismatch
d44b294
andyleejordan
Andy Jordan (andyleejordan) approved these changes Mar 17, 2026
View reviewed changes

@andyleejordan Andy Jordan (andyleejordan) left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Liam!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@andyleejordan
Andy Jordan (andyleejordan) enabled auto-merge (squash) March 17, 2026 22:56
@andyleejordan

Andy Jordan (andyleejordan) commented Mar 17, 2026

Copy link
Copy Markdown
Member

Liam Peters (@liamjpeters) are you able to fix the CI error? I'm not sure what changed, the merge I did was just for the readme.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@andyleejordan
Update expected rule count to 73 for new UseConsistentParameterSetNam…
374afec
…e rule
@andyleejordan
Andy Jordan (andyleejordan) disabled auto-merge March 18, 2026 16:56
@andyleejordan
Merge branch 'main' into #396ParameterSetNameMismatch
2a8ddcf
@andyleejordan
Andy Jordan (andyleejordan) enabled auto-merge (squash) March 18, 2026 17:19
bergmeister
Christoph Bergmeister (bergmeister) approved these changes Mar 18, 2026
View reviewed changes
@andyleejordan
Andy Jordan (andyleejordan) merged commit ed50b9d into PowerShell:main Mar 18, 2026
4 checks passed

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@bergmeister Christoph Bergmeister (bergmeister) bergmeister approved these changes
@sdwheeler Sean Wheeler (sdwheeler) Awaiting requested review from sdwheeler
@michaeltlombardi Mikey Lombardi (He/Him) (michaeltlombardi) Awaiting requested review from michaeltlombardi michaeltlombardi is a code owner
+1 more reviewer
@andyleejordan Andy Jordan (andyleejordan) andyleejordan approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

New Rule Suggestion: ParameterSetName mismatch.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@liamjpeters @bergmeister @andyleejordan
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.