Skip to content

Commit

Permalink
apply changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
kebetsi committed Jun 13, 2024
1 parent 956ac5a commit bf5277a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions packages/jsts/src/analysis/analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ function analyzeFile(
...extendedMetrics,
};

const ast = serializeAst(sourceCode, filePath, input.skipAst);
if (ast) {
const ast = serializeAst(sourceCode, filePath);
if (!input.skipAst && ast) {
result.ast = ast;
}

Expand All @@ -108,8 +108,8 @@ function analyzeFile(
}
}

function serializeAst(sourceCode: SourceCode, filePath: string, skipAst = false) {
if (!isSupported(filePath) || skipAst) {
function serializeAst(sourceCode: SourceCode, filePath: string) {
if (!isSupported(filePath)) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*/
package org.sonar.plugins.javascript.bridge;

import static org.sonarsource.api.sonarlint.SonarLintSide.INSTANCE;

import java.io.IOException;
import java.util.List;
import javax.annotation.Nullable;
Expand All @@ -32,6 +30,8 @@
import org.sonar.plugins.javascript.bridge.protobuf.Node;
import org.sonarsource.api.sonarlint.SonarLintSide;

import static org.sonarsource.api.sonarlint.SonarLintSide.INSTANCE;

@ScannerSide
@SonarLintSide(lifespan = INSTANCE)
public interface BridgeServer extends Startable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected void analyzeFile(InputFile file, @Nullable List<String> tsConfigs, @Nu
LOG.debug("Analyzing file: {}", file.uri());
progressReport.nextFile(file.toString());
var fileContent = contextUtils.shouldSendFileContent(file) ? file.contents() : null;
var skipAst = consumers.getSize() < 1;
var skipAst = !consumers.hasConsumers();
var request = getJsAnalysisRequest(file, fileContent, tsProgram, tsConfigs, skipAst);

var response = isJavaScript(file)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void doneAnalysis() {
consumers.forEach(JsAnalysisConsumer::doneAnalysis);
}

public int getSize() {
return consumers.size();
public boolean hasConsumers() {
return ! consumers.isEmpty();
}
}

0 comments on commit bf5277a

Please sign in to comment.