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

Do not serialize the AST if the skipAst flag is set #4738

Merged
Merged
Changes from 1 commit
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
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);
if (!input.skipAst && ast) {
const ast = serializeAst(sourceCode, filePath, input.skipAst);
if (ast) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oups, that was my initial suggestion that led to this imprecision...
Nice catch anyway.
I still think it feels strange to pass this argument. What about:

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both are not great. I'll add your suggestion.

result.ast = ast;
}

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

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

Expand Down
Loading