@@ -96,31 +96,17 @@ void execute() {
96
96
}
97
97
98
98
private void check (File factoriesFile ) {
99
- Properties factories = load (factoriesFile );
99
+ Properties properties = load (factoriesFile );
100
100
Map <String , List <String >> problems = new LinkedHashMap <>();
101
- for (String key : factories .stringPropertyNames ()) {
102
- List <String > values = Arrays
103
- .asList (StringUtils .commaDelimitedListToStringArray (factories .getProperty (key )));
104
- for (String value : values ) {
105
- boolean found = find (value );
106
- if (!found ) {
107
- List <String > problemsForKey = problems .computeIfAbsent (key , (k ) -> new ArrayList <>());
108
- String binaryName = binaryNameOf (value );
109
- found = find (binaryName );
110
- if (found ) {
111
- problemsForKey
112
- .add ("'%s' should be listed using its binary name '%s'" .formatted (value , binaryName ));
113
- }
114
- else {
115
- problemsForKey .add ("'%s' was not found" .formatted (value ));
116
- }
117
- }
118
- }
119
- List <String > sortedValues = new ArrayList <>(values );
101
+ for (String name : properties .stringPropertyNames ()) {
102
+ String value = properties .getProperty (name );
103
+ List <String > classNames = Arrays .asList (StringUtils .commaDelimitedListToStringArray (value ));
104
+ collectProblems (problems , name , classNames );
105
+ List <String > sortedValues = new ArrayList <>(classNames );
120
106
Collections .sort (sortedValues );
121
- if (!sortedValues .equals (values )) {
122
- List <String > problemsForKey = problems .computeIfAbsent (key , (k ) -> new ArrayList <>());
123
- problemsForKey .add ("Entries should be sorted alphabetically" );
107
+ if (!sortedValues .equals (classNames )) {
108
+ List <String > problemsForClassName = problems .computeIfAbsent (name , (k ) -> new ArrayList <>());
109
+ problemsForClassName .add ("Entries should be sorted alphabetically" );
124
110
}
125
111
}
126
112
File outputFile = getOutputDirectory ().file ("failure-report.txt" ).get ().getAsFile ();
@@ -130,6 +116,21 @@ private void check(File factoriesFile) {
130
116
}
131
117
}
132
118
119
+ private void collectProblems (Map <String , List <String >> problems , String key , List <String > classNames ) {
120
+ for (String className : classNames ) {
121
+ if (!find (className )) {
122
+ addNoFoundProblem (className , problems .computeIfAbsent (key , (k ) -> new ArrayList <>()));
123
+ }
124
+ }
125
+ }
126
+
127
+ private void addNoFoundProblem (String className , List <String > problemsForClassName ) {
128
+ String binaryName = binaryNameOf (className );
129
+ boolean foundBinaryForm = find (binaryName );
130
+ problemsForClassName .add (!foundBinaryForm ? "'%s' was not found" .formatted (className )
131
+ : "'%s' should be listed using its binary name '%s'" .formatted (className , binaryName ));
132
+ }
133
+
133
134
private boolean find (String className ) {
134
135
for (File root : this .classpath .getFiles ()) {
135
136
String classFilePath = className .replace ("." , "/" ) + ".class" ;
0 commit comments