removed-api-usage: fromVersion-only config now fails every lint (exit 2)

未关闭 适合新手
#101 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
领域
testing, tooling

调研方向

阅读 src/lint/rules/removed-api-usage.ts:98-116 中的验证逻辑,以及 test/removed-api.test.ts 中的相关用例。运行报告中的复现步骤,然后为推断出的目标与显式 fromVersion 组合的情况添加测试。当该情况不再导致 lint 以退出码 2 中止,并符合一项已说明的验收标准时,即为完成;运行 npm run build && npm test。

由索引模型根据 Issue 内容生成。

描述

bug good first issue severity: medium

Summary

Since removed-api-usage infers targetVersion from project.godot (#91), a config that sets only options.fromVersion makes every lint run fail with exit 2, when the inferred target equals that fromVersion. The error message names targetVersion, an option the user never set.

Where

  • src/lint/rules/removed-api-usage.ts:98-116

Details

const target = ctx.options["targetVersion"] ?? pinnedVersionFor(ctx.projectGodotVersion ?? null);
...
const fromOpt = ctx.options["fromVersion"];
if (fromOpt !== undefined) {
  const others = PINNED_GODOT_VERSIONS.filter((v) => v !== target);
  if (typeof fromOpt !== "string" || !(others as readonly string[]).includes(fromOpt)) {
    throw new Error(`removed-api-usage: options.fromVersion must be one of ... when targetVersion is ${target} ...`);

Before #91 the rule was simply off without targetVersion, so {"fromVersion": "4.4"} was harmless. Now a project that declares 4.4 infers target = "4.4", and others is ["4.5"]. fromVersion: "4.4" is rejected and the rule throws, which aborts the run.

Impact

Existing configs that pre-set fromVersion (for example, to prepare for an upgrade) break CI with exit 2 after upgrading gdcorrect. The same happens if a project's declared version later changes to match fromVersion.

Steps to reproduce

  1. Set project.godot config/features=PackedStringArray("4.4", ...).
  2. Use the config {"rules": {"removed-api-usage": {"options": {"fromVersion": "4.4"}}}}.
  3. Run gdcorrect lint <project>: exit 2 with the message above.

Suggested fix

When targetVersion was inferred, not configured, and equals fromVersion, skip the rule (nothing to compare) instead of throwing. Otherwise mention the inference in the message, for example "targetVersion 4.4 (inferred from project.godot)".

Acceptance criteria

  • The repro returns no removed-api-usage findings and exit 0, or a clear message that names the inferred version.
  • A test covers an inferred target combined with an explicit fromVersion.

Getting started

  • Relevant files: src/lint/rules/removed-api-usage.ts, test/removed-api.test.ts
  • How to run tests: npm run build && npm test

Related: #91


Filed by repo-audit/full-audit at e836036. Severity: medium. Effort: S. audit-key: bug|src/lint/rules/removed-api-usage.ts|fromVersion

主要语言
TypeScript
星标
0
派生
6
平均合并
1 天 21 小时
30 天内合并 PR
8

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TMHSDigital/godot-correctness-mcp 的其他 Issue

查看 TMHSDigital/godot-correctness-mcp 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。