Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addressing most severe sonar complaints #878

Merged
merged 2 commits into from
Mar 13, 2023
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:

## Retrieve the `target` directory from the build job
- name: Fetch Build Result
uses: actions/github-script@v3.1.0
uses: actions/github-script@v6
with:
script: |
var artifacts = await github.actions.listWorkflowRunArtifacts({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.stream.Stream;

@ApplicationScoped
@SuppressWarnings("java:S4790") // ignore weak hashing
public class SecuritySecretManager {

public static final String SASL_PRINCIPAL ="sasl.principal";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,14 @@ private List<String> getStrimziVersions(Subscription subscription) {
.withName(subscription.getSpec().getName())
.get();

List<String> strimziVersions = this.strimziVersionsFromPackageManifest(packageManifest);
return strimziVersions;
}

private List<String> strimziVersionsFromPackageManifest(PackageManifest packageManifest) {
if (packageManifest == null) {
return Collections.emptyList();
}
// avoiding the nullability of one of the status fields along the chain due to Kubernetes not updating
// the PackageManifest on time when the fleetshard operator starts to take care of the approval
// This way avoid a race condition raising an NPE
String strimziVersionsJson =
Optional.ofNullable(packageManifest)
Optional.of(packageManifest)
.map(PackageManifest::getStatus)
.map(PackageManifestStatus::getChannels)
.map(packageChannels -> !packageChannels.isEmpty() ? packageChannels.get(0) : null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class MockManagedKafkaFactory {
@Scheduled(every = "{mock.factory.interval}")
void loop() {

@SuppressWarnings("java:S2245")
Random random = new Random(System.currentTimeMillis());
log.info("Mock ManagedKafka Factory:: Running Simulation");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
*/
@ApplicationScoped
@DefaultBean
@SuppressWarnings("java:S4790") // ignore weak hashing
public class KafkaCluster extends AbstractKafkaCluster {

static final String KAS_FLEETSHARD_MEDIUM_PRIORITY = "kas-fleetshard-medium";
Expand Down
1 change: 1 addition & 0 deletions sync/src/main/java/org/bf2/sync/SecretManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.stream.Collectors;

@ApplicationScoped
@SuppressWarnings("java:S4790") // ignore weak hashing
public class SecretManager {

private static final String ENDPOINT_TLS_CRT = "endpoint.tls.crt";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ void loop() {
return;
}

@SuppressWarnings("java:S2245")
Random random = new Random(System.currentTimeMillis());
log.info("control plane:: Running Simulation");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
@Startup
@ApplicationScoped
public class SecretRestartHandler {
@SuppressWarnings("java:S5852")
private static final Pattern SECRET_PATTERN = Pattern.compile(".*\\[secret=[^/]*/[^/]*/([^/]*)/([^/]*)\\]");

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,11 @@ public static String getLatestAvailableKafkaVersion(Supplier<ManagedKafkaAgentSt
ComparableVersion aVersion = new ComparableVersion(a);
ComparableVersion bVersion = new ComparableVersion(b);
return aVersion.compareTo(bVersion);
}).reduce((first, second) -> second).get();
}).reduce((first, second) -> second).orElseThrow();
}

public static Stream<String> sortedStrimziVersion(Stream<String> versions) {
@SuppressWarnings("java:S5852")
Pattern pattern = Pattern.compile("^.*\\.v(?<version>[0-9]+\\.[0-9]+\\.[0-9]+[-0-9]*)$");
return Objects.requireNonNull(versions.sorted((a, b) -> {
Matcher aMatcher = pattern.matcher(a);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public String getTrustStoreBase64() {

}

@SuppressWarnings({"java:S2068", "java:S6437"})
public static final String TRUSTSTORE_PASSWORD = "changeit";

public static void main(String[] args) throws Exception {
Expand Down