mirror of
https://github.com/github/codeql.git
synced 2025-12-25 13:16:33 +01:00
Move the `lines-of-code` tag from `py/summary/lines-of-code`. Code Scanning will eventually look for this tag. The intent is to treat the number of lines of user code for Python as the summary of how much code was analysed, ignoring both external libraries and generated code. This matches the current baseline metric the CodeQL Action computes for Python. We'll revisit this decision, and the baseline, if necessary.
23 lines
776 B
Plaintext
23 lines
776 B
Plaintext
/**
|
|
* @name Total lines of user written Python code in the database
|
|
* @description The total number of lines of Python code from the source code directory,
|
|
* excluding auto-generated files. This query counts the lines of code, excluding
|
|
* whitespace or comments. Note: If external libraries are included in the codebase
|
|
* either in a checked-in virtual environment or as vendored code, that will currently
|
|
* be counted as user written code.
|
|
* @kind metric
|
|
* @tags summary
|
|
* lines-of-code
|
|
* @id py/summary/lines-of-user-code
|
|
*/
|
|
|
|
import python
|
|
import semmle.python.filters.GeneratedCode
|
|
|
|
select sum(Module m |
|
|
exists(m.getFile().getRelativePath()) and
|
|
not m.getFile() instanceof GeneratedFile
|
|
|
|
|
m.getMetrics().getNumberOfLinesOfCode()
|
|
)
|