chadwick00 commented on code in PR #218:
URL: 
https://github.com/apache/maven-dependency-plugin/pull/218#discussion_r1342659340


##########
src/main/java/org/apache/maven/plugins/dependency/analyze/AbstractAnalyzeMojo.java:
##########
@@ -638,4 +720,35 @@ private List<Artifact> filterDependencies( Set<Artifact> 
artifacts, String[] exc
 
         return result;
     }
+
+
+    /**
+     * Filter for artifacts that match the <code>include</code> criteria.
+     * No filtering is applied if the criteria is empty.
+     *
+     * @param artifacts filtered for elements that do match the criteria
+     * @param includes the filter to be applied
+     * @return the list of artifacts that didn't match the criteria
+     */
+    private List<Artifact> filterDependencies( Set<Artifact> artifacts, 
String[] includes )
+    {
+        List<Artifact> result = new ArrayList<>();
+
+        if ( includes.length > 0 )
+        {
+          ArtifactFilter filter = new StrictPatternIncludesArtifactFilter( 
Arrays.asList( includes ) );
+
+            for ( Iterator<Artifact> it = artifacts.iterator(); it.hasNext(); )
+            {
+                Artifact artifact = it.next();
+                if ( !filter.include( artifact ) )
+                {
+                    it.remove();

Review Comment:
   The original `filterDependencies` method both mutates the `artifacts` 
argument and indicates what is has removed in the `result`. I didn't want to 
change the stateful nature of this methods because that would be a pretty 
serious overhaul to the code. So the remove call is needed to remove 
`artifacts` that don't match the include argument.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to