repowiselangchain-ai/langchain

langchain-ai / langchain

pythonmasterfacf278327.1K linessynced 2d ago

Code health

6.7out of 10Fair

Hotspots average 3.8, the place fixes pay off most.

Explore this codebase

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
    worth a check
  • Start 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
    worth a check
  • Tidy the code shape this week's commits left: 2 findings in libs/core/langchain_core/language_models/_compat_bridge.py

    1 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
  • Simplify _format_messages in libs/partners/anthropic/langchain_anthropic/chat_models.py: tests reach it, and fixes keep landing

    Changed 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)
    worth a check
  • Break 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
    worth a check

Everything we found

5 areas