You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@creadur.apache.org by po...@apache.org on 2017/10/08 22:11:28 UTC

svn commit: r1811509 - in /creadur/rat/trunk/apache-rat-core/src: main/java/org/apache/rat/Report.java test/java/org/apache/rat/ReportTest.java

Author: pottlinger
Date: Sun Oct  8 22:11:28 2017
New Revision: 1811509

URL: http://svn.apache.org/viewvc?rev=1811509&view=rev
Log:
RAT-240: Unify handling of exclusion parsing

* Use same method from exclusionFile and as parameter to define excludes

Modified:
    creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/Report.java
    creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java

Modified: creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/Report.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/Report.java?rev=1811509&r1=1811508&r2=1811509&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/Report.java (original)
+++ creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/Report.java Sun Oct  8 22:11:28 2017
@@ -33,6 +33,7 @@ import org.apache.rat.walker.DirectoryWa
 
 import javax.xml.transform.TransformerConfigurationException;
 import java.io.*;
+import java.util.Arrays;
 import java.util.List;
 import java.util.regex.PatternSyntaxException;
 
@@ -78,7 +79,7 @@ public class Report {
             if (cl.hasOption(EXCLUDE_CLI)) {
                 String[] excludes = cl.getOptionValues(EXCLUDE_CLI);
                 if (excludes != null) {
-                    final FilenameFilter filter = new NotFileFilter(new WildcardFileFilter(excludes));
+                    final FilenameFilter filter = parseExclusions(Arrays.asList(excludes));
                     report.setInputFileFilter(filter);
                 }
             } else if (cl.hasOption(EXCLUDE_FILE_CLI)) {
@@ -114,7 +115,7 @@ public class Report {
         }
     }
 
-    private static FilenameFilter parseExclusions(List<String> excludes) throws IOException {
+    static FilenameFilter parseExclusions(List<String> excludes) throws IOException {
         final OrFileFilter orFilter = new OrFileFilter();
         for (String exclude : excludes) {
             try {
@@ -216,7 +217,7 @@ public class Report {
         return opts;
     }
 
-    private static final void printUsage(Options opts) {
+    private static void printUsage(Options opts) {
         HelpFormatter f = new HelpFormatter();
         String header = "Options";
 
@@ -244,15 +245,6 @@ public class Report {
     }
 
     /**
-     * Gets the current filter used to select files.
-     *
-     * @return current file filter, or null when no filter has been set
-     */
-    public FilenameFilter getInputFileFilter() {
-        return inputFileFilter;
-    }
-
-    /**
      * Sets the current filter used to select files.
      *
      * @param inputFileFilter filter, or null when no filter has been set

Modified: creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java?rev=1811509&r1=1811508&r2=1811509&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java (original)
+++ creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java Sun Oct  8 22:11:28 2017
@@ -24,9 +24,13 @@ import org.apache.rat.walker.DirectoryWa
 import org.junit.Test;
 
 import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
 import java.io.StringWriter;
+import java.util.Arrays;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 public class ReportTest {
@@ -130,4 +134,10 @@ public class ReportTest {
                 elementsReports,
                 result.substring(generatedAtLineEnd + NL.length()));
     }
+
+    @Test
+    public void parseExclusionsForCLIUsage() throws IOException {
+        final FilenameFilter filter = Report.parseExclusions(Arrays.asList("foo", "foo/bar"));
+        assertNotNull(filter);
+    }
 }