From c480fed3f75436355b53ccbd7837b53066d659fc Mon Sep 17 00:00:00 2001 From: Ilia Kebets Date: Fri, 14 Jun 2024 14:14:43 +0200 Subject: [PATCH 1/3] Do not serialize if 'skipAst' flag is set --- packages/jsts/src/analysis/analyzer.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/jsts/src/analysis/analyzer.ts b/packages/jsts/src/analysis/analyzer.ts index 98340c4d33f..00c805dd983 100644 --- a/packages/jsts/src/analysis/analyzer.ts +++ b/packages/jsts/src/analysis/analyzer.ts @@ -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) { result.ast = ast; } @@ -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; } From f271051f98ccbe5a2af295bde4bdd86b3d43ad8f Mon Sep 17 00:00:00 2001 From: Ilia Kebets Date: Fri, 14 Jun 2024 14:31:51 +0200 Subject: [PATCH 2/3] refactor --- packages/jsts/src/analysis/analyzer.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/jsts/src/analysis/analyzer.ts b/packages/jsts/src/analysis/analyzer.ts index 00c805dd983..61677b354fe 100644 --- a/packages/jsts/src/analysis/analyzer.ts +++ b/packages/jsts/src/analysis/analyzer.ts @@ -92,9 +92,11 @@ function analyzeFile( ...extendedMetrics, }; - const ast = serializeAst(sourceCode, filePath, input.skipAst); - if (ast) { - result.ast = ast; + if (!input.skipAst) { + const ast = serializeAst(sourceCode, filePath); + if (ast) { + result.ast = ast; + } } return result; From c9dde62934f59a763541a97f5defeda11375620e Mon Sep 17 00:00:00 2001 From: Ilia Kebets Date: Fri, 14 Jun 2024 14:51:13 +0200 Subject: [PATCH 3/3] remove remaining parameter --- packages/jsts/src/analysis/analyzer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/jsts/src/analysis/analyzer.ts b/packages/jsts/src/analysis/analyzer.ts index 61677b354fe..306453d4e67 100644 --- a/packages/jsts/src/analysis/analyzer.ts +++ b/packages/jsts/src/analysis/analyzer.ts @@ -110,8 +110,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; }