Skip to content
This repository was archived by the owner on Jan 20, 2026. It is now read-only.

Commit af45882

Browse files
committed
Various minor code simplifications and unifications
- Make getters private and inline getters and fields where suitable - Remove unused/not effective code-paths - Unify redundant code
1 parent b224f0b commit af45882

9 files changed

Lines changed: 192 additions & 634 deletions

File tree

bundles/org.eclipse.build.tools/src/org/eclipse/releng/generators/TestResultsGenerator.java

Lines changed: 36 additions & 199 deletions
Large diffs are not rendered by default.

bundles/org.eclipse.releng.build.tools.comparator/src/org/eclipse/releng/build/tools/comparator/Extractor.java

Lines changed: 40 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -53,42 +53,22 @@ public void addReason(final String reason) {
5353
}
5454
}
5555

56-
private final String debugFilename = "mb060_run-maven-build_output.txt";
57-
private final String outputFilenameFull = "buildtimeComparatorFull.log.txt";
58-
private final String outputFilenameSign = "buildtimeComparatorSignatureOnly.log.txt";
59-
private final String outputFilenameSignPlusInnerJar = "buildtimeComparatorSignatureOnlyWithInnerJar.log.txt";
60-
private final String outputFilenameDoc = "buildtimeComparatorDocBundle.log.txt";
61-
private final String outputFilenameOther = "buildtimeComparatorUnanticipated.log.txt";
62-
private final String outputFilenamejdtCore = "buildtimeComparatorJDTCore.log.txt";
63-
private final String buildlogsDirectory = "buildlogs";
64-
private final String comparatorLogsDirectory = "comparatorlogs";
56+
private static final String BUILD_LOGS_DIRECTORY = "buildlogs";
57+
private static final String COMPARATOR_LOGS_DIRECTORY = "comparatorlogs";
6558
private String comparatorRepo = "comparatorRepo";
6659
private String buildDirectory;
67-
private String inputFilename;
68-
private String outputFilenameFullLog;
69-
private String outputFilenameSignLog;
70-
private String outputFilenameDocLog;
71-
private String outputFilenameOtherLog;
72-
private String outputFilenameSignPlusInnerJarLog;
73-
private String outputFilenamejdtCoreLog;
74-
private final String mainregexPattern = "^\\[WARNING\\].*eclipse.platform.releng.aggregator/(.*): baseline and build artifacts have same version but different contents";
75-
private final Pattern mainPattern = Pattern.compile(mainregexPattern);
76-
private final String noclassifierregexPattern = "^.*no-classifier:.*$";
77-
private final Pattern noclassifierPattern = Pattern.compile(noclassifierregexPattern);
78-
private final String classifier_sourcesregexPattern = "^.*classifier-sources:.*$";
79-
private final Pattern classifier_sourcesPattern = Pattern.compile(classifier_sourcesregexPattern);
80-
private final String classifier_sourcesfeatureregexPattern = "^.*classifier-sources-feature:.*$";
81-
private final Pattern classifier_sourcesfeaturePattern = Pattern.compile(classifier_sourcesfeatureregexPattern);
82-
83-
private final String sign1regexPattern = "^.*META-INF/(ECLIPSE_|CODESIGN).RSA.*$";
84-
private final Pattern sign1Pattern = Pattern.compile(sign1regexPattern);
85-
private final String sign2regexPattern = "^.*META-INF/(ECLIPSE_|CODESIGN).SF.*$";
86-
private final Pattern sign2Pattern = Pattern.compile(sign2regexPattern);
87-
private final String docNameregexPattern = "^.*eclipse\\.platform\\.common.*\\.doc\\..*$";
88-
private final Pattern docNamePattern = Pattern.compile(docNameregexPattern);
60+
private static final Pattern MAIN_PATTERN = Pattern.compile(
61+
"^\\[WARNING\\].*eclipse.platform.releng.aggregator/(.*): baseline and build artifacts have same version but different contents");
62+
private static final Pattern NO_CLASSIFIER_PATTERN = Pattern.compile("^.*no-classifier:.*$");
63+
private static final Pattern CLASSIFIER_SOURCES_PATTERN = Pattern.compile("^.*classifier-sources:.*$");
64+
private static final Pattern CLASSIFIER_SOURCES_FEATURE_PATTERN = Pattern
65+
.compile("^.*classifier-sources-feature:.*$");
66+
67+
private static final Pattern SIGN1_PATTERN = Pattern.compile("^.*META-INF/(ECLIPSE_|CODESIGN).RSA.*$");
68+
private static final Pattern SIGN2_PATTERN = Pattern.compile("^.*META-INF/(ECLIPSE_|CODESIGN).SF.*$");
69+
private static final Pattern DOC_NAME_PATTERN = Pattern.compile("^.*eclipse\\.platform\\.common.*\\.doc\\..*$");
8970
// jar pattern added for bug 416701
90-
private final String jarregexPattern = "^.*\\.jar.*$";
91-
private final Pattern jarPattern = Pattern.compile(jarregexPattern);
71+
private final Pattern JAR_PATTERN = Pattern.compile("^.*\\.jar.*$");
9272
private int count;
9373
private int countSign;
9474
private int countDoc;
@@ -99,7 +79,7 @@ public void addReason(final String reason) {
9979
private boolean docItem(final LogEntry newEntry) {
10080
boolean result = false;
10181
final String name = newEntry.name();
102-
final Matcher matcher = docNamePattern.matcher(name);
82+
final Matcher matcher = DOC_NAME_PATTERN.matcher(name);
10383
if (matcher.matches()) {
10484
result = true;
10585
}
@@ -115,64 +95,43 @@ public String getBuildDirectory() {
11595
}
11696

11797
private String getInputFilename() {
118-
if (inputFilename == null) {
119-
inputFilename = getBuildDirectory() + "/" + buildlogsDirectory + "/" + debugFilename;
120-
}
121-
return inputFilename;
98+
return getBuildDirectory() + "/" + BUILD_LOGS_DIRECTORY + "/" + "mb060_run-maven-build_output.txt";
12299
}
123100

124101
private String getOutputFilenameDoc() {
125-
if (outputFilenameDocLog == null) {
126-
outputFilenameDocLog = getBuildDirectory() + "/" + buildlogsDirectory + "/" + comparatorLogsDirectory + "/"
127-
+ outputFilenameDoc;
128-
}
129-
return outputFilenameDocLog;
102+
return getBuildDirectory() + "/" + BUILD_LOGS_DIRECTORY + "/" + COMPARATOR_LOGS_DIRECTORY + "/"
103+
+ "buildtimeComparatorDocBundle.log.txt";
130104
}
131105

132106
private String getOutputFilenameFull() {
133-
if (outputFilenameFullLog == null) {
134-
outputFilenameFullLog = getBuildDirectory() + "/" + buildlogsDirectory + "/" + comparatorLogsDirectory + "/"
135-
+ outputFilenameFull;
136-
}
137-
return outputFilenameFullLog;
107+
return getBuildDirectory() + "/" + BUILD_LOGS_DIRECTORY + "/" + COMPARATOR_LOGS_DIRECTORY + "/"
108+
+ "buildtimeComparatorFull.log.txt";
138109
}
139110

140111
private String getOutputFilenameOther() {
141-
if (outputFilenameOtherLog == null) {
142-
outputFilenameOtherLog = getBuildDirectory() + "/" + buildlogsDirectory + "/" + comparatorLogsDirectory
143-
+ "/" + outputFilenameOther;
144-
}
145-
return outputFilenameOtherLog;
112+
return getBuildDirectory() + "/" + BUILD_LOGS_DIRECTORY + "/" + COMPARATOR_LOGS_DIRECTORY + "/"
113+
+ "buildtimeComparatorUnanticipated.log.txt";
146114
}
147115

148116
private String getOutputFilenameSign() {
149-
if (outputFilenameSignLog == null) {
150-
outputFilenameSignLog = getBuildDirectory() + "/" + buildlogsDirectory + "/" + comparatorLogsDirectory + "/"
151-
+ outputFilenameSign;
152-
}
153-
return outputFilenameSignLog;
117+
return getBuildDirectory() + "/" + BUILD_LOGS_DIRECTORY + "/" + COMPARATOR_LOGS_DIRECTORY + "/"
118+
+ "buildtimeComparatorSignatureOnly.log.txt";
154119
}
155120

156121
private String getOutputFilenameSignWithInnerJar() {
157-
if (outputFilenameSignPlusInnerJarLog == null) {
158-
outputFilenameSignPlusInnerJarLog = getBuildDirectory() + "/" + buildlogsDirectory + "/"
159-
+ comparatorLogsDirectory + "/" + outputFilenameSignPlusInnerJar;
160-
}
161-
return outputFilenameSignPlusInnerJarLog;
122+
return getBuildDirectory() + "/" + BUILD_LOGS_DIRECTORY + "/" + COMPARATOR_LOGS_DIRECTORY + "/"
123+
+ "buildtimeComparatorSignatureOnlyWithInnerJar.log.txt";
162124
}
163125

164126
private String getOutputFilenameJDTCore() {
165-
if (outputFilenamejdtCoreLog == null) {
166-
outputFilenamejdtCoreLog = getBuildDirectory() + "/" + buildlogsDirectory + "/" + comparatorLogsDirectory
167-
+ "/" + outputFilenamejdtCore;
168-
}
169-
return outputFilenamejdtCoreLog;
127+
return getBuildDirectory() + "/" + BUILD_LOGS_DIRECTORY + "/" + COMPARATOR_LOGS_DIRECTORY + "/"
128+
+ "buildtimeComparatorJDTCore.log.txt";
170129
}
171130

172131
public void processBuildfile() throws IOException {
173132

174133
// Make sure directory exists
175-
File outputDir = new File(getBuildDirectory() + "/" + buildlogsDirectory, comparatorLogsDirectory);
134+
File outputDir = new File(getBuildDirectory() + "/" + BUILD_LOGS_DIRECTORY, COMPARATOR_LOGS_DIRECTORY);
176135
if (!outputDir.exists()) {
177136
outputDir.mkdirs();
178137
}
@@ -215,7 +174,7 @@ public void processBuildfile() throws IOException {
215174
while (inputLine != null) {
216175
inputLine = input.readLine();
217176
if (inputLine != null) {
218-
final Matcher matcher = mainPattern.matcher(inputLine);
177+
final Matcher matcher = MAIN_PATTERN.matcher(inputLine);
219178
if (matcher.matches()) {
220179

221180
final LogEntry newEntry = LogEntry.create(matcher.group(1));
@@ -284,11 +243,11 @@ private boolean pureSignature(final LogEntry newEntry) {
284243
boolean result = true;
285244
final List<String> reasons = newEntry.reasons();
286245
for (final String reason : reasons) {
287-
final Matcher matcher1 = noclassifierPattern.matcher(reason);
288-
final Matcher matcher2 = classifier_sourcesPattern.matcher(reason);
289-
final Matcher matcher3 = classifier_sourcesfeaturePattern.matcher(reason);
290-
final Matcher matcher4 = sign1Pattern.matcher(reason);
291-
final Matcher matcher5 = sign2Pattern.matcher(reason);
246+
final Matcher matcher1 = NO_CLASSIFIER_PATTERN.matcher(reason);
247+
final Matcher matcher2 = CLASSIFIER_SOURCES_PATTERN.matcher(reason);
248+
final Matcher matcher3 = CLASSIFIER_SOURCES_FEATURE_PATTERN.matcher(reason);
249+
final Matcher matcher4 = SIGN1_PATTERN.matcher(reason);
250+
final Matcher matcher5 = SIGN2_PATTERN.matcher(reason);
292251

293252
if (matcher1.matches() || matcher2.matches() || matcher3.matches() || matcher4.matches()
294253
|| matcher5.matches()) {
@@ -309,12 +268,12 @@ private boolean pureSignaturePlusInnerJar(final LogEntry newEntry) {
309268
boolean result = true;
310269
final List<String> reasons = newEntry.reasons();
311270
for (final String reason : reasons) {
312-
final Matcher matcher1 = noclassifierPattern.matcher(reason);
313-
final Matcher matcher2 = classifier_sourcesPattern.matcher(reason);
314-
final Matcher matcher3 = classifier_sourcesfeaturePattern.matcher(reason);
315-
final Matcher matcher4 = sign1Pattern.matcher(reason);
316-
final Matcher matcher5 = sign2Pattern.matcher(reason);
317-
final Matcher matcher6 = jarPattern.matcher(reason);
271+
final Matcher matcher1 = NO_CLASSIFIER_PATTERN.matcher(reason);
272+
final Matcher matcher2 = CLASSIFIER_SOURCES_PATTERN.matcher(reason);
273+
final Matcher matcher3 = CLASSIFIER_SOURCES_FEATURE_PATTERN.matcher(reason);
274+
final Matcher matcher4 = SIGN1_PATTERN.matcher(reason);
275+
final Matcher matcher5 = SIGN2_PATTERN.matcher(reason);
276+
final Matcher matcher6 = JAR_PATTERN.matcher(reason);
318277

319278
if (matcher1.matches() || matcher2.matches() || matcher3.matches() || matcher4.matches()
320279
|| matcher5.matches() || matcher6.matches()) {

bundles/org.eclipse.releng.build.tools.convert/src/org/eclipse/releng/build/tools/convert/ant/Converter.java

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2024 IBM Corporation and others. All rights reserved.
3-
* This program and the accompanying materials are made available under the
4-
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
5-
* and is available at http://www.eclipse.org/legal/epl-v10.html
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
63
*
7-
* Contributors: IBM Corporation - initial API and implementation
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* IBM Corporation - initial API and implementation
813
*******************************************************************************/
914

1015
package org.eclipse.releng.build.tools.convert.ant;
@@ -20,6 +25,8 @@
2025
import javax.xml.parsers.ParserConfigurationException;
2126

2227
import org.eclipse.releng.build.tools.convert.dom.AbstractDOMConverter;
28+
import org.eclipse.releng.build.tools.convert.dom.DOMHtmlConverter;
29+
import org.eclipse.releng.build.tools.convert.dom.DOMTxtConverter;
2330
import org.eclipse.releng.build.tools.convert.dom.IDOMConverter;
2431
import org.eclipse.releng.build.tools.convert.dom.LogDocumentNode;
2532
import org.eclipse.releng.build.tools.convert.dom.LogDocumentNode.ProblemSummaryNode;
@@ -108,7 +115,7 @@ public void configure(final String[] args) {
108115

109116
// set default options
110117
options.put(ENABLE_VALIDATION, "false"); //$NON-NLS-1$
111-
int converterID = ConverterFactory.HTML;
118+
int converterID = Converter.HTML;
112119

113120
final int argCount = args.length;
114121
int index = 0;
@@ -132,7 +139,7 @@ public void configure(final String[] args) {
132139
break;
133140
case OUTPUT_FILE_MODE:
134141
if (currentArg.toLowerCase().endsWith(TXT_EXTENSION)) {
135-
converterID = ConverterFactory.TXT;
142+
converterID = Converter.TXT;
136143
}
137144
options.put(OUTPUT_FILE_NAME, currentArg);
138145
mode = DEFAULT_MODE;
@@ -182,21 +189,28 @@ public void configure(final String[] args) {
182189
}
183190

184191
private void dump(final LogDocumentNode documentNode) {
185-
final IDOMConverter converter = ConverterFactory.createDOMConverter(Integer.parseInt(options
186-
.get(Converter.CONVERTER_ID)));
192+
IDOMConverter converter = createDOMConverter(Integer.parseInt(options.get(Converter.CONVERTER_ID)));
187193
converter.dump(CURRENT_FORMAT_VERSION, options, documentNode);
188194
}
189195

196+
public static final int TXT = 0;
197+
public static final int HTML = 1;
198+
199+
public static IDOMConverter createDOMConverter(final int id) {
200+
return switch (id) {
201+
case TXT -> new DOMTxtConverter();
202+
case HTML -> new DOMHtmlConverter();
203+
default -> new DOMHtmlConverter();
204+
};
205+
}
206+
190207
private String extractNameFrom(final String inputFileName) {
191208
final int index = inputFileName.lastIndexOf('.');
192-
switch (Integer.parseInt(options.get(Converter.CONVERTER_ID))) {
193-
case ConverterFactory.TXT:
194-
return inputFileName.substring(0, index) + TXT_EXTENSION;
195-
case ConverterFactory.HTML:
196-
return inputFileName.substring(0, index) + HTML_EXTENSION;
197-
default:
198-
return inputFileName.substring(0, index) + HTML_EXTENSION;
199-
}
209+
return switch (Integer.parseInt(options.get(Converter.CONVERTER_ID))) {
210+
case Converter.TXT -> inputFileName.substring(0, index) + TXT_EXTENSION;
211+
case Converter.HTML -> inputFileName.substring(0, index) + HTML_EXTENSION;
212+
default -> inputFileName.substring(0, index) + HTML_EXTENSION;
213+
};
200214
}
201215

202216
public void parse2() throws ParserConfigurationException {

bundles/org.eclipse.releng.build.tools.convert/src/org/eclipse/releng/build/tools/convert/ant/ConverterFactory.java

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)