Skip to content

Add UseConsistentParameterSetName Rule #2124

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

liamjpeters
Copy link
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New Rule Suggestion: ParameterSetName mismatch.
1 participant