Skip to content

fix: read COMPLEXITY_THRESHOLD from config instead of hardcoded default#1293

Open
MorningStar0709 wants to merge 1 commit into
CodeGraphContext:mainfrom
MorningStar0709:fix/complexity-threshold-config
Open

fix: read COMPLEXITY_THRESHOLD from config instead of hardcoded default#1293
MorningStar0709 wants to merge 1 commit into
CodeGraphContext:mainfrom
MorningStar0709:fix/complexity-threshold-config

Conversation

@MorningStar0709

Copy link
Copy Markdown
Contributor

Summary

The cgc analyze complexity command's --threshold option ignored the COMPLEXITY_THRESHOLD config value, always defaulting to hardcoded 10.

Root Cause

In cli/main.py line 2511, the threshold parameter was defined as:

threshold: int = typer.Option(10, "--threshold", "-t", help="Complexity threshold for warnings")

The function body never called config_manager.get_config_value("COMPLEXITY_THRESHOLD") to override this default. So even if a user ran cgc config set COMPLEXITY_THRESHOLD 15, the CLI would still use 10.

Fix

Changed the default to None (making it Optional[int]) and added config-reading logic:

threshold: Optional[int] = typer.Option(None, "--threshold", "-t",
    help="Complexity threshold for warnings (default: from config or 10)")

In the function body, when threshold is None:

  1. Read COMPLEXITY_THRESHOLD from config
  2. Parse to int, falling back to 10 on ValueError/TypeError
  3. Default to 10 if config value is also missing

Testing

  • py_compile passes
  • cgc analyze complexity --help shows updated description
  • Manual verification: cgc config set COMPLEXITY_THRESHOLD 15 now takes effect

Impact

  • Users who set COMPLEXITY_THRESHOLD via cgc config set will now see it applied
  • Explicit --threshold N CLI flag still takes precedence (not None)
  • Backward compatible: if neither config nor CLI flag is set, behavior is identical (default 10)

The `cgc analyze complexity --threshold` option had a hardcoded default
of 10 that ignored the COMPLEXITY_THRESHOLD config value set via
`cgc config set COMPLEXITY_THRESHOLD <value>`.

Changed the default to None and added logic to read from config when
not explicitly provided via CLI, falling back to 10 if the config
value is missing or invalid.
@vercel

vercel Bot commented Jun 20, 2026

Copy link
Copy Markdown

@MorningStar0709 is attempting to deploy a commit to the shashankss1205's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog tasks

Development

Successfully merging this pull request may close these issues.

1 participant