Skip to content

Commit

Permalink
fix after formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
saberduck committed May 23, 2024
1 parent bfff32e commit 450ffd3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ record AnalysisResponse(@Nullable ParsingError parsingError, List<Issue> issues,
public AnalysisResponse() {
this(null, List.of(), List.of(), List.of(), new Metrics(), List.of(), List.of());
}

public AnalysisResponse(@Nullable ParsingError parsingError, @Nullable List<Issue> issues, @Nullable List<Highlight> highlights,
@Nullable List<HighlightedSymbol> highlightedSymbols, @Nullable Metrics metrics, @Nullable List<CpdToken> cpdTokens, List<String> ucfgPaths) {
this.parsingError = parsingError;
this.issues = issues != null ? issues : List.of();
this.highlights = highlights != null ? highlights : List.of();
this.highlightedSymbols = highlightedSymbols != null ? highlightedSymbols : List.of();
this.metrics = metrics != null ? metrics : new Metrics();
this.cpdTokens = cpdTokens != null ? cpdTokens : List.of();
this.ucfgPaths = ucfgPaths;
}
}

record ParsingError(String message, Integer line, ParsingErrorCode code) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.sonar.plugins.javascript.bridge.BridgeServer.Highlight;
import org.sonar.plugins.javascript.bridge.BridgeServer.HighlightedSymbol;
import org.sonar.plugins.javascript.bridge.BridgeServer.Location;
import org.sonar.plugins.javascript.bridge.BridgeServer.Metrics;

class AnalysisProcessorTest {

Expand All @@ -41,7 +42,7 @@ void should_not_fail_when_invalid_range() {
.build();
var location = new Location(1, 2, 1, 1); // invalid range startCol > endCol
var highlight = new Highlight(location, "");
var response = new AnalysisResponse(null, List.of(), List.of(highlight), List.of(), null, null, null);
var response = new AnalysisResponse(null, List.of(), List.of(highlight), List.of(), new Metrics(), List.of(), List.of());
processor.processResponse(context, mock(JsTsChecks.class), file, response);
assertThat(logTester.logs())
.contains("Failed to save highlight in " + file.uri() + " at 1:2-1:1");
Expand All @@ -59,14 +60,14 @@ void should_not_fail_when_invalid_symbol() {
.build();
var declaration = new Location(1, 2, 1, 1); // invalid range startCol > endCol
var symbol = new HighlightedSymbol(declaration, List.of());
var response = new AnalysisResponse(null, List.of(), null, List.of(symbol), null, null, null);
var response = new AnalysisResponse(null, List.of(), List.of(), List.of(symbol), new Metrics(), List.of(), List.of());
processor.processResponse(context, mock(JsTsChecks.class), file, response);
assertThat(logTester.logs())
.contains("Failed to create symbol declaration in " + file.uri() + " at 1:2-1:1");

context = SensorContextTester.create(baseDir);
symbol = new HighlightedSymbol(new Location(1, 1, 1, 2), List.of(new Location(2, 2, 2, 1)));
response = new AnalysisResponse(null, List.of(), null, List.of(symbol), null, null, null);
response = new AnalysisResponse(null, List.of(), List.of(), List.of(symbol), new Metrics(), List.of(), List.of());
processor.processResponse(context, mock(JsTsChecks.class), file, response);
assertThat(logTester.logs())
.contains("Failed to create symbol reference in " + file.uri() + " at 2:2-2:1");
Expand All @@ -84,7 +85,7 @@ void should_not_fail_when_invalid_cpd() {
.build();
var location = new Location(1, 2, 1, 1); // invalid range startCol > endCol
var cpd = new CpdToken(location, "img");
var response = new AnalysisResponse(null, List.of(), null, null, null, List.of(cpd), null);
var response = new AnalysisResponse(null, List.of(), List.of(), List.of(), new Metrics(), List.of(cpd), List.of());
processor.processResponse(context, mock(JsTsChecks.class), file, response);
assertThat(context.cpdTokens(file.key())).isNull();
assertThat(logTester.logs())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ DefaultSensorContext createContext(Version version) {
void test() {
var context = createContext(Version.create(6, 3));

var response = new AnalysisResponse(null, List.of(issueWithQuickFix()), null, null, null, null, null);
var response = new AnalysisResponse(null, List.of(issueWithQuickFix()), List.of(), List.of(), new Metrics(), List.of(), List.of());

var issueCaptor = ArgumentCaptor.forClass(DefaultSonarLintIssue.class);
doNothing().when(sensorStorage).store(issueCaptor.capture());
Expand Down Expand Up @@ -135,7 +135,7 @@ static Issue issueWithQuickFix() {
@Test
void test_old_version() {
var context = createContext(Version.create(6, 2));
var response = new AnalysisResponse(null, List.of(issueWithQuickFix()), null, null, null, null, null);
var response = new AnalysisResponse(null, List.of(issueWithQuickFix()), List.of(), List.of(), new Metrics(), List.of(), List.of());

var issueCaptor = ArgumentCaptor.forClass(DefaultSonarLintIssue.class);
doNothing().when(sensorStorage).store(issueCaptor.capture());
Expand All @@ -147,8 +147,8 @@ void test_old_version() {
@Test
void test_null() {
var context = createContext(Version.create(6, 3));
var issue = new Issue(1, 1, 1, 1,"", "no-extra-semi", List.of(), 1.0, null);
var response = new AnalysisResponse(null, List.of(issue), null, null, new Metrics(), null, null);
var issue = new Issue(1, 1, 1, 1,"", "no-extra-semi", List.of(), 1.0, List.of());
var response = new AnalysisResponse(null, List.of(issue), List.of(), List.of(), new Metrics(), List.of(), List.of());

var issueCaptor = ArgumentCaptor.forClass(DefaultSonarLintIssue.class);
doNothing().when(sensorStorage).store(issueCaptor.capture());
Expand Down

0 comments on commit 450ffd3

Please sign in to comment.