Skip to content

Commit 01780c2

Browse files
committed
Apply Eclipse clean up rules
This mostly just adds missing final keywords.
1 parent a04b603 commit 01780c2

File tree

9 files changed

+100
-85
lines changed

9 files changed

+100
-85
lines changed

src/main/java/org/scijava/maven/plugin/BumpMojo.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ public void execute() throws MojoExecutionException, MojoFailureException {
101101
editor.visitVersions(new VersionVisitor() {
102102

103103
@Override
104-
public String visit(String groupId, String artifactId, String version)
105-
throws MojoExecutionException
104+
public String visit(final String groupId, final String artifactId,
105+
final String version) throws MojoExecutionException
106106
{
107107
return latestVersion(groupId, artifactId);
108108
}
@@ -113,13 +113,13 @@ public String visit(String groupId, String artifactId, String version)
113113
catch (final IOException e) {
114114
throw new MojoExecutionException("Could not read POM", e);
115115
}
116-
catch (ParserConfigurationException e) {
116+
catch (final ParserConfigurationException e) {
117117
throw new MojoExecutionException("Could not parse POM", e);
118118
}
119-
catch (SAXException e) {
119+
catch (final SAXException e) {
120120
throw new MojoExecutionException("Could not parse POM", e);
121121
}
122-
catch (XPathExpressionException e) {
122+
catch (final XPathExpressionException e) {
123123
throw new MojoExecutionException(
124124
"Could not extract information from POM", e);
125125
}
@@ -128,15 +128,16 @@ public String visit(String groupId, String artifactId, String version)
128128
@Component
129129
private ProjectDependenciesResolver projectDependenciesResolver;
130130

131-
private String latestVersion(String groupId, String artifactId)
131+
private String latestVersion(final String groupId, final String artifactId)
132132
throws MojoExecutionException
133133
{
134134
final VersionRangeRequest request = new VersionRangeRequest();
135135
final Artifact artifact =
136136
new DefaultArtifact(groupId, artifactId, null, "[0,)");
137137
request.setArtifact(artifact);
138138
makeImageJRepositoryKnown();
139-
List<RemoteRepository> repositories = new ArrayList<RemoteRepository>();
139+
final List<RemoteRepository> repositories =
140+
new ArrayList<RemoteRepository>();
140141
repositories.addAll(remoteRepositories);
141142
request.setRepositories(repositories);
142143
VersionRangeResult result;
@@ -153,7 +154,7 @@ private String latestVersion(String groupId, String artifactId)
153154
"Found no candidates for " + groupId + ":" + artifactId + "; Skipping");
154155
return null;
155156
}
156-
catch (VersionRangeResolutionException e) {
157+
catch (final VersionRangeResolutionException e) {
157158
throw new MojoExecutionException("Could not resolve version for " +
158159
groupId + ":" + artifactId, e);
159160
}

src/main/java/org/scijava/maven/plugin/EclipseHelperMojo.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,31 +99,31 @@ public void execute() throws MojoExecutionException {
9999
thread.setContextClassLoader(loader);
100100
main.invoke(null, (Object) new String[0]);
101101
}
102-
catch (Exception e) {
102+
catch (final Exception e) {
103103
throw new MojoExecutionException(
104104
"Could not execute EclipseHelper's main() method", e);
105105
}
106106
finally {
107107
thread.setContextClassLoader(previousLoader);
108108
}
109109
}
110-
catch (DependencyResolutionRequiredException e) {
110+
catch (final DependencyResolutionRequiredException e) {
111111
throw new MojoExecutionException("Could not get the class path", e);
112112
}
113-
catch (MalformedURLException e) {
113+
catch (final MalformedURLException e) {
114114
throw new MojoExecutionException(
115115
"Could not build class path for EclipseHelper", e);
116116
}
117-
catch (ClassNotFoundException e) {
117+
catch (final ClassNotFoundException e) {
118118
throw new MojoExecutionException(
119119
"Could not load EclipseHelper. If you are using Eclipse and have scijava-common open - close it.",
120120
e);
121121
}
122-
catch (NoSuchMethodException e) {
122+
catch (final NoSuchMethodException e) {
123123
throw new MojoExecutionException(
124124
"Could not find EclipseHelper's main() method", e);
125125
}
126-
catch (SecurityException e) {
126+
catch (final SecurityException e) {
127127
throw new MojoExecutionException(
128128
"Could not access EclipseHelper's main() method", e);
129129
}

src/main/java/org/scijava/maven/plugin/RequireReproducibleBuilds.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public void execute(final EnforcerRuleHelper helper)
101101
DependencyUtils.findEffectiveReactor(reactorModules, session,
102102
project, projectBuilder, localRepository);
103103
}
104-
catch (ProjectBuildingException exc) {
104+
catch (final ProjectBuildingException exc) {
105105
log
106106
.warn("Error during project construction:\n" + exc.getMessage(), exc);
107107
}

src/main/java/org/scijava/maven/plugin/VerifyNoSnapshotsMojo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
108108
DependencyUtils.findEffectiveReactor(reactorModules, mavenSession,
109109
mavenProject, projectBuilder, localRepository);
110110
}
111-
catch (ProjectBuildingException exc) {
111+
catch (final ProjectBuildingException exc) {
112112
getLog().warn("Error during project construction:\n" + exc.getMessage(),
113113
exc);
114114
}

src/main/java/org/scijava/maven/plugin/enforcer/AbstractResolveDependencies.java

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ public abstract class AbstractResolveDependencies implements EnforcerRule {
8989
private transient EnforcerRuleHelper ruleHelper;
9090

9191
@Override
92-
public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException {
92+
public void execute(final EnforcerRuleHelper helper)
93+
throws EnforcerRuleException
94+
{
9395
ruleHelper = helper;
9496

9597
// Get components
@@ -100,7 +102,7 @@ public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException {
100102
(DependencyTreeBuilder) helper
101103
.getComponent(DependencyTreeBuilder.class);
102104
}
103-
catch (ComponentLookupException e) {
105+
catch (final ComponentLookupException e) {
104106
throw new EnforcerRuleException(
105107
"Unable to lookup DependencyTreeBuilder: ", e);
106108
}
@@ -119,12 +121,13 @@ public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException {
119121
.evaluate("${project.remoteArtifactRepositories}");
120122
remoteRepositories = result;
121123
}
122-
catch (ExpressionEvaluationException e) {
124+
catch (final ExpressionEvaluationException e) {
123125
throw new EnforcerRuleException("Unable to lookup an expression " +
124126
e.getLocalizedMessage(), e);
125127
}
126128

127-
Set<Artifact> artifacts = getDependenciesToCheck(project, localRepository);
129+
final Set<Artifact> artifacts =
130+
getDependenciesToCheck(project, localRepository);
128131

129132
handleArtifacts(artifacts);
130133
}
@@ -136,55 +139,55 @@ protected boolean isSearchTransitive() {
136139
return true;
137140
}
138141

139-
private Set<Artifact> getDependenciesToCheck(MavenProject project,
140-
ArtifactRepository repository)
142+
private Set<Artifact> getDependenciesToCheck(final MavenProject project,
143+
final ArtifactRepository repository)
141144
{
142145
Set<Artifact> dependencies = null;
143146
try {
144-
DependencyNode node =
147+
final DependencyNode node =
145148
treeBuilder.buildDependencyTree(project, repository, null);
146149

147150
if (isSearchTransitive()) {
148151
dependencies = getAllDescendants(node);
149152
}
150153
else if (node.getChildren() != null) {
151154
dependencies = new HashSet<Artifact>();
152-
for (DependencyNode depNode : node.getChildren()) {
155+
for (final DependencyNode depNode : node.getChildren()) {
153156
dependencies.add(depNode.getArtifact());
154157
}
155158
}
156159
}
157-
catch (DependencyTreeBuilderException e) {
160+
catch (final DependencyTreeBuilderException e) {
158161
// otherwise we need to change the signature of this protected method
159162
throw new RuntimeException(e);
160163
}
161164
return dependencies;
162165
}
163166

164-
private Set<Artifact> getAllDescendants(DependencyNode node) {
167+
private Set<Artifact> getAllDescendants(final DependencyNode node) {
165168
Set<Artifact> children = null;
166169
if (node.getChildren() != null) {
167170
children = new HashSet<Artifact>();
168-
for (DependencyNode depNode : node.getChildren()) {
171+
for (final DependencyNode depNode : node.getChildren()) {
169172
try {
170173
if (depNode.getState() == DependencyNode.INCLUDED) {
171-
Artifact artifact = depNode.getArtifact();
174+
final Artifact artifact = depNode.getArtifact();
172175

173176
resolver.resolve(artifact, remoteRepositories, localRepository);
174177

175178
children.add(artifact);
176179

177-
Set<Artifact> subNodes = getAllDescendants(depNode);
180+
final Set<Artifact> subNodes = getAllDescendants(depNode);
178181

179182
if (subNodes != null) {
180183
children.addAll(subNodes);
181184
}
182185
}
183186
}
184-
catch (ArtifactResolutionException e) {
187+
catch (final ArtifactResolutionException e) {
185188
getLog().warn(e.getMessage());
186189
}
187-
catch (ArtifactNotFoundException e) {
190+
catch (final ArtifactNotFoundException e) {
188191
getLog().warn(e.getMessage());
189192
}
190193
}
@@ -202,7 +205,7 @@ public boolean isCacheable() {
202205
}
203206

204207
@Override
205-
public boolean isResultValid(EnforcerRule enforcerRule) {
208+
public boolean isResultValid(final EnforcerRule enforcerRule) {
206209
return false;
207210
}
208211

@@ -217,11 +220,11 @@ public String getCacheId() {
217220
* @param wildcard the wildcard to convert.
218221
* @return the equivalent regex.
219222
*/
220-
protected static String asRegex(String wildcard) {
221-
StringBuilder result = new StringBuilder(wildcard.length());
223+
protected static String asRegex(final String wildcard) {
224+
final StringBuilder result = new StringBuilder(wildcard.length());
222225
result.append('^');
223226
for (int index = 0; index < wildcard.length(); index++) {
224-
char character = wildcard.charAt(index);
227+
final char character = wildcard.charAt(index);
225228
switch (character) {
226229
case '*':
227230
result.append(".*");
@@ -264,22 +267,22 @@ protected class IgnorableDependency {
264267
public Pattern type;
265268
public List<Pattern> ignorePatterns = new ArrayList<Pattern>();
266269

267-
public IgnorableDependency applyIgnoreClasses(String[] ignores,
268-
boolean indent)
270+
public IgnorableDependency applyIgnoreClasses(final String[] ignores,
271+
final boolean indent)
269272
{
270-
String prefix = indent ? " " : "";
273+
final String prefix = indent ? " " : "";
271274
for (String ignore : ignores) {
272275
getLog().info(prefix + "Adding ignore: " + ignore);
273276
ignore = ignore.replace('.', '/');
274-
String pattern = asRegex(ignore);
277+
final String pattern = asRegex(ignore);
275278
getLog().debug(
276279
prefix + "Ignore: " + ignore + " maps to regex " + pattern);
277280
ignorePatterns.add(Pattern.compile(pattern));
278281
}
279282
return this;
280283
}
281284

282-
public boolean matchesArtifact(Artifact dup) {
285+
public boolean matchesArtifact(final Artifact dup) {
283286
return (artifactId == null || artifactId.matcher(dup.getArtifactId())
284287
.matches()) &&
285288
(groupId == null || groupId.matcher(dup.getGroupId()).matches()) &&
@@ -288,8 +291,8 @@ public boolean matchesArtifact(Artifact dup) {
288291
(type == null || type.matcher(dup.getType()).matches());
289292
}
290293

291-
public boolean matches(String className) {
292-
for (Pattern p : ignorePatterns) {
294+
public boolean matches(final String className) {
295+
for (final Pattern p : ignorePatterns) {
293296
if (p.matcher(className).matches()) {
294297
return true;
295298
}

0 commit comments

Comments
 (0)