Skip to content

fix: miscellaneous SonarCloud findings (small groups, 1-9 each) #443

@RobertLD

Description

@RobertLD

Remaining SonarCloud issues — small groups

Collected smaller rule groups (≤9 occurrences each) into a single issue.

S7755 — Prefer .at() over bracket index (9 issues, MINOR)

Replace `arr[arr.length - 1]` with `arr.at(-1)` in src/core/indexing.ts, packs.ts, and test files.

S4325 — Unnecessary type assertions (7 issues, MINOR)

Remove redundant `as Type` casts in tests/unit/watcher.test.ts, reindex.test.ts, src/web/server.ts, and test files.

S3863 — Duplicate imports (6 issues, MINOR)

Merge duplicate import statements in tests/unit/batch-search.test.ts, src/cli/index.ts, tests/unit/obsidian.test.ts.

S7748 — Zero fraction in numbers (6 issues, MINOR)

Replace `1.0` with `1` in src/core/search.ts, tags.ts, dedup.ts.

S7778 — Multiple Array#push calls (5 issues, MINOR)

Combine consecutive `.push(a); .push(b)` into `.push(a, b)` in src/core/search.ts, parsers/csv.ts, tests/unit/api.test.ts.

S7760 — Prefer default parameters (3 issues, MAJOR)

Replace `param = param ?? default` with default parameter syntax in src/core/tags.ts, src/connectors/onenote.ts.

S6535 — Unnecessary regex escape (2 issues, MAJOR)

Remove unnecessary `/` escapes in src/web/dashboard.ts.

S8233 — GitHub Actions permissions (2 issues, MAJOR)

Move write permissions from workflow level to job level in .github/workflows/release-please.yml.

S7746 — Return value directly instead of Promise.resolve (2 issues, MAJOR)

Replace `return Promise.resolve(value)` with `return value` in tests/fixtures/mock-provider.ts.

S4623 — Redundant undefined (2 issues, MAJOR)

Remove redundant `undefined` arguments in tests/unit/reporter.test.ts, api.test.ts.

S4323 — Extract union type alias (2 issues, MINOR)

Create type aliases for inline union types in src/cli/index.ts, tests/unit/api.test.ts.

Single-occurrence rules:

  • S107: `handlePackConflict` has 8 params → bundle into options (src/cli/index.ts:282)
  • S6594: Use `RegExp.exec()` instead of `String.match()` (src/cli/commands/registry.ts:44)
  • S1135: Complete TODO comment (tests/unit/registry/types.test.ts:141)
  • S7744: Remove useless empty object (src/connectors/http-utils.ts:40)
  • S7776: Use Set instead of array for `docTags` (src/core/bulk.ts:78)
  • S4822: Await promise inside try block (src/core/packs.ts:532)
  • S2933: Mark `jobs` as `readonly` (src/core/scheduler.ts:69)
  • S3735: Remove `void` operator (src/core/scheduler.ts:127) — conflicts with ESLint no-floating-promises; suppress with inline comment
  • S4144: Deduplicate identical test function (tests/unit/obsidian.test.ts:631)
  • S7767: Use `Math.trunc` instead of `| 0` (tests/fixtures/mock-provider.ts:28)
  • S7758: Use `codePointAt` over `charCodeAt` (tests/fixtures/mock-provider.ts:28)
  • S7769: Use `Math.hypot` over `Math.sqrt` (tests/fixtures/mock-provider.ts:35)
  • S7785: Use top-level await (src/mcp/server.ts:1348)

Python SDK (3 issues, MAJOR)

  • S1244: Float equality checks in sdk/python/tests/test_client.py:46, test_models.py:53,98 → use `pytest.approx()`

Total: 59 issues across ~35 rules

Severity: Mixed (MAJOR/MINOR) | Effort: ~2-3hrs mechanical

Metadata

Metadata

Assignees

No one assigned

    Labels

    tech-debtCode quality and technical debt

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions