From 77b55278149f98758086022fb53732a80111c17a Mon Sep 17 00:00:00 2001 From: Benedek Farkas Date: Tue, 25 Jun 2024 15:51:32 +0200 Subject: [PATCH] Updating warning messages and expected code analysis errors --- .github/workflows/test-analysis-failure.yml | 12 ++++++------ .../Measure-VariableNameCasing.psm1 | 10 ++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-analysis-failure.yml b/.github/workflows/test-analysis-failure.yml index 5c60ce7..045e3b9 100644 --- a/.github/workflows/test-analysis-failure.yml +++ b/.github/workflows/test-analysis-failure.yml @@ -27,9 +27,9 @@ jobs: PSPlaceOpenBrace: Open brace is not on a new line. PSUseApprovedVerbs: The cmdlet 'Violate-Analyzers' uses an unapproved verb. PSUseConsistentIndentation: Indentation not consistent - PSUseCorrectAutomaticVariableNameCasing: Automatic variables should be used with the correct casing - PSUseCorrectParameterNameCasing: Parameter names should contain only alphanumeric characters and start with an uppercase letter - PSUseCorrectVariableNameCasing: Variable names should contain only alphanumeric characters and start with a lowercase letter + PSUseCorrectAutomaticVariableNameCasing: Automatic variables should be used with the casing according to the documentation + PSUseCorrectParameterNameCasing: Parameter names should start with an uppercase letter + PSUseCorrectVariableNameCasing: Variable names should start with a lowercase letter PSUseParameterNameDeclaredCasing: Parameters should be used with the declared casing PSUseSingularNouns: The cmdlet 'Violate-Analyzers' uses a plural noun. @@ -52,8 +52,8 @@ jobs: PSPlaceOpenBrace: Open brace is not on a new line. PSUseApprovedVerbs: The cmdlet 'Violate-Analyzers' uses an unapproved verb. PSUseConsistentIndentation: Indentation not consistent - PSUseCorrectAutomaticVariableNameCasing: Automatic variables should be used with the correct casing - PSUseCorrectParameterNameCasing: Parameter names should contain only alphanumeric characters and start with an uppercase letter - PSUseCorrectVariableNameCasing: Variable names should contain only alphanumeric characters and start with a lowercase letter + PSUseCorrectAutomaticVariableNameCasing: Automatic variables should be used with the casing according to the documentation + PSUseCorrectParameterNameCasing: Parameter names should start with an uppercase letter + PSUseCorrectVariableNameCasing: Variable names should start with a lowercase letter PSUseParameterNameDeclaredCasing: Parameters should be used with the declared casing PSUseSingularNouns: The cmdlet 'Violate-Analyzers' uses a plural noun. diff --git a/Lombiq.Analyzers.PowerShell/Rules/Measure-VariableNameCasing/Measure-VariableNameCasing.psm1 b/Lombiq.Analyzers.PowerShell/Rules/Measure-VariableNameCasing/Measure-VariableNameCasing.psm1 index e70958e..c512e93 100644 --- a/Lombiq.Analyzers.PowerShell/Rules/Measure-VariableNameCasing/Measure-VariableNameCasing.psm1 +++ b/Lombiq.Analyzers.PowerShell/Rules/Measure-VariableNameCasing/Measure-VariableNameCasing.psm1 @@ -7,11 +7,9 @@ - PSUseCorrectAutomaticVariableNameCasing: Automatic variables should be used with the casing according to the documentation: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables. - - PSUseCorrectParameterNameCasing: Parameter names should contain only alphanumeric characters and start with an - uppercase letter. + - PSUseCorrectParameterNameCasing: Parameter names should start with an uppercase letter. - PSUseParameterNameDeclaredCasing: Parameters should be used with the declared casing. - - PSUseCorrectVariableNameCasing: Variable names should contain only alphanumeric characters and start with a - lowercase letter. + - PSUseCorrectVariableNameCasing: Variable names should start with a lowercase letter. When fixing warnings, work through the rules in the order they are listed above, because violating PSUseCorrectParameterNameCasing, while referencing that parameter with the correct casing, will also raise a @@ -190,8 +188,8 @@ function Measure-VariableNameCasing $analyzerViolations += [Microsoft.Windows.Powershell.ScriptAnalyzer.Generic.DiagnosticRecord]@{ 'Extent' = $variable.Extent 'Message' = @( - "Automatic variables should be used with the correct casing: '$automaticVariable'" - "instead of '$variableName'." + 'Automatic variables should be used with the casing according to the documentation:' + "'$automaticVariable' instead of '$variableName'." ) -join ' ' 'RuleName' = 'PSUseCorrectAutomaticVariableNameCasing' 'RuleSuppressionID' = 'PSUseCorrectAutomaticVariableNameCasing'