]> source.dussan.org Git - jgit.git/commitdiff
[errorprone] RawText: Add parenthesis for explicit op precedence 48/1204048/1
authorIvan Frade <ifrade@google.com>
Thu, 14 Nov 2024 00:11:17 +0000 (16:11 -0800)
committerIvan Frade <ifrade@google.com>
Thu, 14 Nov 2024 00:11:17 +0000 (16:11 -0800)
errorprone reports:

[OperatorPrecedence] Use grouping parenthesis to make the
operator precedence explicit

Take the chance to fix also
https://errorprone.info/bugpattern/YodaCondition in the same lines.

Change-Id: I6d8f00842ef2bb24cd00fc413121b8a4e20c186b

org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java

index 5a4d2aa45a7510c04ec35d28a36197c12f1ca7c0..fdfe533618415c7d6d3ba1fae72687f7ede99dd4 100644 (file)
@@ -365,7 +365,7 @@ public class RawText extends Sequence {
                byte current;
                while (ptr < length - 2) {
                        current = raw[++ptr];
-                       if ('\0' == current || '\r' == current && raw[++ptr] != '\n') {
+                       if (current == '\0' || (current == '\r' && raw[++ptr] != '\n')) {
                                return true;
                        }
                }
@@ -373,7 +373,7 @@ public class RawText extends Sequence {
                if (ptr == length - 2) {
                        // if '\r' be last, then if isComplete then return binary
                        current = raw[++ptr];
-                       return '\0' == current || '\r' == current && isComplete;
+                       return current == '\0' || (current == '\r' && isComplete);
                }
 
                return false;
@@ -490,7 +490,7 @@ public class RawText extends Sequence {
                if (ptr == length - 2) {
                        // if '\r' be last, then if isComplete then return binary
                        current = raw[++ptr];
-                       if('\0' == current || '\r' == current && complete){
+                       if (current == '\0' || (current == '\r' && complete)) {
                                return false;
                        }
                }