langchain-ai / langchain
Code health
Hotspots average 3.8, the place fixes pay off most.
Explore this codebase
- Code health map58hotspots across 2,965 files
- Ownership489sole-owned files: one author, no second reader
- Architecture2modules, 23 entry points
- Decisions59recorded, of which 0 accepted and 59 awaiting review
- Refactoring121open opportunities, one per file
- TestsNo coverage report yet. Run your tests with coverage on, then add the report:
AlsoDocsChatFilesKnowledge graphChange couplingCommitsStatsCosts
Do next · 5
5 things worth doing in the week to Oct 28, the last indexed commit.
Worth planning
Break up _iter_blocks (CCN 118, 350 lines)
libs/core/langchain_core/messages/block_translators/openai.py:727
_iter_blocks nests deeply; easier to read and change once split, which also removes a duplicate; function changed in 6 commits; its file is imported by 13 files, changed 1 time in 90 days.
- gain
- up to +0.6 health on this file(inferred)
- finding
- Nested complexity
- size
- CCN 118, 350 lines, nests 6 deep
- severity
- medium
Medium effort, worth a checkStart breaking up _convert_to_v1_from_genai (CCN 51, 187 lines): first lift lines 335-367
libs/core/langchain_core/messages/block_translators/google_genai.py:335
_convert_to_v1_from_genai has many paths; easier to read and change once split, which also removes a duplicate; function changed in 10 commits; its file is imported by 4 files, changed 2 times in 90 days.
- gain
- up to +1.6 health on this file(inferred)
- finding
- Complex method
- size
- CCN 51, 187 lines, nests 7 deep
- severity
- high
Medium effort, worth a checkTidy the code shape this week's commits left: 2 findings in
libs/core/langchain_core/language_models/_compat_bridge.py1 commit in the last 7 days added or worsened long, complex or deeply nested code, still open. Start with
libs/core/langchain_core/language_models/_compat_bridge.py(2 findings): tidying it while the change is fresh costs less than after the next one.- code-shape findings
- 2
- files
- 1
- commits
- 1
Medium effortSimplify
_format_messagesinlibs/partners/anthropic/langchain_anthropic/chat_models.py: tests reach it, and fixes keep landingChanged 20 times in 90 days, and 8 of those commits were bug fixes.
- commits in 90 days
- 20
- bug-fix commits
- 8
- line coverage
- Unknown, no report
- tests that reach it
- 71 test files, call graph(inferred)
Large effort, worth a checkBreak up merge_lists (CCN 27, 66 lines)
libs/core/langchain_core/utils/_merge.py:146
merge_lists nests deeply; easier to read and change once split; function changed in 13 commits; its file is imported by 10 files, changed 1 time in 90 days.
- gain
- up to +1.3 health on this file(inferred)
- finding
- Nested complexity
- size
- CCN 27, 66 lines, nests 8 deep
- severity
- high
Medium effort, worth a check
Everything we found
5 areas
Every detector's open count by area. The actions above are the part worth doing.
- Code health3,509 open findingsCriticalChange entropy · libs/partners/openai/langchain_openai/chat_models/base.py111 findings · 15.8 deducted
- Refactoring121 open opportunitiesMediuminclude_run+1.1 health, S effort · libs/core/langchain_core/tracers/log_stream.py
- Decisions59 to reviewMediumlibs/partners/openrouter/langchain_openrouter/data/_profiles.py59 awaiting review, 0 drifting from the code
- Ownership489 sole-owned filesMediumlibs/partners/typesafe/tests/unit_tests/experimental/middleware/test_model_router.pyOne author, no second reader
- Dead code5Lowis_llmUnreachable function (10 lines)