From 0a8235441453f1141dbe3f02ef13786698cf3c19 Mon Sep 17 00:00:00 2001 From: Aaron Echavarria Date: Sun, 15 Sep 2024 23:32:21 -0600 Subject: [PATCH] resolver codenarc issues --- .../jte/util/FileSystemCacheKey.groovy | 34 +++++++------------ 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/main/groovy/org/boozallen/plugins/jte/util/FileSystemCacheKey.groovy b/src/main/groovy/org/boozallen/plugins/jte/util/FileSystemCacheKey.groovy index 95e982d0..57447d22 100644 --- a/src/main/groovy/org/boozallen/plugins/jte/util/FileSystemCacheKey.groovy +++ b/src/main/groovy/org/boozallen/plugins/jte/util/FileSystemCacheKey.groovy @@ -61,6 +61,8 @@ import org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner */ class FileSystemCacheKey { + private static final int MULTIPLIER = 31 + FlowExecutionOwner owner SCM scm SCMSource scmSource @@ -88,26 +90,13 @@ class FileSystemCacheKey { FileSystemCacheKey that = (FileSystemCacheKey) o - if (owner != that.owner) { - return false - } - if (scm != that.scm) { - return false - } - if (scmHead != that.scmHead) { - return false - } - if (scmRevision != that.scmRevision) { - return false - } - if (scmSource != that.scmSource) { - return false - } - - return true + return owner == that.owner && + scm == that.scm && + scmHead == that.scmHead && + scmRevision == that.scmRevision && + scmSource == that.scmSource; } - /** * Generates a hash code for this FileSystemCacheKey instance. * The hash code is computed based on the {@code owner}, {@code scm}, {@code scmSource}, @@ -122,10 +111,11 @@ class FileSystemCacheKey { int hashCode() { int result result = (owner != null ? owner.hashCode() : 0) - result = 31 * result + (scm != null ? scm.hashCode() : 0) - result = 31 * result + (scmSource != null ? scmSource.hashCode() : 0) - result = 31 * result + (scmHead != null ? scmHead.hashCode() : 0) - result = 31 * result + (scmRevision != null ? scmRevision.hashCode() : 0) + result = MULTIPLIER * result + (scm != null ? scm.hashCode() : 0) + result = MULTIPLIER * result + (scmSource != null ? scmSource.hashCode() : 0) + result = MULTIPLIER * result + (scmHead != null ? scmHead.hashCode() : 0) + result = MULTIPLIER * result + (scmRevision != null ? scmRevision.hashCode() : 0) return result } + }