Skip to content

Commit

Permalink
Add check for duplicated file patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
tibetiroka committed Feb 23, 2024
1 parent 4d51610 commit dbc0834
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/com/tibetiroka/deblint/Linters.java
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ public boolean isMoreGeneric(String first, String second) {
*/
public void lintFileStanzas(ControlFile file, Configuration config) {
if(config.copyrightFilePatternGenerality) {
ArrayList<String> previousPatterns = new ArrayList<>();
HashSet<String> previousPatterns = new HashSet<>();
for(int i = 0; i < file.getSpecs().size(); i++) {
StanzaSpec spec = file.getSpecs().get(i);
if(spec.name().equals("file stanza")) {
Expand All @@ -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)) {
Expand Down

0 comments on commit dbc0834

Please sign in to comment.