From 2cc698f55a79a8f4e392e816c9153c92fe6561dc Mon Sep 17 00:00:00 2001 From: Matteo Baccan Date: Wed, 21 Apr 2021 02:20:27 +0200 Subject: [PATCH 1/3] Public static field should be constant --- core/src/main/java/pl/project13/core/log/FormattingTuple.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/pl/project13/core/log/FormattingTuple.java b/core/src/main/java/pl/project13/core/log/FormattingTuple.java index b5bae414..2d34d0dd 100644 --- a/core/src/main/java/pl/project13/core/log/FormattingTuple.java +++ b/core/src/main/java/pl/project13/core/log/FormattingTuple.java @@ -49,7 +49,7 @@ */ public class FormattingTuple { - public static FormattingTuple NULL = new FormattingTuple(null); + public static final FormattingTuple NULL = new FormattingTuple(null); private String message; private Throwable throwable; From c665ec9fa929845e4bc1cae4773923ccd4bfb791 Mon Sep 17 00:00:00 2001 From: Matteo Baccan Date: Wed, 21 Apr 2021 02:24:45 +0200 Subject: [PATCH 2/3] Local variables should not be declared and then immediately returned Signed-off-by:Matteo Baccan --- core/src/main/java/pl/project13/core/jgit/JGitCommon.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/core/src/main/java/pl/project13/core/jgit/JGitCommon.java b/core/src/main/java/pl/project13/core/jgit/JGitCommon.java index ff300c24..1b803990 100644 --- a/core/src/main/java/pl/project13/core/jgit/JGitCommon.java +++ b/core/src/main/java/pl/project13/core/jgit/JGitCommon.java @@ -341,13 +341,11 @@ public static boolean isRepositoryInDirtyState(Repository repo) throws GitAPIExc // repo is dirty. JGit does this, so we cannot use the isClean method // to get the same behaviour. Instead check dirty state without // status.getUntracked().isEmpty() - boolean isDirty = !(status.getAdded().isEmpty() + return !(status.getAdded().isEmpty() && status.getChanged().isEmpty() && status.getRemoved().isEmpty() && status.getMissing().isEmpty() && status.getModified().isEmpty() && status.getConflicting().isEmpty()); - - return isDirty; } } From 587254040530ec0dd55cffb8b0f3b0e38ec1d505 Mon Sep 17 00:00:00 2001 From: Matteo Baccan Date: Wed, 21 Apr 2021 02:28:03 +0200 Subject: [PATCH 3/3] Return of boolean expression should not be wrapped into an if-the-else statement Signed-off-by:Matteo Baccan --- .../java/pl/project13/core/log/MessageFormatter.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/pl/project13/core/log/MessageFormatter.java b/core/src/main/java/pl/project13/core/log/MessageFormatter.java index 81f21bfc..4d593766 100644 --- a/core/src/main/java/pl/project13/core/log/MessageFormatter.java +++ b/core/src/main/java/pl/project13/core/log/MessageFormatter.java @@ -261,19 +261,11 @@ static boolean isEscapedDelimeter(String messagePattern, int delimeterStartIndex return false; } char potentialEscape = messagePattern.charAt(delimeterStartIndex - 1); - if (potentialEscape == ESCAPE_CHAR) { - return true; - } else { - return false; - } + return (potentialEscape == ESCAPE_CHAR); } static boolean isDoubleEscaped(String messagePattern, int delimeterStartIndex) { - if (delimeterStartIndex >= 2 && messagePattern.charAt(delimeterStartIndex - 2) == ESCAPE_CHAR) { - return true; - } else { - return false; - } + return (delimeterStartIndex >= 2 && messagePattern.charAt(delimeterStartIndex - 2) == ESCAPE_CHAR); } // special treatment of array values was suggested by 'lizongbo'