Skip to content

Reduce buildProvider cyclomatic complexity - #6680

Merged
reyortiz3 merged 1 commit into
mainfrom
fix/gocyclo-build-provider
Sep 17, 2026
Merged

reyortiz3 merged 1 commit into
mainfrom
fix/gocyclo-build-provider

Conversation

@reyortiz3

Copy link
Copy Markdown
Collaborator

Summary

main fails task lint with:

pkg/authserver/server_impl.go:447:1: cyclomatic complexity 16 of func `buildProvider` is high (> 15) (gocyclo)

buildProvider accumulated branches over several recent additions (token
exchange, JWT-bearer, ID-JAG, device flow), pushing it over the gocyclo
threshold. This PR restores a clean lint run without changing behavior:

  • Extracted the JWT-bearer + ID-JAG factory construction into a new
    buildJWTBearerFactories helper.
  • Extracted the device-flow factory construction (storage capability check
    • interval defaulting) into a new buildDeviceFlowFactory helper.
  • buildProvider now calls these helpers and appends their results,
    bringing its cyclomatic complexity from 16 down to within the limit.

Type of change

  • Bug fix
  • Refactoring (no behavior change)
  • New feature
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (task test)
  • E2E tests (task test-e2e)
  • Linting (task lint-fix)
  • Manual testing (describe below)

task lint now reports 0 issues, and the full task test suite passes.

Does this introduce a user-facing change?

No.

🤖 Generated with Claude Code

Extract the JWT-bearer/ID-JAG factory construction and the device-flow
factory construction into buildJWTBearerFactories and
buildDeviceFlowFactory. This drops buildProvider's cyclomatic
complexity from 16 to under the gocyclo threshold of 15 without
changing behavior.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions github-actions Bot added the size/XS Extra small PR: < 100 lines changed label Sep 17, 2026
@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.21%. Comparing base (59ba54d) to head (91428c4).

Files with missing lines Patch % Lines
pkg/authserver/server_impl.go 71.42% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6680      +/-   ##
==========================================
+ Coverage   79.14%   79.21%   +0.06%     
==========================================
  Files         789      789              
  Lines       79021    79028       +7     
==========================================
+ Hits        62545    62599      +54     
+ Misses      16471    16424      -47     
  Partials        5        5              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@reyortiz3
reyortiz3 merged commit 158e671 into main Sep 17, 2026
47 checks passed
@reyortiz3
reyortiz3 deleted the fix/gocyclo-build-provider branch September 17, 2026 17:19
@github-actions github-actions Bot mentioned this pull request Sep 18, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Extra small PR: < 100 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants