Skip to content

chore(bootstrap): silence gocognit/gocyclo on InitServers wire-up#34

Closed
alexgarzao wants to merge 1 commit into
developfrom
chore/silence-gocognit-init-servers
Closed

chore(bootstrap): silence gocognit/gocyclo on InitServers wire-up#34
alexgarzao wants to merge 1 commit into
developfrom
chore/silence-gocognit-init-servers

Conversation

@alexgarzao
Copy link
Copy Markdown
Collaborator

Summary

  • Adds an inline //nolint:gocognit,gocyclo directive to InitServers in internal/bootstrap/config.go so make lint runs clean (was 1 issue, now 0).
  • Documents why the suppression is acceptable rather than refactoring.

Why

InitServers is a linear bootstrap/wire-up routine. Its complexity scores (gocognit: 41, gocyclo: 39, both above the 25 threshold) come from the sequential if err != nil { return nil, err } chain across:

  1. Config load from env vars
  2. Logger initialization
  3. TLS validation (SaaS hard-fail)
  4. Telemetry (OpenTelemetry)
  5. readyz / multi-tenant metric init
  6. MongoDB pool (with multi-tenant gate)
  7. Executor catalog + default registration
  8. Repository wiring
  9. HTTP / gRPC server startup

Extracting helpers would add indirection without simplifying control flow — each step consumes outputs from the previous one, and the readable shape is the linear sequence. A genuine refactor (a builder / staged-init abstraction) is a separate concern, larger than a lint suppression PR.

Alternative considered

Refactor InitServers into a staged initializer struct. Rejected for this PR: high blast radius (touches every dependency the function returns inside *Service), and the current shape is already easy to read top-to-bottom. The lint score is a signal to consider decomposition, not a mandate.

Test plan

  • make lint — 0 issues (was 1: gocognit on InitServers)
  • go test ./internal/bootstrap/... — 58 tests pass
  • go test ./... — 240 tests pass across 52 packages (no regressions)
  • go vet ./... — clean

Notes

InitServers is a linear bootstrap/wire-up routine. The high cognitive
and cyclomatic complexity scores (41 / 39, both > 25) come from the
sequential `if err != nil { return nil, err }` chain across config
load, logger, telemetry, TLS validation, MongoDB pool, executor
catalog, repositories, and HTTP/gRPC server startup.

Extracting helpers would add indirection without simplifying the
control flow: each step consumes outputs from the previous one, and
the readable shape *is* the linear sequence. A genuine refactor (e.g.
a builder/stages abstraction) is a separate, larger concern.

Silencing both linters at the function level with an inline
justification keeps `make lint` green so it can flag real regressions.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0da3d5e0-8600-4691-85b9-611a0739b648

📥 Commits

Reviewing files that changed from the base of the PR and between 749a22d and 206e910.

📒 Files selected for processing (1)
  • internal/bootstrap/config.go

Walkthrough

This PR adds documentation and linter suppression to the InitServers bootstrap function in internal/bootstrap/config.go. A multi-line comment explains the intentional sequential initialization pattern with error checking, and a //nolint:gocognit,gocyclo directive silences complexity linters for this routine.

Changes

Bootstrap Initialization Documentation

Layer / File(s) Summary
InitServers documentation and complexity suppression
internal/bootstrap/config.go
Added an explanatory comment block and //nolint:gocognit,gocyclo directive before InitServers to document why the function intentionally maintains a sequential initialization pattern with inline error handling rather than being decomposed into smaller functions, and to suppress related complexity linter warnings.

Comment @coderabbitai help to get the list of available commands and usage tips.

@lerian-studio
Copy link
Copy Markdown
Contributor

📊 Unit Test Coverage Report: flowker

Metric Value
Overall Coverage 45.2% ⚠️ BELOW THRESHOLD
Threshold 85%

Coverage by Package

Package Coverage
github.com/LerianStudio/flowker/api 100.0%
github.com/LerianStudio/flowker/internal/adapters/http/in/audit 0.0%
github.com/LerianStudio/flowker/internal/adapters/http/in/catalog 60.9%
github.com/LerianStudio/flowker/internal/adapters/http/in/dashboard 91.5%
github.com/LerianStudio/flowker/internal/adapters/http/in/execution 81.0%
github.com/LerianStudio/flowker/internal/adapters/http/in/executor_configuration 70.8%
github.com/LerianStudio/flowker/internal/adapters/http/in/health 100.0%
github.com/LerianStudio/flowker/internal/adapters/http/in/middleware/testutil 0.0%
github.com/LerianStudio/flowker/internal/adapters/http/in/middleware 44.4%
github.com/LerianStudio/flowker/internal/adapters/http/in/provider_configuration 33.1%
github.com/LerianStudio/flowker/internal/adapters/http/in/readyz 81.3%
github.com/LerianStudio/flowker/internal/adapters/http/in/webhook 87.5%
github.com/LerianStudio/flowker/internal/adapters/http/in/workflow 69.7%
github.com/LerianStudio/flowker/internal/adapters/http/in 33.3%
github.com/LerianStudio/flowker/internal/adapters/mongodb/dashboard 43.0%
github.com/LerianStudio/flowker/internal/adapters/mongodb/execution 64.8%
github.com/LerianStudio/flowker/internal/adapters/mongodb/executor_configuration 36.6%
github.com/LerianStudio/flowker/internal/adapters/mongodb/provider_configuration 63.0%
github.com/LerianStudio/flowker/internal/adapters/mongodb/workflow 69.2%
github.com/LerianStudio/flowker/internal/adapters/postgresql/audit 42.2%
github.com/LerianStudio/flowker/internal/bootstrap 40.5%
github.com/LerianStudio/flowker/internal/services/command 37.2%
github.com/LerianStudio/flowker/internal/services/query 11.2%
github.com/LerianStudio/flowker/internal/services 3.2%
github.com/LerianStudio/flowker/internal/testutil 63.6%
github.com/LerianStudio/flowker/pkg/circuitbreaker 97.6%
github.com/LerianStudio/flowker/pkg/clock 0.0%
github.com/LerianStudio/flowker/pkg/condition 87.9%
github.com/LerianStudio/flowker/pkg/contextutil 0.0%
github.com/LerianStudio/flowker/pkg/executor/base 20.0%
github.com/LerianStudio/flowker/pkg/executor 39.5%
github.com/LerianStudio/flowker/pkg/executors/http/auth 58.2%
github.com/LerianStudio/flowker/pkg/executors/http 49.5%
github.com/LerianStudio/flowker/pkg/executors/midaz 83.2%
github.com/LerianStudio/flowker/pkg/executors/s3 0.0%
github.com/LerianStudio/flowker/pkg/executors/tracer 72.2%
github.com/LerianStudio/flowker/pkg/executors 57.1%
github.com/LerianStudio/flowker/pkg/model 58.7%
github.com/LerianStudio/flowker/pkg/net/http 91.3%
github.com/LerianStudio/flowker/pkg/pagination 0.0%
github.com/LerianStudio/flowker/pkg/safehttp 90.3%
github.com/LerianStudio/flowker/pkg/templates/tracer_midaz 81.5%
github.com/LerianStudio/flowker/pkg/templates 0.0%
github.com/LerianStudio/flowker/pkg/transformation 67.2%
github.com/LerianStudio/flowker/pkg/triggers/webhook 0.0%
github.com/LerianStudio/flowker/pkg/triggers 0.0%
github.com/LerianStudio/flowker/pkg/webhook 100.0%
github.com/LerianStudio/flowker/pkg 90.3%

Generated by Go PR Analysis workflow

@lerian-studio
Copy link
Copy Markdown
Contributor

🔒 Security Scan Results — flowker

Trivy

Filesystem Scan

✅ No vulnerabilities or secrets found.

Docker Image Scan

✅ No vulnerabilities found.


Docker Hub Health Score Compliance

✅ Policies — 4/4 met

Policy Status
Default non-root user ✅ Passed
No fixable critical/high CVEs ✅ Passed
No high-profile vulnerabilities ✅ Passed
No AGPL v3 licenses ✅ Passed

Pre-release Version Check

✅ No unstable version pins found.


🔍 View full scan logs

@alexgarzao alexgarzao closed this May 21, 2026
@alexgarzao alexgarzao deleted the chore/silence-gocognit-init-servers branch May 21, 2026 17:35
alexgarzao added a commit that referenced this pull request May 21, 2026
InitServers is a linear bootstrap/wire-up routine. The complexity
scores (gocognit 41, gocyclo 39, both > 25) come from the sequential
`if err != nil { return nil, err }` chain across config load, logger,
telemetry, TLS validation, MongoDB pool, executor catalog,
repositories, and HTTP/gRPC server startup.

Extracting helpers would add indirection without simplifying the
control flow — each step consumes outputs from the previous one and
the readable shape *is* the linear sequence. A genuine refactor is a
separate, larger concern tracked outside this PR.

This is the same fix landing on develop via #34; when #34 merges
first, a subsequent rebase here will skip this commit because the
diff is identical.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants