ottlinger commented on code in PR #240:
URL: https://github.com/apache/creadur-rat/pull/240#discussion_r1581906723


##########
apache-rat-core/src/main/java/org/apache/rat/report/claim/ClaimStatistic.java:
##########
@@ -57,45 +58,71 @@ public int getCounter(Counter counter) {
         return count == null ? 0 : count[0];
     }
 
-    /**
-     * @return Returns a map with the file types. The map keys
-     * are file type names and the map values
-     * are integers with the number of resources matching
-     * the file type.
-     */
-    public Map<Counter, int[]> getCounterMap() {
-        return counterMap;
+    public void incCounter(Counter key, int value) {
+        final int[] num = counterMap.get(key);
+
+        if (num == null) {
+            counterMap.put(key, new int[] { value });
+        } else {
+            num[0] += value;
+        }
     }
 
-    
     /**
-     * @return Returns a map with the file types. The map keys
-     * are file type names and the map values
-     * are integers with the number of resources matching
-     * the file type.
+     * Returns the counts for the counter.
+     * @param documentType the document type to get the counter for.
+     * @return Returns the number of files with approved licenses.
      */
-    public Map<Document.Type, int[]> getDocumentCategoryMap() {
-        return documentCategoryMap;
+    public int getCounter(Document.Type documentType) {
+        int[] count = documentCategoryMap.get(documentType);
+        return count == null ? 0 : count[0];
     }
 
-    /**
-     * @return Returns a map with the license family codes. The map
-     * keys are license family category names,
-     * the map values are integers with the number of resources
-     * matching the license family code.
-     */
-    public Map<String, int[]> getLicenseFamilyCodeMap() {
-        return licenseFamilyCodeMap;
+    public void incCounter(Document.Type documentType, int value) {
+        final int[] num = documentCategoryMap.get(documentType);
+
+        if (num == null) {
+            documentCategoryMap.put(documentType, new int[] { value });
+        } else {
+            num[0] += value;
+        }
     }
 
-    /**
-     * @return Returns a map with the license family codes. The map
-     * keys are the names of the license families and
-     * the map values are integers with the number of resources
-     * matching the license family name.
-     */
-    public Map<String, int[]> getLicenseFileNameMap() {
-        return licenseFamilyNameMap;
+    public int getLicenseFamilyCount(String licenseFamilyName) {
+        int[] count = licenseFamilyCodeMap.get(licenseFamilyName);
+        return count == null ? 0 : count[0];
+    }
+
+    public void incLicenseFamilyCount(String licenseFamilyName, int value) {
+        final int[] num = licenseFamilyCodeMap.get(licenseFamilyName);
+
+        if (num == null) {
+            licenseFamilyCodeMap.put(licenseFamilyName, new int[] { value });
+        } else {
+            num[0] += value;
+        }
     }
 
+    public Set<String> getLicenseFamilyNames() {
+        return Collections.unmodifiableSet(licenseFamilyCodeMap.keySet());
+    }
+
+    public Set<String> getLicenseFileNames() {
+        return Collections.unmodifiableSet(licenseFamilyNameMap.keySet());
+    }
+
+    public int getLicenseFileNameCount(String licenseFilename) {
+        int[] count = licenseFamilyNameMap.get(licenseFilename);
+        return count == null ? 0 : count[0];
+    }
+
+    public void incLicenseFileNameCount(String licenseFileNameName, int value) 
{
+        final int[] num = licenseFamilyNameMap.get(licenseFileNameName);
+
+        if (num == null) {
+            licenseFamilyNameMap.put(licenseFileNameName, new int[] { value });
+        } else {
+            num[0] += value;

Review Comment:
   AtomicInteger?



##########
apache-rat-core/src/main/java/org/apache/rat/walker/DirectoryWalker.java:
##########
@@ -38,56 +38,42 @@ public class DirectoryWalker extends Walker implements 
IReportable {
 
     private static final FileNameComparator COMPARATOR = new 
FileNameComparator();
 
-    private final IOFileFilter directoryFilter;
-
-    /**
-     * Constructs a walker.
-     *
-     * @param file the directory to walk.
-     * @param directoryFilter directory filter to eventually exclude some 
directories/files from the scan.
-     */
-    public DirectoryWalker(File file, IOFileFilter directoryFilter) {
-        this(file, (FilenameFilter) null, directoryFilter);
-    }
+    private final IOFileFilter directoriesToIgnore;
 
     /**
      * Constructs a walker.
      *
      * @param file the directory to walk (not null).
-     * @param filter filters input files (optional),
+     * @param filesToIgnore filters input files (optional),
      *               or null when no filtering should be performed
-     * @param directoryFilter filters directories (optional), or null when no 
filtering should be performed.
+     * @param directoriesToIgnore filters directories (optional), or null when 
no filtering should be performed.
      */
-    public DirectoryWalker(File file, final FilenameFilter filter, 
IOFileFilter directoryFilter) {
-        super(file.getPath(), file, filter);
-        this.directoryFilter = directoryFilter;
+    public DirectoryWalker(File file, final FilenameFilter filesToIgnore, 
IOFileFilter directoriesToIgnore) {
+        super(file.getPath(), file, filesToIgnore);

Review Comment:
   Maybe this class would also benefit from ScanDefault as mentioned in above 
comments



##########
apache-rat-core/src/main/java/org/apache/rat/walker/Walker.java:
##########
@@ -33,38 +34,32 @@ public abstract class Walker implements IReportable {
     protected final File file;
     protected final String name;
 
-    protected final FilenameFilter filter;
+    protected final FilenameFilter filesToIgnore;
 
     protected static FilenameFilter regexFilter(final Pattern pattern) {
         return (dir, name) -> {
             final boolean result;
             if (pattern == null) {
-                result = true;
+                result = false;
             } else {
-                result = !pattern.matcher(name).matches();
+                result = pattern.matcher(name).matches();

Review Comment:
   Thanks for getting rid of the negation. Has there been an error in here 
before or should line 42 be changed as well?
   
   BEFORE
   if(pattern==null) return true
   else 
   !pattern.matches()
   
   NOW
   if(pattern==null) return false
   else 
   pattern.matches()
   
   or did I not get what is going on here?



##########
apache-rat-core/src/main/java/org/apache/rat/report/claim/ClaimStatistic.java:
##########
@@ -57,45 +58,71 @@ public int getCounter(Counter counter) {
         return count == null ? 0 : count[0];
     }
 
-    /**
-     * @return Returns a map with the file types. The map keys
-     * are file type names and the map values
-     * are integers with the number of resources matching
-     * the file type.
-     */
-    public Map<Counter, int[]> getCounterMap() {
-        return counterMap;
+    public void incCounter(Counter key, int value) {
+        final int[] num = counterMap.get(key);
+
+        if (num == null) {
+            counterMap.put(key, new int[] { value });
+        } else {
+            num[0] += value;
+        }
     }
 
-    
     /**
-     * @return Returns a map with the file types. The map keys
-     * are file type names and the map values
-     * are integers with the number of resources matching
-     * the file type.
+     * Returns the counts for the counter.
+     * @param documentType the document type to get the counter for.
+     * @return Returns the number of files with approved licenses.
      */
-    public Map<Document.Type, int[]> getDocumentCategoryMap() {
-        return documentCategoryMap;
+    public int getCounter(Document.Type documentType) {
+        int[] count = documentCategoryMap.get(documentType);
+        return count == null ? 0 : count[0];
     }
 
-    /**
-     * @return Returns a map with the license family codes. The map
-     * keys are license family category names,
-     * the map values are integers with the number of resources
-     * matching the license family code.
-     */
-    public Map<String, int[]> getLicenseFamilyCodeMap() {
-        return licenseFamilyCodeMap;
+    public void incCounter(Document.Type documentType, int value) {
+        final int[] num = documentCategoryMap.get(documentType);
+
+        if (num == null) {
+            documentCategoryMap.put(documentType, new int[] { value });
+        } else {
+            num[0] += value;
+        }
     }
 
-    /**
-     * @return Returns a map with the license family codes. The map
-     * keys are the names of the license families and
-     * the map values are integers with the number of resources
-     * matching the license family name.
-     */
-    public Map<String, int[]> getLicenseFileNameMap() {
-        return licenseFamilyNameMap;
+    public int getLicenseFamilyCount(String licenseFamilyName) {
+        int[] count = licenseFamilyCodeMap.get(licenseFamilyName);
+        return count == null ? 0 : count[0];
+    }
+
+    public void incLicenseFamilyCount(String licenseFamilyName, int value) {
+        final int[] num = licenseFamilyCodeMap.get(licenseFamilyName);
+
+        if (num == null) {
+            licenseFamilyCodeMap.put(licenseFamilyName, new int[] { value });
+        } else {
+            num[0] += value;

Review Comment:
   AtomicInteger?



##########
src/changes/changes.xml:
##########
@@ -72,6 +72,22 @@ 
https://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd
     </release>
     -->
     <release version="0.17-SNAPSHOT" date="xxxx-yy-zz" description="Current 
SNAPSHOT - release to be done">
+      <action issue="RAT-54" type="fix" dev="claudenw">
+        MIME Detection Using Tika
+      </action>
+      <action issue="RAT-20" type="fix" dev="claudenw">
+        Changed to detecting binary by content not name.
+      </action>
+      <action issue="RAT-147" type="fix" dev="claudenw">
+        Change to detect non UTF-8 text as text not binary.

Review Comment:
   Isn't that what RAT-301 is all about? I got curious when I read your comment 
in the changelog here.



-- 
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: dev-unsubscr...@creadur.apache.org

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

Reply via email to