mirror of
https://github.com/github/codeql.git
synced 2026-01-28 22:02:57 +01:00
Will need subsequent PRs fixing up test failures (due to deprecated methods moving around), but other than that everything should be straight-forward.
35 lines
851 B
Plaintext
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())
|