From dbc08348c662dd10cc9aa0d4970ea90228563c03 Mon Sep 17 00:00:00 2001 From: tibetiroka Date: Fri, 23 Feb 2024 21:50:52 +0100 Subject: [PATCH] Add check for duplicated file patterns --- src/main/java/com/tibetiroka/deblint/Linters.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/tibetiroka/deblint/Linters.java b/src/main/java/com/tibetiroka/deblint/Linters.java index de62c50..c062fd9 100644 --- a/src/main/java/com/tibetiroka/deblint/Linters.java +++ b/src/main/java/com/tibetiroka/deblint/Linters.java @@ -1090,7 +1090,7 @@ public boolean isMoreGeneric(String first, String second) { */ public void lintFileStanzas(ControlFile file, Configuration config) { if(config.copyrightFilePatternGenerality) { - ArrayList previousPatterns = new ArrayList<>(); + HashSet previousPatterns = new HashSet<>(); for(int i = 0; i < file.getSpecs().size(); i++) { StanzaSpec spec = file.getSpecs().get(i); if(spec.name().equals("file stanza")) { @@ -1101,6 +1101,9 @@ public void lintFileStanzas(ControlFile file, Configuration config) { if(config.redundantFilePattern) { for(int i1 = 0; i1 < currentPatterns.size(); i1++) { String pat1 = currentPatterns.get(i1); + if(previousPatterns.contains(pat1)) { + Main.error("Duplicate file pattern: " + pat1, "redundantFilePattern"); + } for(int i2 = i1 + 1; i2 < currentPatterns.size(); i2++) { String pat2 = currentPatterns.get(i2); if(isMoreGeneric(pat1, pat2) || isMoreGeneric(pat2, pat1)) {