-
Notifications
You must be signed in to change notification settings - Fork 394
Warn when using FileRedirection operator inside if/while statements and improve new PossibleIncorrectUsageOfAssignmentOperator rule #881
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
Merged
JamesWTruher
merged 26 commits into
PowerShell:development
from
bergmeister:WarnPipelineInsideIfStatement
Apr 9, 2018
Merged
Changes from 5 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
4a0485c
first working prototype that warns against usage of the redirection o…
bergmeister 2c0bc28
adapt error message strings and add tests
bergmeister 29c7e34
remove old todo comment
bergmeister 7310387
remove duplicated test case
bergmeister 4078e41
syntax fix from last cleanup commits
bergmeister b7ad069
tweak extents in error message: for equal sign warnings, it will poin…
bergmeister 8a48a62
Enhance check for assignment by rather checking if assigned variable …
bergmeister c9d510f
Merge branch 'development' of https://github.com/PowerShell/PSScriptA…
bergmeister fd339f6
tweak messages and readme
bergmeister 5e8a8be
Merge branch 'WarnPipelineInsideIfStatement' of https://github.com/be…
bergmeister c74a746
Merge branch 'development' of https://github.com/PowerShell/PSScriptA…
bergmeister b467d10
update to pester v4 syntax
bergmeister 594414f
Revert to not check assigned variable usage of RHS but add optional c…
bergmeister c4e242e
Minor fix resource variable naming
bergmeister f7ce114
uncommented accidental comment out of ipmo pssa in tests
bergmeister bc00213
do not exclude BinaryExpressionAst on RHS because this case is the ch…
bergmeister c6c4f4a
update test to test against clang suppression
bergmeister 691f2ce
make clang suppression work again
bergmeister fe30f4d
reword warning text to use 'equality operator' instead of 'equals ope…
bergmeister 78ef4bf
Always warn when LHS is $null
bergmeister 675e3eb
Enhance PossibleIncorrectUsageOfAssignmentOperator rule to do the sam…
bergmeister ad008cd
tweak message to be more generic in terms of the conditional statement
bergmeister d042f37
Merge branch 'development' of https://github.com/PowerShell/PSScriptA…
bergmeister f530d75
Address PR comments
bergmeister ed95d84
Merge branch 'development' of https://github.com/PowerShell/PSScriptA…
bergmeister bdf39ac
Merge branch 'development' of https://github.com/PowerShell/PSScriptA…
bergmeister File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 0 additions & 7 deletions
7
RuleDocumentation/PossibleIncorrectUsageOfAssignmentOperator.md
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
RuleDocumentation/PossibleIncorrectUsageOfComparisonOperator.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# PossibleIncorrectUsageOfComparisonOperator | ||
|
||
**Severity Level: Information** | ||
|
||
## Description | ||
|
||
In many programming languages, the comparison operator for greater is `>` but `PowerShell` uses `-gt` for it and `-ge` for `>=`. Similarly the equality operator is denoted as `==` or `=` in many programming languages, but `PowerShell` uses `-eq`. Since using as the FileRedirection operator `>` or the assignment operator are rarely needed inside if statements, this rule wants to call out this case because it was probably unintentional. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering because we can determine pretty accurately know that the usage of the comparison operator inside if statements is unintentional, if we should up the level to warning because some people ignore/disable warnings of informational level?