Skip to content

Commit 4553f99

Browse files
committed
fix: Address Sonar S1192 and S107 in security additions
1 parent 91de0e9 commit 4553f99

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/main/java/com/retailsvc/http/Request.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ public Request(
6969
* @param headerLookup first-value, case-insensitive header lookup; returns {@code null} if absent
7070
* @param principals principals stashed by the security filter, keyed by scheme name
7171
*/
72+
// Request is transport-neutral and assembled from primitives at the adapter boundary; collapsing
73+
// these into a holder type would just move the parameter count one level out without simplifying
74+
// the call site, so the 8-arg constructor is preferred over the rule's 7-param limit.
75+
@SuppressWarnings("java:S107")
7276
public Request(
7377
byte[] body,
7478
Object parsed,

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public record Spec(
3333
List<SecurityRequirement> security) {
3434

3535
private static final String SCHEMA_KEY = "schema";
36+
private static final String SECURITY_KEY = "security";
3637
private static final String SCHEMA_REF_PREFIX = "#/components/schemas/";
3738
private static final String PARAMETER_REF_PREFIX = "#/components/parameters/";
3839

@@ -151,7 +152,7 @@ public static Spec from(Map<String, Object> raw) {
151152
entry.getKey(), SecuritySchemeParser.parse((Map<String, Object>) entry.getValue()));
152153
}
153154
List<SecurityRequirement> rootSecurity =
154-
SecuritySchemeParser.parseRequirements((List<Object>) raw.get("security"));
155+
SecuritySchemeParser.parseRequirements((List<Object>) raw.get(SECURITY_KEY));
155156
return new Spec(
156157
openapi,
157158
info,
@@ -286,9 +287,9 @@ private static Operation parseOperation(
286287
Map<String, Response> responses =
287288
parseResponses((Map<String, Object>) raw.getOrDefault("responses", Map.of()));
288289
Optional<List<SecurityRequirement>> opSecurity =
289-
raw.containsKey("security")
290+
raw.containsKey(SECURITY_KEY)
290291
? Optional.of(
291-
SecuritySchemeParser.parseRequirements((List<Object>) raw.get("security")))
292+
SecuritySchemeParser.parseRequirements((List<Object>) raw.get(SECURITY_KEY)))
292293
: Optional.empty();
293294
return new Operation(
294295
opId, method, path, body, params, responses, extractExtensions(raw), opSecurity);

0 commit comments

Comments
 (0)