-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Enable IDE0048: AddRequiredParentheses #13936
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -805,7 +805,7 @@ private byte[] GetSendBuffer(int bufferSize) | |
|
|
||
| for (int i = 0; i < bufferSize; i++) | ||
| { | ||
| sendBuffer[i] = (byte)((int)'a' + i % 23); | ||
| sendBuffer[i] = (byte)((int)'a' + (i % 23)); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Less readability.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Multiplicative > Additive |
||
| } | ||
|
|
||
| if (bufferSize == DefaultSendBufferSize && s_DefaultSendBuffer == null) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1289,7 +1289,7 @@ private string BuildErrorMessage(Diagnostic diagnisticRecord) | |
| var errorLineString = textLines[errorLineNumber].ToString(); | ||
| var errorPosition = lineSpan.StartLinePosition.Character; | ||
|
|
||
| StringBuilder sb = new StringBuilder(diagnisticMessage.Length + errorLineString.Length * 2 + 4); | ||
| StringBuilder sb = new StringBuilder(diagnisticMessage.Length + (errorLineString.Length * 2) + 4); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Less readability.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Multiplicative > Additive |
||
|
|
||
| sb.AppendLine(diagnisticMessage); | ||
| sb.AppendLine(errorLineString); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -324,7 +324,7 @@ private double GetRandomDouble(double minValue, double maxValue) | |
| do | ||
| { | ||
| double r = Generator.NextDouble(); | ||
| randomNumber = minValue + r * maxValue - r * minValue; | ||
| randomNumber = minValue + (r * maxValue) - (r * minValue); | ||
| } | ||
| while (randomNumber >= maxValue); | ||
| } | ||
|
|
@@ -333,7 +333,7 @@ private double GetRandomDouble(double minValue, double maxValue) | |
| do | ||
| { | ||
| double r = Generator.NextDouble(); | ||
| randomNumber = minValue + r * diff; | ||
| randomNumber = minValue + (r * diff); | ||
| diff = diff * r; | ||
| } | ||
| while (randomNumber >= maxValue); | ||
|
|
@@ -385,7 +385,7 @@ private Int64 GetRandomInt64(Int64 minValue, Int64 maxValue) | |
| randomUint64 &= mask; | ||
| } while (uint64Diff <= randomUint64); | ||
|
|
||
| double randomNumber = minValue * 1.0 + randomUint64 * 1.0; | ||
| double randomNumber = (minValue * 1.0) + (randomUint64 * 1.0); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Less readability.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Multiplicative > Additive |
||
| return (Int64)randomNumber; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2006,8 +2006,8 @@ internal string ReadLineWithTabCompletion(Executor exec) | |
| // the user hit tab up to the current cursor position after writing the completed text. | ||
|
|
||
| int deltaInput = | ||
| (endOfInputCursorPos.Y * screenBufferSize.Width + endOfInputCursorPos.X) | ||
| - (endOfCompletionCursorPos.Y * screenBufferSize.Width + endOfCompletionCursorPos.X); | ||
| ((endOfInputCursorPos.Y * screenBufferSize.Width) + endOfInputCursorPos.X) | ||
| - ((endOfCompletionCursorPos.Y * screenBufferSize.Width) + endOfCompletionCursorPos.X); | ||
|
Comment on lines
2009
to
2010
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Less readability.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Multiplicative > Additive |
||
|
|
||
| if (deltaInput > 0) | ||
| { | ||
|
|
@@ -2066,7 +2066,7 @@ private void SendLeftArrows(int length) | |
| up.Data.Keyboard.ExtraInfo = IntPtr.Zero; | ||
|
|
||
| inputs[2 * i] = down; | ||
| inputs[2 * i + 1] = up; | ||
| inputs[(2 * i) + 1] = up; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd wonder if anybody wanted parentheses in such expressions.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Multiplicative > Additive |
||
| } | ||
|
|
||
| ConsoleControl.MimicKeyPress(inputs); | ||
|
|
||
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.
Less readability.
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.
For most people it is obvious that multiplication has a higher precedence than addition, so the parenthesis are probably not necessary. However while readability might not be any better, it is not really any worse.
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.
Multiplicative > Additive