Skip to content

Commit 6afa197

Browse files
thcedclaude
andcommitted
fix: Address SonarQube findings in Spec
Use LinkedHashMap.newLinkedHashMap(int) for properly-sized init and reuse the PARAMETER_REF_PREFIX constant in resolveParameterOrParse instead of duplicating the literal. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4b7e32a commit 6afa197

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • src/main/java/com/retailsvc/http/spec

src/main/java/com/retailsvc/http/spec/Spec.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ private static String computeBasePath(List<Server> servers) {
5757
}
5858

5959
private static <T> Map<String, T> indexByRef(Map<String, T> components, String prefix) {
60-
Map<String, T> out = new LinkedHashMap<>(components.size());
60+
Map<String, T> out = LinkedHashMap.newLinkedHashMap(components.size());
6161
for (var e : components.entrySet()) {
6262
out.put(prefix + e.getKey(), e.getValue());
6363
}
@@ -175,7 +175,7 @@ private static Parameter resolveParameterOrParse(
175175
Map<String, Object> raw, Map<String, Parameter> componentParameters) {
176176
String ref = (String) raw.get("$ref");
177177
if (ref != null) {
178-
String name = stripPrefix(ref, "#/components/parameters/");
178+
String name = stripPrefix(ref, PARAMETER_REF_PREFIX);
179179
Parameter p = componentParameters.get(name);
180180
if (p == null) {
181181
throw new IllegalArgumentException("unknown parameter ref: " + ref);

0 commit comments

Comments
 (0)