github / github/codeql

getMetrics appears to be miscounting blank lines in docstrings

Ouverte
#20,766 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
Python question
Langage dominant
CodeQL
Étoiles
10.1k
Forks
2.1k
Merge moyen
2 j 15 h
PR mergées (30 j)
141

Description

The definition of the python function `combine_docs` starts on line 227 in [combine_documents/map_reduce.py](https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain_classic/chains/combine_documents/map_reduce.py) and ends on line 259.

[func-def.txt](https://github.com/user-attachments/files/23375865/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](https://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain_classic/chains/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

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Reproduce the reported metrics for combine_docs in libs/langchain/langchain_classic/chains/combine_documents/map_reduce.py and collapse_docs in combine_documents/reduce.py using the linked QL script and attachment. Compare total, code, comment, and docstring counts with the stated expected values, especially around blank lines in docstrings. Done means the metrics consistently report the expected counts for both examples.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
devtools
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.