From 2be7f4a183b5fca0ae34e1a5a8221d3fc9046300 Mon Sep 17 00:00:00 2001 From: Aaron Echavarria Date: Sun, 15 Sep 2024 23:24:56 -0600 Subject: [PATCH] resolver codenarc issues --- .../jte/util/FileSystemWrapperFactory.groovy | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/groovy/org/boozallen/plugins/jte/util/FileSystemWrapperFactory.groovy b/src/main/groovy/org/boozallen/plugins/jte/util/FileSystemWrapperFactory.groovy index 1261d758..e4f340ed 100644 --- a/src/main/groovy/org/boozallen/plugins/jte/util/FileSystemWrapperFactory.groovy +++ b/src/main/groovy/org/boozallen/plugins/jte/util/FileSystemWrapperFactory.groovy @@ -111,15 +111,16 @@ class FileSystemWrapperFactory { private static FileSystemWrapper fromSCM(FlowExecutionOwner owner, WorkflowJob job, SCM scm) { FileSystemCacheKey cacheKey = new FileSystemCacheKey(owner: owner, scm: scm) + FileSystemWrapper fsw if (CACHE.containsKey(cacheKey)) { - return CACHE.get(cacheKey) + fsw = CACHE.get(cacheKey) } else { SCMFileSystem fs fs = SCMFileSystem.of(job, scm) - FileSystemWrapper fsw = new FileSystemWrapper(fs: fs, scmKey: scm.getKey(), owner: owner) + fsw = new FileSystemWrapper(fs: fs, scmKey: scm.getKey(), owner: owner) CACHE.put(cacheKey, fsw) - return fsw } + return fsw } private static FileSystemWrapper fromMultiBranchProject(FlowExecutionOwner owner, WorkflowJob job, TaskListener listener){ @@ -139,6 +140,7 @@ class FileSystemWrapperFactory { SCMHead head = branch.getHead() SCMRevision tip = scmSource.fetch(head, listener) + FileSystemWrapper fsw SCMFileSystem fs String scmKey if (tip) { @@ -146,23 +148,24 @@ class FileSystemWrapperFactory { SCMRevision rev = scmSource.getTrustedRevision(tip, listener) FileSystemCacheKey cacheKey = new FileSystemCacheKey(owner: owner, scmSource: scmSource, scmHead: head, scmRevision: rev) if (CACHE.containsKey(cacheKey)) { - fs = CACHE.get(cacheKey) + fsw = CACHE.get(cacheKey) } else { fs = SCMFileSystem.of(scmSource, head, rev) - CACHE.put(cacheKey, fs) + fsw = new FileSystemWrapper(fs: fs, scmKey: scmKey, owner: owner) + CACHE.put(cacheKey, fsw) } } else { SCM jobSCM = branch.getScm() scmKey = jobSCM.getKey() FileSystemCacheKey cacheKey = new FileSystemCacheKey(owner: owner, scm: jobSCM) if (CACHE.containsKey(cacheKey)) { - fs = CACHE.get(cacheKey) + fsw = CACHE.get(cacheKey) } else { fs = SCMFileSystem.of(job, jobSCM) - CACHE.put(cacheKey, fs) + fsw = new FileSystemWrapper(fs: fs, scmKey: scmKey, owner: owner) + CACHE.put(cacheKey, fsw) } } - FileSystemWrapper fsw = new FileSystemWrapper(fs: fs, scmKey: scmKey, owner: owner) return fsw } @@ -171,13 +174,14 @@ class FileSystemWrapperFactory { SCM jobSCM = definition.getScm() String scmKey = jobSCM.getKey() FileSystemCacheKey cacheKey = new FileSystemCacheKey(owner: owner, scm: jobSCM) + FileSystemWrapper fsw if (CACHE.containsKey(cacheKey)) { - return CACHE.get(cacheKey) + fsw = CACHE.get(cacheKey) } else { SCMFileSystem fs = SCMFileSystem.of(job, jobSCM) - FileSystemWrapper fsw = new FileSystemWrapper(fs: fs, scmKey: scmKey, owner: owner) - CACHE.put(cacheKey, fs) - return fsw + fsw = new FileSystemWrapper(fs: fs, scmKey: scmKey, owner: owner) + CACHE.put(cacheKey, fsw) } + return fsw } }