PowerShell / PowerShell/PSScriptAnalyzer

PSUseCorrectCasing malfunctioning in DSC configuration

Open
#1,474 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area - Formatter
Dominant language
C#
Stars
2.2k
Forks
414
Avg merge
13h 1m
Merged PRs (30d)
2

Description

PSUseCorrectCasing is erroneously changing Type to type in a DSC configuration.

Steps to reproduce

$settings = @{
    IncludeRules = @("PSUseCorrectCasing")
    Rules = @{
        PSUseCorrectCasing = @{
            Enable = $true
        }
    }
}

Invoke-Formatter -Settings $settings -ScriptDefinition @'
Configuration ApacheServer{
    Node localhost{
         nxFile vHostDirectory{
             DestinationPath = $VhostDir
             Type = "Directory"
             Ensure = "Present"
             Owner = "root"
             Mode = "744"
         }
     }
 }
'@

Expected behavior

Configuration ApacheServer{
    Node localhost{
         nxFile vHostDirectory{
             DestinationPath = $VhostDir
             Type = "Directory"
             Ensure = "Present"
             Owner = "root"
             Mode = "744"
         }
     }
 }

Actual behavior

Configuration ApacheServer{
    Node localhost{
         nxFile vHostDirectory{
             DestinationPath = $VhostDir
             type = "Directory"
             Ensure = "Present"
             Owner = "root"
             Mode = "744"
         }
     }
 }

Environment data

> $PSVersionTable
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.19.0
1.18.3

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 reproducing the issue with Invoke-Formatter, the PSUseCorrectCasing rule, and the DSC configuration shown in the report. Trace how the rule handles the DSC nxFile property and verify that formatting preserves Type rather than changing it to type.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.