Files
codeql/python/ql/src/Metrics/History/HNumberOfReCommits.ql
Taus Brock-Nannestad f07a7bf8cf Python: Autoformat everything using qlformat.
Will need subsequent PRs fixing up test failures (due to deprecated
methods moving around), but other than that everything should be
straight-forward.
2020-07-07 15:43:52 +02:00

35 lines
851 B
Plaintext

/**
* @name Number of re-commits for each file
* @description A re-commit is taken to mean a commit to a file that was touched less than five days ago.
* @kind treemap
* @id py/historical-number-of-re-commits
* @treemap.warnOn highValues
* @metricType file
* @metricAggregate avg min max
*/
import python
import external.VCS
predicate inRange(Commit first, Commit second) {
first.getAnAffectedFile() = second.getAnAffectedFile() and
first != second and
exists(int n |
n = first.getDate().daysTo(second.getDate()) and
n >= 0 and
n < 5
)
}
int recommitsForFile(File f) {
result =
count(Commit recommit |
f = recommit.getAnAffectedFile() and
exists(Commit prev | inRange(prev, recommit))
)
}
from Module m
where exists(m.getMetrics().getNumberOfLinesOfCode())
select m, recommitsForFile(m.getFile())