From e3f310ec3c8fd98305f2bfdf2067ff80979fbe2d Mon Sep 17 00:00:00 2001 From: Frantisek Nagy Date: Wed, 28 Aug 2019 11:03:40 +0200 Subject: [PATCH] Fix codenarc warnings --- .../gradle/versions/updates/DependencyUpdatesTask.groovy | 8 ++++---- .../ComponentSelectionRulesWithCurrent.groovy | 8 ++++---- .../ComponentSelectionWithCurrent.groovy | 4 ++-- .../versions/ComponentSelectionRuleSourceSpec.groovy | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/groovy/com/github/benmanes/gradle/versions/updates/DependencyUpdatesTask.groovy b/src/main/groovy/com/github/benmanes/gradle/versions/updates/DependencyUpdatesTask.groovy index 219dadc5..66551056 100644 --- a/src/main/groovy/com/github/benmanes/gradle/versions/updates/DependencyUpdatesTask.groovy +++ b/src/main/groovy/com/github/benmanes/gradle/versions/updates/DependencyUpdatesTask.groovy @@ -52,8 +52,8 @@ class DependencyUpdatesTask extends DefaultTask { @Input boolean checkForGradleUpdate = true - Object outputFormatter = 'plain'; - Action resolutionStrategy = null; + Object outputFormatter = 'plain' + Action resolutionStrategyAction = null DependencyUpdatesTask() { description = 'Displays the dependency updates for the project.' @@ -66,7 +66,7 @@ class DependencyUpdatesTask extends DefaultTask { def dependencyUpdates() { project.evaluationDependsOnChildren() - def evaluator = new DependencyUpdates(project, resolutionStrategy, revisionLevel(), + def evaluator = new DependencyUpdates(project, resolutionStrategyAction, revisionLevel(), outputFormatterProp(), outputDirectory(), getReportfileName(), checkForGradleUpdate, gradleReleaseChannelLevel()) DependencyUpdatesReporter reporter = evaluator.run() reporter?.write() @@ -77,7 +77,7 @@ class DependencyUpdatesTask extends DefaultTask { * @param resolutionStrategy the resolution strategy */ void resolutionStrategy(final Action resolutionStrategy) { - this.resolutionStrategy = resolutionStrategy + this.resolutionStrategyAction = resolutionStrategy } /** Returns the resolution revision level. */ diff --git a/src/main/groovy/com/github/benmanes/gradle/versions/updates/resolutionstrategy/ComponentSelectionRulesWithCurrent.groovy b/src/main/groovy/com/github/benmanes/gradle/versions/updates/resolutionstrategy/ComponentSelectionRulesWithCurrent.groovy index 17395516..097b5180 100644 --- a/src/main/groovy/com/github/benmanes/gradle/versions/updates/resolutionstrategy/ComponentSelectionRulesWithCurrent.groovy +++ b/src/main/groovy/com/github/benmanes/gradle/versions/updates/resolutionstrategy/ComponentSelectionRulesWithCurrent.groovy @@ -38,7 +38,7 @@ class ComponentSelectionRulesWithCurrent { ComponentSelectionRulesWithCurrent all(Object ruleSource) { RuleAction ruleAction = RuleSourceBackedRuleAction.create( - ModelType.of(ComponentSelectionWithCurrent.class), ruleSource) + ModelType.of(ComponentSelectionWithCurrent), ruleSource) delegate.all(new Action() { void execute(ComponentSelection inner) { ruleAction.execute(wrapComponentSelection(inner), []) @@ -70,7 +70,7 @@ class ComponentSelectionRulesWithCurrent { ComponentSelectionRulesWithCurrent withModule(Object id, Object ruleSource) { RuleAction ruleAction = RuleSourceBackedRuleAction.create( - ModelType.of(ComponentSelectionWithCurrent.class), ruleSource) + ModelType.of(ComponentSelectionWithCurrent), ruleSource) delegate.withModule(id, new Action() { void execute(ComponentSelection inner) { ruleAction.execute(wrapComponentSelection(inner), []) @@ -82,8 +82,8 @@ class ComponentSelectionRulesWithCurrent { private ComponentSelectionWithCurrent wrapComponentSelection(ComponentSelection inner) { Coordinate candidateCoordinate = Coordinate.from(inner.candidate) Coordinate current = currentCoordinates.get(candidateCoordinate.key) - ComponentSelectionWithCurrent wrapped = new ComponentSelectionWithCurrent(inner, - current.version) + ComponentSelectionWithCurrent wrapped = new ComponentSelectionWithCurrent(current.version, + inner) return wrapped } } diff --git a/src/main/groovy/com/github/benmanes/gradle/versions/updates/resolutionstrategy/ComponentSelectionWithCurrent.groovy b/src/main/groovy/com/github/benmanes/gradle/versions/updates/resolutionstrategy/ComponentSelectionWithCurrent.groovy index 1d84a7f6..61bb201b 100644 --- a/src/main/groovy/com/github/benmanes/gradle/versions/updates/resolutionstrategy/ComponentSelectionWithCurrent.groovy +++ b/src/main/groovy/com/github/benmanes/gradle/versions/updates/resolutionstrategy/ComponentSelectionWithCurrent.groovy @@ -6,8 +6,8 @@ import org.gradle.api.artifacts.ComponentSelection @TupleConstructor(includeFields=true) class ComponentSelectionWithCurrent { + final String currentVersion + @Delegate private final ComponentSelection delegate - - public final String currentVersion } diff --git a/src/test/groovy/com/github/benmanes/gradle/versions/ComponentSelectionRuleSourceSpec.groovy b/src/test/groovy/com/github/benmanes/gradle/versions/ComponentSelectionRuleSourceSpec.groovy index db31c374..fbfb93dd 100644 --- a/src/test/groovy/com/github/benmanes/gradle/versions/ComponentSelectionRuleSourceSpec.groovy +++ b/src/test/groovy/com/github/benmanes/gradle/versions/ComponentSelectionRuleSourceSpec.groovy @@ -13,10 +13,10 @@ final class ComponentSelectionRuleSourceSpec extends Specification { private List pluginClasspath def 'setup'() { - def pluginClasspathResource = getClass().classLoader.findResource("plugin-classpath.txt") + def pluginClasspathResource = getClass().classLoader.findResource('plugin-classpath.txt') if (pluginClasspathResource == null) { throw new IllegalStateException( - "Did not find plugin classpath resource, run `testClasses` build task.") + 'Did not find plugin classpath resource, run `testClasses` build task.') } pluginClasspath = pluginClasspathResource.readLines().collect { new File(it) } @@ -28,7 +28,7 @@ final class ComponentSelectionRuleSourceSpec extends Specification { def classpathString = pluginClasspath .collect { it.absolutePath.replace('\\', '\\\\') } // escape backslashes in Windows paths .collect { "'$it'" } - .join(", ") + .join(', ') def mavenRepoUrl = getClass().getResource('/maven/').toURI() def srdErrWriter = new StringWriter()