From f22cb186e32c5ce4c7c1255a21697ceedc9f410b Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Wed, 10 Apr 2019 08:21:49 -0700 Subject: [PATCH] JavaScript: Teach AutoBuilder to extract YAML files by default. --- change-notes/1.21/extractor-javascript.md | 7 +++++++ .../extractor/src/com/semmle/js/extractor/AutoBuild.java | 5 ++++- .../src/com/semmle/js/extractor/test/AutoBuildTests.java | 8 ++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 change-notes/1.21/extractor-javascript.md diff --git a/change-notes/1.21/extractor-javascript.md b/change-notes/1.21/extractor-javascript.md new file mode 100644 index 00000000000..0f6fd996a72 --- /dev/null +++ b/change-notes/1.21/extractor-javascript.md @@ -0,0 +1,7 @@ +[[ condition: enterprise-only ]] + +# Improvements to JavaScript analysis + +## Changes to code extraction + +* YAML files are now extracted by default on LGTM. You can specify exclusion filters in your `lgtm.yml` file to override this behavior. diff --git a/javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java b/javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java index f599617c14d..61093e7bdb4 100644 --- a/javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java +++ b/javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java @@ -128,6 +128,8 @@ import java.util.stream.Stream; * FileType#JS} (currently ".js", ".jsx", ".mjs", ".es6", ".es"). *
  • All HTML files, that is, files with with one of the extensions supported by {@link * FileType#HTML} (currently ".htm", ".html", ".xhtm", ".xhtml", ".vue"). + *
  • All YAML files, that is, files with one of the extensions supported by {@link + * FileType#YAML} (currently ".raml", ".yaml", ".yml"). *
  • Files with base name "package.json". *
  • JavaScript, JSON or YAML files whose base name starts with ".eslintrc". *
  • All extension-less files. @@ -338,10 +340,11 @@ public class AutoBuild { // exclude all files with extensions patterns.add("-**/*.*"); - // but include HTML, JavaScript and (optionally) TypeScript + // but include HTML, JavaScript, YAML and (optionally) TypeScript Set defaultExtract = new LinkedHashSet(); defaultExtract.add(FileType.HTML); defaultExtract.add(FileType.JS); + defaultExtract.add(FileType.YAML); if (typeScriptMode != TypeScriptMode.NONE) defaultExtract.add(FileType.TYPESCRIPT); for (FileType filetype : defaultExtract) for (String extension : filetype.getExtensions()) patterns.add("**/*" + extension); diff --git a/javascript/extractor/src/com/semmle/js/extractor/test/AutoBuildTests.java b/javascript/extractor/src/com/semmle/js/extractor/test/AutoBuildTests.java index 52bc65f2501..f5155cca224 100644 --- a/javascript/extractor/src/com/semmle/js/extractor/test/AutoBuildTests.java +++ b/javascript/extractor/src/com/semmle/js/extractor/test/AutoBuildTests.java @@ -491,4 +491,12 @@ public class AutoBuildTests { Assert.assertEquals("Invalid file type 'javascript'.", ue.getMessage()); } } + + @Test + public void includeYaml() throws IOException { + addFile(true, LGTM_SRC, "tst.yaml"); + addFile(true, LGTM_SRC, "tst.yml"); + addFile(true, LGTM_SRC, "tst.raml"); + addFile(true, LGTM_SRC, "tst2.YML"); + } }