-
Notifications
You must be signed in to change notification settings - Fork 393
Rule request: Avoid enclosing strings with smart quotes #1936
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
Comments
Thanks @iRon7 I am going to open this up as a discussion and see if other folks have scenarios that would need this, PowerShell manages smart quotes quite well today |
Thanks for picking this up as a discussion
Agree but just like e.g. the |
For clarity, maybe add a definition of "smart quotes" to your issue description. Initially I didn't know what you meant. Looking at your test code I guess it's the curly quote styles, like these:
And I agree these shouldn't be used for defining strings. Actually, Powershell itself should fail hard on these quote types and not "handle them". |
Thanks for the comment. ...Done.
I am not sure whether it should "fail hard" but my recommendation would be to avoid them in anyway (which I think should actually apply for using any non-ASCII character in a PowerShell statement, see also: #1999) |
Background (excerpt from Wikipedea Quotation mark definition):
Summary of the new feature
Quoted strings are sometimes unintendedly replaced when passed by word processors as Microsoft Office applications as MSWord and Outlook. It is recommended to surround strings with unambiguous single quoted or double quoted string as it unnecessary triggers the UseBOMForUnicodeEncodedFile rule with no clear indication of the location.
Proposed technical implementation details (optional)
See (PowerShell based) prototype
AvoidSmartQuotedString
at: https://github.com/iRon7/PSRulesWhat is the latest version of PSScriptAnalyzer at the point of writing
1.21.0
The text was updated successfully, but these errors were encountered: