From 254fafc6ce7b6432a6755d724189e2f1fe5eadae Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Fri, 25 Jan 2019 22:44:07 +0800 Subject: [PATCH] JavaScript: Round down percentage in `DuplicateToplevel.ql`. All the other duplication queries already do this. --- javascript/ql/src/external/DuplicateToplevel.ql | 2 +- .../DuplicateToplevel/DuplicateToplevel.expected | 4 ++++ .../query-tests/external/DuplicateToplevel/e.js | 13 +++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 javascript/ql/test/query-tests/external/DuplicateToplevel/e.js diff --git a/javascript/ql/src/external/DuplicateToplevel.ql b/javascript/ql/src/external/DuplicateToplevel.ql index bc88dc79a7c..c1459cd0efe 100644 --- a/javascript/ql/src/external/DuplicateToplevel.ql +++ b/javascript/ql/src/external/DuplicateToplevel.ql @@ -22,5 +22,5 @@ from TopLevel one, TopLevel another, float percent where duplicateContainers(one, another, percent) and one.getNumLines() > 5 -select one.(FirstLineOf), percent + "% of statements in this script are duplicated in $@.", +select one.(FirstLineOf), percent.floor() + "% of statements in this script are duplicated in $@.", another.(FirstLineOf), "another script" diff --git a/javascript/ql/test/query-tests/external/DuplicateToplevel/DuplicateToplevel.expected b/javascript/ql/test/query-tests/external/DuplicateToplevel/DuplicateToplevel.expected index d4f768ca3ac..b2430574fdd 100644 --- a/javascript/ql/test/query-tests/external/DuplicateToplevel/DuplicateToplevel.expected +++ b/javascript/ql/test/query-tests/external/DuplicateToplevel/DuplicateToplevel.expected @@ -1,2 +1,6 @@ +| a.js:1:1:1:1 | | 90% of statements in this script are duplicated in $@. | e.js:1:1:1:1 | | another script | | a.js:1:1:1:1 | | 100% of statements in this script are duplicated in $@. | b.js:1:1:1:1 | | another script | +| b.js:1:1:1:1 | | 90% of statements in this script are duplicated in $@. | e.js:1:1:1:1 | | another script | | b.js:1:1:1:1 | | 100% of statements in this script are duplicated in $@. | a.js:1:1:1:1 | | another script | +| e.js:1:1:1:1 | | 90% of statements in this script are duplicated in $@. | a.js:1:1:1:1 | | another script | +| e.js:1:1:1:1 | | 90% of statements in this script are duplicated in $@. | b.js:1:1:1:1 | | another script | diff --git a/javascript/ql/test/query-tests/external/DuplicateToplevel/e.js b/javascript/ql/test/query-tests/external/DuplicateToplevel/e.js new file mode 100644 index 00000000000..b763d09bf6c --- /dev/null +++ b/javascript/ql/test/query-tests/external/DuplicateToplevel/e.js @@ -0,0 +1,13 @@ +{ + if (arguments.length == 0) + 23; + if (arguments.length % 2 != 0) + 42; + console.log(arguments[0]); + arguments[0]--; + arguments[1] += 19; + arguments[0] * arguments[1]; + arguments[2] / arguments[3]; + arguments[4] % arguments[5]; + /*arguments[6] % arguments[7]*/; +}