@@ -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