PowerShell / PowerShell/PSScriptAnalyzer
Check for platform-dependent path usage
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2.2k
- Forks
- 414
- Avg merge
- 13h 1m
- Merged PRs (30d)
- 2
Description
As suggested by @SteveL-MSFT.
A rule that checks/corrects filesystem path usage that doesn't translate across between Windows and UNIX-like OSes could ease migration to PowerShell Core.
User story
As a PowerShell user, I want a rule to tell me when a path I've used
will break my script on another platform, so that I can write
cross-platform scripts more easily (e.g. for Azure scenarios).
Proposed technical implementation
Check all *-*Item and *-Path cmdlets (and their aliases) for direct string/bareword arguments to check for platform specific usages (like C:), or even encourage usage of Join-Path or [System.IO.Path]::Combine() instead of / and \.
Of course this check isn't universally feasible, but this is another case where some constant folding would come in handy for PowerShell analysis (something PSES could also use).
Latest current version of PSSA
1.17.1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue does not name files, tests, or an existing rule entry point. Start by reviewing how PSScriptAnalyzer implements rules and how it identifies *-Item and *-Path cmdlets and aliases. Define the supported platform-specific patterns and constant-folding scope before implementing; done means the rule detects and, if supported, corrects agreed cases with tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, powershell
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100