[go: nahoru, domu]

Skip to content

Commit

Permalink
Check more operators
Browse files Browse the repository at this point in the history
  • Loading branch information
daviesj committed Oct 27, 2020
1 parent d3da1e4 commit 3943377
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Rules/UseConsistentWhitespace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -547,12 +547,29 @@ private IEnumerable<DiagnosticRecord> FindOperatorViolations(TokenOperations tok
else if (tokenHasBinaryFlag // binary flag is set but not unary
// include other (non-expression) binary operators
|| TokenTraits.HasTrait(tokenNode.Value.Kind, TokenFlags.AssignmentOperator)
|| tokenNode.Value.Kind == TokenKind.Redirection
|| tokenNode.Value.Kind == TokenKind.AndAnd
|| tokenNode.Value.Kind == TokenKind.OrOr
#if !(NET452 || PSV6) // include both parts of ternary operator but only for PS7+
|| TokenTraits.HasTrait(tokenNode.Value.Kind, TokenFlags.TernaryOperator)
|| tokenNode.Value.Kind == TokenKind.Colon
#endif
) {
checkLeftSide = true;
checkRightSide = true;
}
// Treat call and dot source operators as unary with operand on right.
else if ((tokenNode.Value.Kind == TokenKind.Dot || tokenNode.Value.Kind == TokenKind.Ampersand)
&& tokenOperations.GetAstPosition(tokenNode.Value) is CommandAst)
{
checkRightSide = true;
}
#if !(NET452) // Treat background operator as unary with operand on left (only exists in PS6+)
else if (tokenNode.Value.Kind == TokenKind.Ampersand)
{
checkLeftSide = true;
}
#endif
else // Token is not an operator
{
continue;
Expand Down

0 comments on commit 3943377

Please sign in to comment.