fix: resolve 25 SonarQube code smells across 21 files
All checks were successful
CI / cleanup-branch (push) Has been skipped
CI / build (push) Successful in 1m2s
CI / docker (push) Successful in 45s
CI / deploy-feature (push) Has been skipped
CI / deploy (push) Successful in 38s

Remove unused fields (log, rbacService, roleRepository, jwt),
unused variables (agentTps, routeKeys, updated), unused imports
(HttpHeaders, JdbcTemplate). Rename restricted identifier 'record'
to 'auditRecord'/'event'. Return empty collections instead of null.
Replace .collect(Collectors.toList()) with .toList(). Simplify
conditional return in BootstrapTokenValidator.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-04 09:36:13 +02:00
parent 633a61d89d
commit b04b12220b
21 changed files with 42 additions and 90 deletions

View File

@@ -5,7 +5,7 @@ import java.util.List;
public interface AuditRepository {
void insert(AuditRecord record);
void insert(AuditRecord auditRecord);
record AuditQuery(
String username,

View File

@@ -30,9 +30,9 @@ public class AuditService {
HttpServletRequest request) {
String ip = request != null ? request.getRemoteAddr() : null;
String userAgent = request != null ? request.getHeader("User-Agent") : null;
AuditRecord record = AuditRecord.create(username, action, category, target, detail, result, ip, userAgent);
AuditRecord auditRecord = AuditRecord.create(username, action, category, target, detail, result, ip, userAgent);
repository.insert(record);
repository.insert(auditRecord);
if (request != null) {
request.setAttribute("audit.logged", true);

View File

@@ -13,7 +13,7 @@ import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.stream.Collectors;
/**
* In-memory agent registry managing agent lifecycle, heartbeats, and commands.
@@ -53,7 +53,7 @@ public class AgentRegistryService {
List.copyOf(routeIds), Map.copyOf(capabilities),
AgentState.LIVE, now, now, null);
AgentInfo result = agents.compute(id, (key, existing) -> {
return agents.compute(id, (key, existing) -> {
if (existing != null) {
// Re-registration: update metadata, reset to LIVE
log.info("Agent {} re-registering (was {})", id, existing.state());
@@ -67,8 +67,6 @@ public class AgentRegistryService {
log.info("Agent {} registered (name={}, application={})", id, name, application);
return newAgent;
});
return result;
}
/**
@@ -196,7 +194,7 @@ public class AgentRegistryService {
public List<AgentInfo> findByState(AgentState state) {
return agents.values().stream()
.filter(a -> a.state() == state)
.collect(Collectors.toList());
.toList();
}
/**
@@ -205,7 +203,7 @@ public class AgentRegistryService {
public List<AgentInfo> findByApplication(String application) {
return agents.values().stream()
.filter(a -> application.equals(a.applicationId()))
.collect(Collectors.toList());
.toList();
}
/**
@@ -276,7 +274,7 @@ public class AgentRegistryService {
}
return queue.stream()
.filter(cmd -> cmd.status() == CommandStatus.PENDING)
.collect(Collectors.toList());
.toList();
}
/**

View File

@@ -29,7 +29,7 @@ public class DetailService {
// Prefer the raw processor tree (faithful to agent data) over
// flat-record reconstruction (which loses iteration context).
List<ProcessorNode> processors = parseProcessorsJson(exec.processorsJson());
if (processors == null) {
if (processors.isEmpty()) {
// Fallback for executions ingested before processors_json was added
List<ProcessorRecord> records = executionStore.findProcessors(executionId);
processors = buildTree(records);
@@ -78,12 +78,12 @@ public class DetailService {
/** Parse the raw processor tree JSON stored alongside the execution. */
private List<ProcessorNode> parseProcessorsJson(String json) {
if (json == null || json.isBlank()) return null;
if (json == null || json.isBlank()) return List.of();
try {
List<ProcessorExecution> executions = JSON.readValue(json, PROCESSOR_EXEC_LIST);
return convertProcessors(executions);
} catch (Exception e) {
return null;
return List.of();
}
}