Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ public String toString() {
StringWriter writer = new StringWriter();
XmlService.write(this, writer);
return writer.toString();
} catch (IOException e) {
} catch (IOException ignored) {
return toStringObject();
}
}
Expand All @@ -527,7 +527,7 @@ private String toStringObject() {
w = addToStringField(sb, value, o -> !o.isEmpty(), "value", w);
w = addToStringField(sb, attributes, o -> !o.isEmpty(), "attributes", w);
w = addToStringField(sb, children, o -> !o.isEmpty(), "children", w);
w = addToStringField(sb, inputLocation, Objects::nonNull, "inputLocation", w);
addToStringField(sb, inputLocation, Objects::nonNull, "inputLocation", w);
sb.append("]");
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private Settings readSettings(
return Settings.newInstance();
}

settings = interpolate(settings, request, problems);
settings = interpolate(settings, request);
settings = decrypt(settingsSource, settings, request, problems);

settingsValidator.validate(settings, isProjectSettings, problems);
Expand Down Expand Up @@ -228,8 +228,7 @@ private Settings readSettings(
return settings;
}

private Settings interpolate(
Settings settings, SettingsBuilderRequest request, ProblemCollector<BuilderProblem> problems) {
private Settings interpolate(Settings settings, SettingsBuilderRequest request) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once again, those are not unused variables. These are intermediary results.
Your refactoring hinders readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ppl wondering just like the SCA why its unused or ignored. Having it named accordingly or removed seems to be the best practise in order to turn the questions into answers, as history is mystery.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ppl wondering just like the SCA why its unused or ignored. Having it named accordingly or removed seems to be the best practise in order to turn the questions into answers, as history is mystery.

best practice is to understand what you are refactoring instead of blindly trusting tools/AI

Copy link
Contributor Author

@Pankraz76 Pankraz76 Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One could argue that "understanding" is a complex goal for this codebase. The presence of incorrect, ignored, and unused segments suggests that the original intent has become obscured over time. It's likely the logic was once valid, but that context has been lost.

The system continues to operate, but its current behavior appears disconnected from its actual purpose, seemingly functioning through emergent coincidence rather than by explicit design (no unused stuff dangling around).

In these situations, static code analysis becomes a valuable tool for reconstructing the rationale behind the code. As team members move on, institutional knowledge fades, and manual auditing does not scale effectively.

From my perspective, comprehending the full scope is challenging. For instance, the purpose of an unused field isn't clear, requiring me to hypothesize about its original function.

Ideally, code should narrate its purpose like a coherent story, with each line building upon the last. Gaps in this narrative—such as unused components or logical inconsistencies—highlight areas where the underlying purpose has been lost. While there may be valid, albeit hidden, reasons for these anomalies, the process of understanding involves methodically converting these open questions into resolved answers to piece together the complete picture.

UnaryOperator<String> src;
if (request.getInterpolationSource().isPresent()) {
src = request.getInterpolationSource().get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ public class DefaultModelBuilder implements ModelBuilder {
private static final String FILE = "file";
private static final String IMPORT = "import";
private static final String PARENT = "parent";
private static final String MODEL = "model";

private final Logger logger = LoggerFactory.getLogger(getClass());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
*/
package org.apache.maven.impl.model;

import java.util.Arrays;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
Expand All @@ -33,6 +31,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static java.util.Arrays.stream;
import static org.apache.maven.api.Constants.MAVEN_MODEL_PROCESSOR_POOLED_TYPES;

/**
* Default implementation of ModelObjectProcessor that provides memory optimization
* through object pooling and interning.
Expand Down Expand Up @@ -80,7 +81,11 @@ public <T> T process(T object) {
String simpleClassName = objectType.getSimpleName();

// Check if this object type should be pooled (read configuration dynamically)
if (!getPooledTypes(properties).contains(simpleClassName)) {
if (!stream(getProperty(MAVEN_MODEL_PROCESSOR_POOLED_TYPES, "Dependency")
.split(","))
.map(String::trim)
.collect(Collectors.toSet())
.contains(simpleClassName)) {
return object;
}

Expand All @@ -95,17 +100,6 @@ private String getProperty(String name, String defaultValue) {
return value instanceof String str ? str : defaultValue;
}

/**
* Gets the set of object types that should be pooled.
*/
private Set<String> getPooledTypes(Map<?, ?> properties) {
String pooledTypesProperty = getProperty(Constants.MAVEN_MODEL_PROCESSOR_POOLED_TYPES, "Dependency");
return Arrays.stream(pooledTypesProperty.split(","))
.map(String::trim)
.filter(s -> !s.isEmpty())
.collect(Collectors.toSet());
}

/**
* Creates a cache for the specified object type with the appropriate reference type.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public String toString() {
StringWriter writer = new StringWriter();
XmlService.write(this, writer);
return writer.toString();
} catch (IOException e) {
} catch (IOException ignored) {
return toStringObject();
}
}
Expand All @@ -310,7 +310,7 @@ public String toStringObject() {
w = addToStringField(sb, value, o -> !o.isEmpty(), "value", w);
w = addToStringField(sb, attributes, o -> !o.isEmpty(), "attributes", w);
w = addToStringField(sb, children, o -> !o.isEmpty(), "children", w);
w = addToStringField(sb, location, Objects::nonNull, "location", w);
addToStringField(sb, location, Objects::nonNull, "location", w);
sb.append("]");
return sb.toString();
}
Expand Down