Skip to content

fix(quality): move inner functions to module scope (S7721) #473

@RobertLD

Description

@RobertLD

Summary

10 SonarCloud issues (S7721) across 6 files where functions are defined inside other functions but do not close over any local variables, so they can be safely moved to module scope.

Why

Defining a function inside another function recreates it on every call, adding unnecessary overhead. When the inner function doesn't use any variables from the enclosing scope, there's no reason for it to be nested. Moving it out also reduces the cognitive complexity of the outer function, potentially fixing S3776 violations as a side effect.

Scope

~10 occurrences across:

  • src/cli/index.ts
  • src/core/
  • src/api/
  • src/connectors/
  • tests/
  • and others

Fix

For each flagged inner function, verify it captures no outer-scope variables, then move it to module scope (or to a shared utilities file if used in multiple places).

Estimated effort

~50 min total (~5 min/issue)

SonarCloud

View issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions