Skip to content

Commit

Permalink
fix: don't use mutable objects for constants
Browse files Browse the repository at this point in the history
  • Loading branch information
grv87 committed Dec 1, 2018
1 parent 5544399 commit e51c829
Show file tree
Hide file tree
Showing 15 changed files with 47 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package org.fidata.gradle

import static org.fidata.testfixtures.gradle.GradleRunnerUtils.skippedTaskPathsGradleBugWorkaround
import static org.fidata.testfixtures.TestFixtures.initEmptyGitRepository
import com.google.common.collect.ImmutableMap
import spock.lang.Specification
import spock.lang.Unroll
import org.gradle.testkit.runner.GradleRunner
Expand All @@ -39,14 +40,14 @@ class GradlePluginPluginSpecification extends Specification {
File settingsFile = new File(testProjectDir, 'settings.gradle')
File propertiesFile = new File(testProjectDir, 'gradle.properties')

static final Map<String, String> EXTRA_PROPERTIES = [
static final Map<String, String> EXTRA_PROPERTIES = ImmutableMap.copyOf([
'artifactoryUser' : 'dummyArtifactoryUser',
'artifactoryPassword': 'dummyArtifactoryPassword',
'gitUsername': 'dummyGitUser',
'gitPassword': 'dummyGitPassword',
'ghToken': 'dummyGhToken',
'gpgKeyId': 'ABCD1234',
]
])

// fixture methods

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.fidata.gradle

import static org.fidata.testfixtures.TestFixtures.initEmptyGitRepository
import com.google.common.collect.ImmutableMap
import org.gradle.testkit.runner.GradleRunner
import spock.lang.Specification

Expand All @@ -35,14 +36,14 @@ class JVMBasePluginSpecification extends Specification {
File buildFile = new File(testProjectDir, 'build.gradle')
File propertiesFile = new File(testProjectDir, 'gradle.properties')

static final Map<String, String> EXTRA_PROPERTIES = [
static final Map<String, String> EXTRA_PROPERTIES = ImmutableMap.copyOf([
'artifactoryUser' : 'dummyArtifactoryUser',
'artifactoryPassword': 'dummyArtifactoryPassword',
'gitUsername': 'dummyGitUser',
'gitPassword': 'dummyGitPassword',
'ghToken': 'dummyGhToken',
'gpgKeyId': 'ABCD1234',
]
])

// fixture methods

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package org.fidata.gradle

import static org.fidata.testfixtures.TestFixtures.initEmptyGitRepository
import com.google.common.collect.ImmutableMap
import org.gradle.testkit.runner.GradleRunner
import spock.lang.Specification

Expand All @@ -42,14 +43,14 @@ class ProjectPluginBuildSrcSpecification extends Specification {

File buildSrcPropertiesFile = new File(buildSrcTestProjectDir, 'gradle.properties')

static final Map<String, String> EXTRA_PROPERTIES = [
static final Map<String, String> EXTRA_PROPERTIES = ImmutableMap.copyOf([
'artifactoryUser' : System.getProperty('org.fidata.compatTest.artifactoryUser'),
'artifactoryPassword': System.getProperty('org.fidata.compatTest.artifactoryPassword'),
'gitUsername': 'dummyGitUser',
'gitPassword': 'dummyGitPassword',
'ghToken': 'dummyGhToken',
'gpgKeyId': 'ABCD1234',
]
])

// fixture methods

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.fidata.gradle

import static org.fidata.testfixtures.TestFixtures.initEmptyGitRepository
import com.google.common.collect.ImmutableMap
import org.gradle.testkit.runner.GradleRunner
import spock.lang.Specification

Expand All @@ -35,14 +36,14 @@ class ProjectPluginSpecification extends Specification {
File buildFile = new File(testProjectDir, 'build.gradle')
File propertiesFile = new File(testProjectDir, 'gradle.properties')

static final Map<String, String> EXTRA_PROPERTIES = [
static final Map<String, String> EXTRA_PROPERTIES = ImmutableMap.copyOf([
'artifactoryUser' : 'dummyArtifactoryUser',
'artifactoryPassword': 'dummyArtifactoryPassword',
'gitUsername': 'dummyGitUser',
'gitPassword': 'dummyGitPassword',
'ghToken': 'dummyGhToken',
'gpgKeyId' : 'ABCD1234',
]
])

// fixture methods

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.fidata.gradle

import static org.fidata.testfixtures.TestFixtures.initEmptyGitRepository
import com.google.common.collect.ImmutableMap
import org.gradle.api.Project
import org.gradle.testfixtures.ProjectBuilder
import org.junit.Rule
Expand All @@ -36,14 +37,14 @@ class GroovyProjectPluginSpecification extends Specification {

Project project

static final Map<String, String> EXTRA_PROPERTIES = [
static final Map<String, String> EXTRA_PROPERTIES = ImmutableMap.copyOf([
'artifactoryUser' : 'dummyArtifactoryUser',
'artifactoryPassword': 'dummyArtifactoryPassword',
'gitUsername': 'dummyGitUser',
'gitPassword': 'dummyGitPassword',
'ghToken': 'dummyGhToken',
'gpgKeyId': 'ABCD1234',
]
])

// fixture methods

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.fidata.gradle

import static org.fidata.testfixtures.TestFixtures.initEmptyGitRepository
import com.google.common.collect.ImmutableMap
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.testfixtures.ProjectBuilder
Expand All @@ -37,14 +38,14 @@ class JVMBasePluginSpecification extends Specification {

Project project

static final Map<String, String> EXTRA_PROPERTIES = [
static final Map<String, String> EXTRA_PROPERTIES = ImmutableMap.copyOf([
'artifactoryUser' : 'dummyArtifactoryUser',
'artifactoryPassword': 'dummyArtifactoryPassword',
'gitUsername': 'dummyGitUser',
'gitPassword': 'dummyGitPassword',
'ghToken': 'dummyGhToken',
'gpgKeyId': 'ABCD1234',
]
])

// fixture methods

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package org.fidata.gradle

import static org.fidata.testfixtures.TestFixtures.initEmptyGitRepository
import com.google.common.collect.ImmutableMap
import org.gradle.api.Project
import org.gradle.api.internal.plugins.PluginApplicationException
import org.gradle.testfixtures.ProjectBuilder
Expand All @@ -40,14 +41,14 @@ class ProjectPluginExtraPropertiesSpecification extends Specification {

Project project

static final Map<String, String> EXTRA_PROPERTIES = [
static final Map<String, String> EXTRA_PROPERTIES = ImmutableMap.copyOf([
'artifactoryUser' : 'dummyArtifactoryUser',
'artifactoryPassword': 'dummyArtifactoryPassword',
'gitUsername': 'dummyGitUser',
'gitPassword': 'dummyGitPassword',
'ghToken': 'dummyGhToken',
'gpgKeyId': 'ABCD1234',
]
])

// fixture methods

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.fidata.gradle

import static org.fidata.testfixtures.TestFixtures.initEmptyGitRepository
import com.google.common.collect.ImmutableMap
import org.spdx.spdxspreadsheet.InvalidLicenseStringException
import spock.lang.Specification
import org.junit.Rule
Expand All @@ -40,14 +41,14 @@ class ProjectPluginSpecification extends Specification {

Project project

static final Map<String, String> EXTRA_PROPERTIES = [
static final Map<String, String> EXTRA_PROPERTIES = ImmutableMap.copyOf([
'artifactoryUser' : 'dummyArtifactoryUser',
'artifactoryPassword': 'dummyArtifactoryPassword',
'gitUsername': 'dummyGitUser',
'gitPassword': 'dummyGitPassword',
'ghToken': 'dummyGhToken',
'gpgKeyId': 'ABCD1234',
]
])

// fixture methods

Expand Down
9 changes: 5 additions & 4 deletions src/main/groovy/org/fidata/gradle/ProjectPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import static org.fidata.gradle.utils.VersionUtils.isPreReleaseVersion
import static org.gradle.language.base.plugins.LifecycleBasePlugin.VERIFICATION_GROUP
import static com.dorongold.gradle.tasktree.TaskTreePlugin.TASK_TREE_TASK_NAME
import static org.fidata.gpg.GpgUtils.getGpgHome
import com.google.common.collect.ImmutableList
import com.github.zafarkhaja.semver.ParseException
import java.nio.file.InvalidPathException
import org.gradle.api.plugins.quality.Pmd
Expand Down Expand Up @@ -116,7 +117,7 @@ final class ProjectPlugin extends AbstractProjectPlugin {
/**
* List of filenames considered as license files
*/
public static final List<String> LICENSE_FILE_NAMES = [
public static final List<String> LICENSE_FILE_NAMES = ImmutableList.of(
// License file names recognized by JFrog Artifactory
'license',
'LICENSE',
Expand All @@ -126,7 +127,7 @@ final class ProjectPlugin extends AbstractProjectPlugin {
// GPL standard file names
'COPYING',
'COPYING.LESSER',
]
)

/**
* Minimum supported version of Gradle
Expand Down Expand Up @@ -276,7 +277,7 @@ final class ProjectPlugin extends AbstractProjectPlugin {
* Move these filters into separate library
* <grv87 2018-09-22>
*/
public static final List<String> BUILD_INFO_ENV_VARS_EXCLUDE_PATTERS = [
public static final List<String> BUILD_INFO_ENV_VARS_EXCLUDE_PATTERS = ImmutableList.of(
'*Password',
'*Passphrase',
'*SecretKey',
Expand All @@ -287,7 +288,7 @@ final class ProjectPlugin extends AbstractProjectPlugin {
'*gradlePluginsSecret',
'*OAuthClientSecret',
'*Token',
]
)

private void configureArtifactory() {
project.convention.getPlugin(ArtifactoryPluginConvention).with {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package org.fidata.gradle

import com.google.common.collect.ImmutableMap
import groovy.transform.CompileStatic
import org.fidata.gradle.utils.PluginDependee

Expand All @@ -30,7 +31,7 @@ final class GradlePluginPluginDependees {
/**
* List of plugin dependees with IDs
*/
static final Map<String, PluginDependee> PLUGIN_DEPENDEES = [
static final Map<String, PluginDependee> PLUGIN_DEPENDEES = ImmutableMap.copyOf([
'org.gradle.java-gradle-plugin': new PluginDependee(),
'org.ajoberstar.stutter': new PluginDependee(
version: '[0, 1[',
Expand All @@ -45,7 +46,7 @@ final class GradlePluginPluginDependees {
version: '[0, 1[',
enabled: false,
),
]
])

// Suppress default constructor for noninstantiability
private GradlePluginPluginDependees() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package org.fidata.gradle

import com.google.common.collect.ImmutableMap
import groovy.transform.CompileStatic
import org.fidata.gradle.utils.PluginDependee

Expand All @@ -30,9 +31,9 @@ final class GroovyBaseProjectPluginDependees {
/**
* List of plugin dependees with IDs
*/
static final Map<String, PluginDependee> PLUGIN_DEPENDEES = [
static final Map<String, PluginDependee> PLUGIN_DEPENDEES = ImmutableMap.copyOf([
'org.gradle.groovy-base': new PluginDependee(),
]
])

// Suppress default constructor for noninstantiability
private GroovyBaseProjectPluginDependees() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package org.fidata.gradle

import com.google.common.collect.ImmutableMap
import groovy.transform.CompileStatic
import org.fidata.gradle.utils.PluginDependee

Expand All @@ -30,9 +31,9 @@ final class GroovyProjectPluginDependees {
/**
* List of plugin dependees with IDs
*/
static final Map<String, PluginDependee> PLUGIN_DEPENDEES = [
static final Map<String, PluginDependee> PLUGIN_DEPENDEES = ImmutableMap.copyOf([
'org.gradle.groovy': new PluginDependee(),
]
])

// Suppress default constructor for noninstantiability
private GroovyProjectPluginDependees() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package org.fidata.gradle

import com.google.common.collect.ImmutableMap
import groovy.transform.CompileStatic
import org.fidata.gradle.utils.PluginDependee
import org.fidata.gradle.utils.PluginDependeeExclusion
Expand All @@ -31,7 +32,7 @@ final class JVMBasePluginDependees {
/**
* List of plugin dependees with IDs
*/
static final Map<String, PluginDependee> PLUGIN_DEPENDEES = [
static final Map<String, PluginDependee> PLUGIN_DEPENDEES = ImmutableMap.copyOf([
'org.gradle.java-base': new PluginDependee(),
'org.gradle.java-library': new PluginDependee(),
'org.gradle.maven-publish': new PluginDependee(
Expand All @@ -53,7 +54,7 @@ final class JVMBasePluginDependees {
],
enabled: false,
),
]
])

// Suppress default constructor for noninstantiability
private JVMBasePluginDependees() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package org.fidata.gradle

import com.google.common.collect.ImmutableMap
import groovy.transform.CompileStatic
import org.fidata.gradle.utils.PluginDependee

Expand All @@ -30,13 +31,13 @@ final class JavaProjectPluginDependees {
/**
* List of plugin dependees with IDs
*/
static final Map<String, PluginDependee> PLUGIN_DEPENDEES = [
static final Map<String, PluginDependee> PLUGIN_DEPENDEES = ImmutableMap.copyOf([
'org.gradle.java': new PluginDependee(),
'io.franzbecker.gradle-lombok': new PluginDependee(
configurationName: 'implementation',
version: '[1, 2[',
),
]
])

// Suppress default constructor for noninstantiability
private JavaProjectPluginDependees() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package org.fidata.gradle

import com.google.common.collect.ImmutableMap
import groovy.transform.CompileStatic
import org.fidata.gradle.utils.PluginDependee
import org.fidata.gradle.utils.PluginDependeeExclusion
Expand All @@ -31,7 +32,7 @@ final class ProjectPluginDependees {
/**
* List of plugin dependees with IDs
*/
static final Map<String, PluginDependee> PLUGIN_DEPENDEES = [
static final Map<String, PluginDependee> PLUGIN_DEPENDEES = ImmutableMap.copyOf([
'org.gradle.idea': new PluginDependee(),
'org.gradle.lifecycle-base': new PluginDependee(),
'org.fidata.prerequisites': new PluginDependee(
Expand Down Expand Up @@ -91,7 +92,7 @@ final class ProjectPluginDependees {
configurationName: 'implementation',
version: '[1, 2[',
),
]
])

// Suppress default constructor for noninstantiability
private ProjectPluginDependees() {
Expand Down

0 comments on commit e51c829

Please sign in to comment.