Skip to content

Commit a6cf950

Browse files
author
Esben Sparre Andreasen
authored
Merge pull request #1235 from xiemaisi/js/include-yaml
JavaScript: Teach AutoBuilder to extract YAML files by default.
2 parents 02fc45d + f22cb18 commit a6cf950

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[[ condition: enterprise-only ]]
2+
3+
# Improvements to JavaScript analysis
4+
5+
## Changes to code extraction
6+
7+
* YAML files are now extracted by default on LGTM. You can specify exclusion filters in your `lgtm.yml` file to override this behavior.

javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@
128128
* FileType#JS} (currently ".js", ".jsx", ".mjs", ".es6", ".es").
129129
* <li>All HTML files, that is, files with with one of the extensions supported by {@link
130130
* FileType#HTML} (currently ".htm", ".html", ".xhtm", ".xhtml", ".vue").
131+
* <li>All YAML files, that is, files with one of the extensions supported by {@link
132+
* FileType#YAML} (currently ".raml", ".yaml", ".yml").
131133
* <li>Files with base name "package.json".
132134
* <li>JavaScript, JSON or YAML files whose base name starts with ".eslintrc".
133135
* <li>All extension-less files.
@@ -338,10 +340,11 @@ private void setupFilters() {
338340
// exclude all files with extensions
339341
patterns.add("-**/*.*");
340342

341-
// but include HTML, JavaScript and (optionally) TypeScript
343+
// but include HTML, JavaScript, YAML and (optionally) TypeScript
342344
Set<FileType> defaultExtract = new LinkedHashSet<FileType>();
343345
defaultExtract.add(FileType.HTML);
344346
defaultExtract.add(FileType.JS);
347+
defaultExtract.add(FileType.YAML);
345348
if (typeScriptMode != TypeScriptMode.NONE) defaultExtract.add(FileType.TYPESCRIPT);
346349
for (FileType filetype : defaultExtract)
347350
for (String extension : filetype.getExtensions()) patterns.add("**/*" + extension);

javascript/extractor/src/com/semmle/js/extractor/test/AutoBuildTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,4 +491,12 @@ public void invalidFileType() throws IOException {
491491
Assert.assertEquals("Invalid file type 'javascript'.", ue.getMessage());
492492
}
493493
}
494+
495+
@Test
496+
public void includeYaml() throws IOException {
497+
addFile(true, LGTM_SRC, "tst.yaml");
498+
addFile(true, LGTM_SRC, "tst.yml");
499+
addFile(true, LGTM_SRC, "tst.raml");
500+
addFile(true, LGTM_SRC, "tst2.YML");
501+
}
494502
}

0 commit comments

Comments
 (0)