JavaScript: Round down percentage in `DuplicateToplevel.ql`.

All the other duplication queries already do this.
This commit is contained in:
Max Schaefer 2019-01-25 22:44:07 +08:00
Родитель 39191ed6f1
Коммит 254fafc6ce
3 изменённых файлов: 18 добавлений и 1 удалений

Просмотреть файл

@ -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"

Просмотреть файл

@ -1,2 +1,6 @@
| a.js:1:1:1:1 | <toplevel> | 90% of statements in this script are duplicated in $@. | e.js:1:1:1:1 | <toplevel> | another script |
| a.js:1:1:1:1 | <toplevel> | 100% of statements in this script are duplicated in $@. | b.js:1:1:1:1 | <toplevel> | another script |
| b.js:1:1:1:1 | <toplevel> | 90% of statements in this script are duplicated in $@. | e.js:1:1:1:1 | <toplevel> | another script |
| b.js:1:1:1:1 | <toplevel> | 100% of statements in this script are duplicated in $@. | a.js:1:1:1:1 | <toplevel> | another script |
| e.js:1:1:1:1 | <toplevel> | 90% of statements in this script are duplicated in $@. | a.js:1:1:1:1 | <toplevel> | another script |
| e.js:1:1:1:1 | <toplevel> | 90% of statements in this script are duplicated in $@. | b.js:1:1:1:1 | <toplevel> | another script |

13
javascript/ql/test/query-tests/external/DuplicateToplevel/e.js поставляемый Normal file
Просмотреть файл

@ -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]*/;
}