| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
👋 Looks useful, thanks! The naming of this rule is a little awkward. It's listed as InvalidVersionConstruction in the markdown doc, so I guess you renamed it at some point? Naming things is hard! Perhaps something like InvalidDottedValue or InvalidDottedLiteral as a suggestion? I don't know though 🤷 - I'm bad at naming things - I just know the current name looks off. This rule has a severity of Warning but is emitting a diagnostic of Error severity. Where this is the only diagnostic that your rule emits, these should match. Not sure which is more appropriate here - I can't think of a case where you'd want the unquoted dotted literal intentionally so maybe Error is correct? In your tests, you have 2 Context blocks with the same Supressed name. You are using the temp folder in some of your testing; I'd suggest looking into and using Pester's Test Drive for temporary file usage during tests. It helpfully takes care of relevant cleanup for you too at the right time. I don't think the CompilerServices import is intended? This has the same copy-pasta as your other PRs. |
Sorry, something went wrong.
|
I am trying to be precise but it is amazing how many issues you still find in PRs. |
Sorry, something went wrong.
Fixed, although I have kept the questionable name InvalidMultiDotValue name (as I would like to avoid that I forget to update a reference again) until somebody comes up with a accurate name that better covers the scope.
Fixed
Fixed
Removed
Changed accordingly |
Sorry, something went wrong.
Co-authored-by: Copilot <copilot@github.com>
There was a problem hiding this comment.
Adds a new built-in PSScriptAnalyzer rule to detect unquoted literals containing multiple dots (which PowerShell can parse as member-access on a double and end up evaluating to $null), along with documentation and test coverage.
Changes:
Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.
Show a summary per file| File | Description |
|---|---|
| docs/Rules/README.md | Registers the new rule in the rules index table. |
| docs/Rules/InvalidMultiDotValue.md | New rule documentation with examples. |
| Tests/Rules/InvalidMultiDotValue.tests.ps1 | New test suite for detection, suppression, and -Fix. |
| Rules/Strings.resx | Adds name/description/error/correction strings for the rule. |
| Rules/InvalidMultiDotValue.cs | Implements AST-based detection and suggested correction extents. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Thanks iRon7 — and thanks Liam Peters (@liamjpeters) for the thorough review. The rename of the markdown title, the dropped CompilerServices import, the dedup'd Context "Suppressed" block, and the severity alignment are all in. This is the closest to ready-to-merge of the four.
Two small things before I'm comfortable merging, plus one open question:
The if (invalidAsts != null) guard around the foreach in Rules/InvalidMultiDotValue.cs is dead code. Ast.FindAll never returns null — it always returns at least an empty enumerable per the .NET API. The foreach will simply not iterate when there are no matches, so the conditional can be removed and the body un-indented. Cosmetic but worth cleaning up while we're here.
Opt-in by default. Same point as the other rules: this is currently IScriptRule, which means enabled-by-default. Even though this is a clear error case (invalid construction that produces $null), our convention for new rules is opt-in via ConfigurableRule with Enable = false, so users get to evaluate impact on existing codebases before flipping it on.
Open question — Liam suggested TestDrive instead of the manual temp folder in Tests/Rules/InvalidMultiDotValue.tests.ps1, but that thread didn't conclude. Are you good with that change, or do you have a reason to prefer the explicit temp folder? Either way is fine, just want to close the loop on Liam's suggestion.
Drafted by Copilot (Claude Opus 4.7)
Sorry, something went wrong.
|
Thank you for your feedback,
I will change the rule and derive it from ConfigurableRule once I have a better understanding of the value writing a new rule if it is disabled by default (see also: #2178 (comment)). For this particular rule, I really don't see any value in leaving an unquoted "MultiDotValue" (which results in$null) unnoticed.
Thanks, I missed that (too much PowerShell ballast and just starting with C# 😃)
This is already implemented: |
Sorry, something went wrong.
The problem is that, for better or worse, a lot of people have enabled PSSA with default rules set to on in their CI systems, and so if new rules show up with warnings their builds fail and we get yelled at. Should they have done that? No. But it does mean that for as long as we're doing minor releases (which get you a new package with your rules usable) then the net effect of taking said minor release should be no new warnings/errors. When we do a major release we get to break what's become the equivalent of an API promise and go and enable by default all the great new rules. So yes, good new rules like this will eventually land as enabled by default, but it's a much bigger project for us to go through and do that and make a major release. I'd like for that to happen, we'll just have to get it on the docket.
Don't thank me, thank Claude!
Don't blame me, blame Claude! 🤠 |
Sorry, something went wrong.
Thank you for the explanation. Further thoughts: |
Sorry, something went wrong.
A shameless plug - I'm trying to improve on the settings file story a little and make rules and their options more discoverable with #2176. I don't know loads about the vscode extension side of things, but I'm interested in making adding a settings file to a project super easy. |
Sorry, something went wrong.
Fyi: I did a formal request for an additional settings file for developement: #2184 |
Sorry, something went wrong.
There was a problem hiding this comment.
Looks ok but what makes it WIP?
Sorry, something went wrong.
Co-authored-by: Sean Wheeler <sean.wheeler@microsoft.com>
Co-authored-by: Sean Wheeler <sean.wheeler@microsoft.com>
|
Christoph Bergmeister (@bergmeister),
The WIP was because of the Opt-in by default convention feedback. |
Sorry, something went wrong.
There was a problem hiding this comment.
Docs look good.
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks iRon7 — opt-in conversion is in (ConfigurableRule, Enable = false, README updated to Error / No / Yes), TestDrive is in use, and Sean Wheeler (@sdwheeler) approved the docs. CI green on all three OSes. Approving.
One small follow-up that's not a merge blocker: the if (invalidAsts != null) { ... } guard around the foreach in Rules/InvalidMultiDotValue.cs is dead code — Ast.FindAll returns an empty enumerable, never null, so the foreach simply won't iterate when there are no matches. Fine to drop in a follow-up commit (or I can push it).
Drafted by Copilot (Claude Opus 4.7)
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
PowerShell does not support an implicit value with multiple dots.
Any unquoted value with 2 or more dots will not be treated as any special type (like a version or IPAddress)
but result in $null. These objects need to be constructed from either a quoted string (e.g. [Version]'1.2.3')
or their individual components (e.g. [Version]::new(1, 2, 3)).
This rule returns an Error for unquoted values that have 2 or more dots (e.g.: $version = [Version]1.2.3).
And implements a -Fix to surround the concerned violation with single quotes.
Closes: #1698
PR Checklist