-
Notifications
You must be signed in to change notification settings - Fork 369
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
Quotes aren't smartly replaced when used in #Requires
statements.
#2008
Comments
I like the idea of this - but it could be a difficult one to implement. The way the majority of the rules work within PSSA is that they analyze the Abstract Syntax Tree and not the source files directly. The rule that does the quote replacement, AvoidUsingDoubleQuotesForConstantString, looks for The AST is useful as it tells you where each part of the code starts and stops as well as other useful information from the PowerShell parser. For instance in the strings example, where each string starts and stops, and the type of string it is - making it trivial to decide if a change is required and then change the type of quotes that string uses. The This provides no hint as to where the I believe to implement this, you'd have to do a lot of work to recognise the |
That indeed sounds like a lot of work. To be honest, the whole Based on your answer, it seems the best way would be for the Abstract Syntax Tree to have better support for |
I noticed quotes aren't smartly replaced when used in
#Requires
statements.Steps to reproduce
Look at the following lines. Note that the double quote chars probably don't need to be used on that first line, but I don't think it's an error to use them. And when they are used, they should be processed properly by PSScriptAnalyzer.
Expected behavior
I had expected the double quote chars to be replaced by single quote chars, like this:
Actual behavior
The quotes remain unchanged.
It seems PSScriptAnalyzer treats
#Requires
lines as mere comments and doesn't process them.Environment data
The text was updated successfully, but these errors were encountered: