Skip to content

refactor: resolve DeepSource findings for require imports and dynamic delete - #328

Merged
pascalre merged 2 commits into
masterfrom
feat/deepsource-smells
Nov 20, 2026
Merged

pascalre merged 2 commits into
masterfrom
feat/deepsource-smells

Conversation

@pascalre

Copy link
Copy Markdown
Owner

What changed

  • vs-code-adapter.test.ts: import path = require("path") replaced by import { resolve } from "path". The test runner uses import * as Mocha from "mocha", which compiles to the same require() call. nyc (no type definitions) and sonar-project.js (plain node script) keep require() with a justified eslint-disable comment.
  • YamlUtil.sortYaml(): the custom sort no longer deletes keys from the loaded document. The document is typed as unknown instead of any, the custom sort applies to mappings only, each keyword is dumped by the new dumpKeyword(), and the remaining keys are built as a new object.
  • Enabled @typescript-eslint/no-require-imports and @typescript-eslint/no-dynamic-delete in .eslintrc.js.

Why

DeepSource reported two code smells after #327:

  • "Require statement not part of import statement" (src/test/suite/adapter/vs-code-adapter.test.ts:2)
  • "Do not delete dynamically computed property keys" (src/util/yaml-util.ts:74)

With the lint rules, npm run lint and CI catch these before DeepSource does.

Testing

  • New characterization tests for the custom sort (keyword order, a document with only keywords, list and scalar documents), green before and after the refactoring.
  • tsc, eslint (with the new rules), dependency-cruiser and 207 tests pass locally. No behavior change.
  • Please rely on CI for the full Electron suite.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Jdb5is9YsMnteaxHryN26M

pascalre and others added 2 commits November 20, 2026 08:05
DeepSource reported "Require statement not part of import statement"
for `import path = require("path")` in vs-code-adapter.test.ts.

Use a named import there and `import * as Mocha` in the test runner,
which compiles to the same require() call. nyc ships no type
definitions and sonar-project.js is a plain node script, so both keep
their require() with a justified eslint-disable comment.

Enable @typescript-eslint/no-require-imports, so lint and CI catch
this before DeepSource does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jdb5is9YsMnteaxHryN26M
DeepSource reported "Do not delete dynamically computed property keys"
for `delete doc[key]` in the custom sort of YamlUtil.sortYaml(). The
loaded document was typed as `any` and mutated while the keywords were
dumped.

Type the loaded document as unknown, apply the custom sort only to
mappings, dump each keyword in the new dumpKeyword() and build the
remaining keys as a new object. Characterization tests cover keyword
order, a document with only keywords, list and scalar documents.

Enable @typescript-eslint/no-dynamic-delete, so lint and CI catch this
before DeepSource does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jdb5is9YsMnteaxHryN26M
@sonarqubecloud

Copy link
Copy Markdown

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 5 complexity · 0 duplication

Metric Results
Complexity 5
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@pascalre
pascalre merged commit beeecae into master Nov 20, 2026
10 of 11 checks passed
@pascalre
pascalre deleted the feat/deepsource-smells branch November 20, 2026 08:32
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.

1 participant