codeql icon indicating copy to clipboard operation
codeql copied to clipboard

getMetrics appears to be miscounting blank lines in docstrings

Open Derek-Jones opened this issue 2 months ago • 1 comments

The definition of the python function combine_docs starts on line 227 in combine_documents/map_reduce.py and ends on line 259.

func-def.txt Running the above QL script on the latest langchain database produces the values:

func.getMetrics().getNumberOfLines() = 33 func.getMetrics().getNumberOfLinesOfCode() = 27 # Should be 26 func.getMetrics().getNumberOfLinesOfComments() = 2 func.getMetrics().getNumberOfLinesOfDocStrings() = 5

I suspect that the number of blank line in the docstring might be a factor. The above function contains one blank line in a docstring, while the example below contains two blank lines in a docstring.

The function collapse_docs starts on line 67 in combine_documents/reduce.py and ends on line 96.

The above QL script produces the values:

func.getMetrics().getNumberOfLines() = 30 func.getMetrics().getNumberOfLinesOfCode() = 12 # Should be 14 func.getMetrics().getNumberOfLinesOfComments() = 0 func.getMetrics().getNumberOfLinesOfDocStrings() = 16

Derek-Jones avatar Nov 05 '25 21:11 Derek-Jones

Hi again @Derek-Jones 👋🏻

Yes, that looks like a plausible explanation for what is happening there. I'll check this with our Python team.

mbg avatar Nov 07 '25 18:11 mbg