Skip to content

Commit

Permalink
Fix Babel fallback for JS files (#4088)
Browse files Browse the repository at this point in the history
  • Loading branch information
victor-diez-sonarsource committed Aug 24, 2023
1 parent e4e3d6c commit 2ba5336
Show file tree
Hide file tree
Showing 25 changed files with 160 additions and 50 deletions.
Expand Up @@ -326,6 +326,26 @@
"javascript-test-sources:src/ecmascript6/Ghost/core/server/models/plugins/pagination.js": [
180
],
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/startup-check.js": [
35,
36,
38,
61,
63,
92,
93,
94,
136,
137,
138,
158,
159,
160,
205,
206,
207,
208
],
"javascript-test-sources:src/ecmascript6/Ghost/core/test/functional/base.js": [
337
],
Expand Down Expand Up @@ -377,6 +397,12 @@
17,
20
],
"javascript-test-sources:src/ecmascript6/ecmascript6-today/6-destructuring.js": [
6,
10,
16,
36
],
"javascript-test-sources:src/ecmascript6/ecmascript6-today/7-rest-params/js/rest-spread.js": [
18,
22,
Expand Down
Expand Up @@ -92306,6 +92306,9 @@
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/index.js": [
93
],
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/startup-check.js": [
147
],
"javascript-test-sources:src/ecmascript6/Ghost/core/test/functional/base.js": [
154,
160,
Expand Down Expand Up @@ -93644,6 +93647,12 @@
12,
21
],
"javascript-test-sources:src/ecmascript6/ecmascript6-today/6-destructuring.js": [
13,
13,
13,
13
],
"javascript-test-sources:src/ecmascript6/ecmascript6-today/8-iterators.js": [
37
],
Expand Down
Expand Up @@ -1693,6 +1693,9 @@
15,
23
],
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/startup-check.js": [
174
],
"javascript-test-sources:src/ecmascript6/Ghost/core/test/functional/base.js": [
179,
456,
Expand Down
@@ -0,0 +1,5 @@
{
"javascript-test-sources:src/ecmascript6/ecmascript6-today/6-destructuring.js": [
13
]
}
Expand Up @@ -1032,6 +1032,13 @@
13,
19
],
"javascript-test-sources:src/ecmascript6/ecmascript6-today/6-destructuring.js": [
6,
10,
15,
16,
36
],
"javascript-test-sources:src/ecmascript6/ecmascript6-today/7-rest-params/Gruntfile.js": [
8
],
Expand Down
Expand Up @@ -54737,6 +54737,15 @@
20,
20
],
"javascript-test-sources:src/ecmascript6/ecmascript6-today/6-destructuring.js": [
5,
5,
6,
10,
13,
24,
36
],
"javascript-test-sources:src/ecmascript6/ecmascript6-today/7-rest-params/js/rest-spread.js": [
22,
23,
Expand Down
Expand Up @@ -3968,6 +3968,9 @@
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/sequence.js": [
0
],
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/startup-check.js": [
0
],
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/validate-themes.js": [
0
],
Expand Down Expand Up @@ -4484,6 +4487,9 @@
"javascript-test-sources:src/ecmascript6/ecmascript6-today/5-set.js": [
0
],
"javascript-test-sources:src/ecmascript6/ecmascript6-today/6-destructuring.js": [
0
],
"javascript-test-sources:src/ecmascript6/ecmascript6-today/7-rest-params/Gruntfile.js": [
0
],
Expand Down
Expand Up @@ -631,6 +631,9 @@
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/downzero.js": [
18
],
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/startup-check.js": [
167
],
"javascript-test-sources:src/ecmascript6/expressionist.js/test/parser.spec.js": [
66,
393
Expand Down
Expand Up @@ -1722,6 +1722,10 @@
10,
14
],
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/startup-check.js": [
5,
192
],
"javascript-test-sources:src/ecmascript6/Ghost/core/shared/ghost-url.js": [
56,
57,
Expand Down
Expand Up @@ -10,11 +10,5 @@
],
"javascript-test-sources:src/ace/tool/templates/theme.js": [
32
],
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/startup-check.js": [
37
],
"javascript-test-sources:src/ecmascript6/ecmascript6-today/6-destructuring.js": [
13
]
}
Expand Up @@ -15865,6 +15865,15 @@
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/sequence.js": [
1
],
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/startup-check.js": [
1,
30,
46,
76,
105,
146,
172
],
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/validate-themes.js": [
5,
17,
Expand Down Expand Up @@ -17505,6 +17514,11 @@
"javascript-test-sources:src/ecmascript6/ecmascript6-today/5-set.js": [
7
],
"javascript-test-sources:src/ecmascript6/ecmascript6-today/6-destructuring.js": [
5,
15,
33
],
"javascript-test-sources:src/ecmascript6/ecmascript6-today/7-rest-params/js/rest-spread.js": [
1,
5,
Expand Down
Expand Up @@ -1192,6 +1192,10 @@
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/downzero.js": [
14
],
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/startup-check.js": [
36,
61
],
"javascript-test-sources:src/ecmascript6/Ghost/core/shared/ghost-url.js": [
20
],
Expand Down Expand Up @@ -1338,6 +1342,12 @@
"javascript-test-sources:src/ecmascript6/ecmascript6-today/4-default-params.js": [
4
],
"javascript-test-sources:src/ecmascript6/ecmascript6-today/6-destructuring.js": [
6,
10,
16,
36
],
"javascript-test-sources:src/ecmascript6/ecmascript6-today/7-rest-params/js/rest-spread.js": [
25
],
Expand Down
Expand Up @@ -4912,6 +4912,12 @@
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/sequence.js": [
1
],
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/startup-check.js": [
1,
2,
3,
4
],
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/validate-themes.js": [
5,
6,
Expand Down
Expand Up @@ -12811,6 +12811,10 @@
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/read-directory.js": [
38
],
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/startup-check.js": [
15,
212
],
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/validate-themes.js": [
19,
33,
Expand Down Expand Up @@ -14404,6 +14408,10 @@
13,
31
],
"javascript-test-sources:src/ecmascript6/ecmascript6-today/6-destructuring.js": [
28,
29
],
"javascript-test-sources:src/ecmascript6/ecmascript6-today/7-rest-params/Gruntfile.js": [
8,
9,
Expand Down
@@ -0,0 +1,14 @@
{
"javascript-test-sources:src/ecmascript6/Ghost/core/server/utils/startup-check.js": [
37,
38,
62,
64,
92,
94,
110,
112,
205,
208
]
}
Expand Up @@ -15,7 +15,7 @@
2
],
"jshint:tests/unit/fixtures/es6-template-literal-tagged.js": [
24
23
],
"jshint:tests/unit/fixtures/es6-template-literal.js": [
14
Expand Down

This file was deleted.

Expand Up @@ -70,5 +70,9 @@ void initialize(SensorContext context, JsTsChecks checks, AnalysisMode analysisM
this.analysisMode = analysisMode;
}

protected boolean isJavaScript(InputFile file) {
return inputFileLanguage(file).equals(JavaScriptLanguage.KEY);
}

abstract void analyzeFiles(List<InputFile> inputFiles, List<String> tsConfigs) throws IOException;
}
Expand Up @@ -160,7 +160,11 @@ private void analyze(InputFile file, @Nullable TsProgram tsProgram) throws IOExc
monitoring.startFile(file);
var fileContent = contextUtils.shouldSendFileContent(file) ? file.contents() : null;
var request = getJsAnalysisRequest(file, tsProgram, fileContent);
var response = bridgeServer.analyzeWithProgram(request);

var response = isJavaScript(file)
? bridgeServer.analyzeJavaScript(request)
: bridgeServer.analyzeTypeScript(request);

analysisProcessor.processResponse(context, checks, file, response);
cacheStrategy.writeAnalysisToCache(
CacheAnalysis.fromResponse(response.ucfgPaths, response.cpdTokens),
Expand Down
Expand Up @@ -166,8 +166,4 @@ private void analyze(InputFile file, @Nullable TsConfigFile tsConfigFile) throws
analysisProcessor.processCacheAnalysis(context, file, cacheAnalysis);
}
}

private boolean isJavaScript(InputFile file) {
return inputFileLanguage(file).equals(JavaScriptLanguage.KEY);
}
}
Expand Up @@ -48,8 +48,6 @@ void initLinter(

AnalysisResponse analyzeTypeScript(JsAnalysisRequest request) throws IOException;

AnalysisResponse analyzeWithProgram(JsAnalysisRequest request) throws IOException;

AnalysisResponse analyzeCss(CssAnalysisRequest request) throws IOException;

AnalysisResponse analyzeYaml(JsAnalysisRequest request) throws IOException;
Expand Down
Expand Up @@ -347,11 +347,6 @@ public AnalysisResponse analyzeTypeScript(JsAnalysisRequest request) throws IOEx
return response(request(json, "analyze-ts"), request.filePath);
}

@Override
public AnalysisResponse analyzeWithProgram(JsAnalysisRequest request) throws IOException {
return response(request(GSON.toJson(request), "analyze-with-program"), request.filePath);
}

@Override
public AnalysisResponse analyzeCss(CssAnalysisRequest request) throws IOException {
String json = GSON.toJson(request);
Expand Down
Expand Up @@ -298,7 +298,7 @@ void should_get_answer_from_server_for_program_based_requests() throws Exception
programCreated.programId,
DEFAULT_LINTER_ID
);
assertThat(bridgeServer.analyzeWithProgram(request).issues).isEmpty();
assertThat(bridgeServer.analyzeTypeScript(request).issues).isEmpty();

assertThat(bridgeServer.deleteProgram(programCreated)).isTrue();
}
Expand Down

0 comments on commit 2ba5336

Please sign in to comment.