Skip to content

Commit

Permalink
Fix code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
damien-urruty-sonarsource committed Jan 18, 2025
1 parent 456d8a0 commit 5f27374
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,31 +84,31 @@ public static ServerBuilder newSonarQubeServer() {
return newSonarQubeServer((Consumer<Server>) null);
}

public static ServerBuilder newSonarQubeServer(Consumer<Server> onStart) {
public static ServerBuilder newSonarQubeServer(@Nullable Consumer<Server> onStart) {
return newSonarQubeServer(onStart, "99.9");
}

public static ServerBuilder newSonarQubeServer(String version) {
return newSonarQubeServer(null, version);
}

public static ServerBuilder newSonarQubeServer(Consumer<Server> onStart, String version) {
public static ServerBuilder newSonarQubeServer(@Nullable Consumer<Server> onStart, String version) {
return new ServerBuilder(onStart, ServerKind.SONARQUBE, null, version);
}

public static ServerBuilder newSonarCloudServer() {
return newSonarCloudServer((Consumer<Server>) null);
}

public static ServerBuilder newSonarCloudServer(Consumer<Server> onStart) {
public static ServerBuilder newSonarCloudServer(@Nullable Consumer<Server> onStart) {
return newSonarCloudServer(onStart, "myOrganization");
}

public static ServerBuilder newSonarCloudServer(String organization) {
return newSonarCloudServer(null, organization);
}

public static ServerBuilder newSonarCloudServer(Consumer<Server> onStart, String organization) {
public static ServerBuilder newSonarCloudServer(@Nullable Consumer<Server> onStart, String organization) {
return new ServerBuilder(onStart, ServerKind.SONARCLOUD, organization, null);
}

Expand All @@ -133,7 +133,7 @@ public static class ServerBuilder {
private boolean smartNotificationsSupported;
private final List<String> tokensRegistered = new ArrayList<>();

public ServerBuilder(Consumer<Server> onStart, ServerKind serverKind, @Nullable String organizationKey, @Nullable String version) {
public ServerBuilder(@Nullable Consumer<Server> onStart, ServerKind serverKind, @Nullable String organizationKey, @Nullable String version) {
this.onStart = onStart;
this.serverKind = serverKind;
this.organizationKey = organizationKey;
Expand Down Expand Up @@ -250,7 +250,7 @@ public ServerProjectBuilder withEmptyBranch(String branchName) {
return this;
}

public ServerProjectBuilder withBranch(String branchName, UnaryOperator<ServerProjectBranchBuilder> branchBuilder) {
public ServerProjectBuilder withBranch(@Nullable String branchName, UnaryOperator<ServerProjectBranchBuilder> branchBuilder) {
var builder = new ServerProjectBranchBuilder();
this.branchesByName.put(branchName, branchBuilder.apply(builder));
return this;
Expand Down Expand Up @@ -304,7 +304,7 @@ public ServerProjectBranchBuilder withIssue(String issueKey) {
}

public ServerProjectBranchBuilder withIssue(String issueKey, String ruleKey, String message, String author, String filePath,
String status, String resolution, Instant creationDate, TextRange textRange) {
String status, @Nullable String resolution, Instant creationDate, TextRange textRange) {
this.issues.add(new ServerIssue(issueKey, ruleKey, message, author, filePath, status, resolution, creationDate, textRange, RuleType.BUG));
return this;
}
Expand Down Expand Up @@ -389,15 +389,15 @@ private ServerIssue(String issueKey, String ruleKey, String message, String auth
}

private ServerIssue(String issueKey, String ruleKey, String message, String author, String filePath, String status,
String resolution, Instant introductionDate, TextRange textRange, RuleType ruleType, String hash, Constants.Severity severity) {
@Nullable String resolution, Instant introductionDate, TextRange textRange, RuleType ruleType, String hash, Constants.Severity severity) {
this(issueKey, ruleKey, message, author, filePath, status, resolution, introductionDate, textRange, ruleType);
this.hash = hash;
this.severity = severity;
this.manualSeverity = true;
}

private ServerIssue(String issueKey, String ruleKey, String message, String author, String filePath, String status,
String resolution, Instant introductionDate, TextRange textRange, RuleType ruleType) {
@Nullable String resolution, Instant introductionDate, TextRange textRange, RuleType ruleType) {
this.issueKey = issueKey;
this.ruleKey = ruleKey;
this.message = message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.nio.file.Path;
import java.time.Instant;
import javax.annotation.Nullable;
import org.sonarsource.sonarlint.core.commons.HotspotReviewStatus;
import org.sonarsource.sonarlint.core.commons.IssueSeverity;
import org.sonarsource.sonarlint.core.commons.api.TextRangeWithHash;
Expand Down Expand Up @@ -92,7 +93,7 @@ public static class ServerHotspot {
public final VulnerabilityProbability vulnerabilityProbability;
public final String assignee;

public ServerHotspot(String key, String ruleKey, String message, String filePath, Instant introductionDate, IssueSeverity userSeverity,
public ServerHotspot(String key, String ruleKey, String message, String filePath, Instant introductionDate, @Nullable IssueSeverity userSeverity,
TextRangeWithHash textRangeWithHash, HotspotReviewStatus status, VulnerabilityProbability vulnerabilityProbability, String assignee) {
this.key = key;
this.ruleKey = ruleKey;
Expand Down

0 comments on commit 5f27374

Please sign in to comment.