fix: Address sonarcloud issues with the format strings.
@@ -44,23 +44,27 @@ public class RapidScanDetectResult implements DetectResult {
String policyGroupName = RapidScanDetailGroup.POLICY.getDisplayName();
String securityGroupName = RapidScanDetailGroup.SECURITY.getDisplayName();
String licenseGroupName = RapidScanDetailGroup.LICENSE.getDisplayName();
+ String errorCountFormat = "\t%s Errors = %d";
+ String warningCountFormat = "\t%s Warnings = %d";
+ String indentedMessageFormat = "\t\t%s";
+
List<String> resultMessages = new LinkedList<>();
resultMessages.add("");
- resultMessages.add(String.format("\t%s Errors = %d", policyGroupName, summary.getPolicyErrorCount()));
- resultMessages.add(String.format("\t%s Warnings = %d", policyGroupName, summary.getPolicyWarningCount()));
- resultMessages.add(String.format("\t%s Errors = %d", securityGroupName, summary.getSecurityErrorCount()));
- resultMessages.add(String.format("\t%s Warnings = %d", securityGroupName, summary.getSecurityWarningCount()));
- resultMessages.add(String.format("\t%s Errors = %d", licenseGroupName, summary.getLicenseErrorCount()));
- resultMessages.add(String.format("\t%s Warnings = %d", licenseGroupName, summary.getLicenseWarningCount()));
+ resultMessages.add(String.format(errorCountFormat, policyGroupName, summary.getPolicyErrorCount()));
+ resultMessages.add(String.format(warningCountFormat, policyGroupName, summary.getPolicyWarningCount()));
+ resultMessages.add(String.format(errorCountFormat, securityGroupName, summary.getSecurityErrorCount()));
+ resultMessages.add(String.format(warningCountFormat, securityGroupName, summary.getSecurityWarningCount()));
+ resultMessages.add(String.format(errorCountFormat, licenseGroupName, summary.getLicenseErrorCount()));
+ resultMessages.add(String.format(warningCountFormat, licenseGroupName, summary.getLicenseWarningCount()));
resultMessages.add("");
resultMessages.add("\tPolicies Violated:");
- summary.getPolicyViolationNames().forEach(policy -> resultMessages.add(String.format("\t\t%s", policy)));
+ summary.getPolicyViolationNames().forEach(policy -> resultMessages.add(String.format(indentedMessageFormat, policy)));
resultMessages.add("");
resultMessages.add("\tComponents with Policy Violations:");
- summary.getComponentsViolatingPolicy().forEach(component -> resultMessages.add(String.format("\t\t%s", component)));
+ summary.getComponentsViolatingPolicy().forEach(component -> resultMessages.add(String.format(indentedMessageFormat, component)));
resultMessages.add("");
resultMessages.add("\tComponents with Policy Violation Warnings:");
- summary.getComponentsViolatingPolicyWarnings().forEach(component -> resultMessages.add(String.format("\t\t%s", component)));
+ summary.getComponentsViolatingPolicyWarnings().forEach(component -> resultMessages.add(String.format(indentedMessageFormat, component)));
return resultMessages;
}
}
