env-var usage analyzer: fallback judged by the first occurrence, CI-provided variables flagged, URLs counted twice

未关闭
#433 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript
领域
devtools

调研方向

Start with environment-variables-usage-configuration.ts around lines 27, 57, 174–185, then read git-law-base.ts around lines 78–90 and environment-files-analyzer-validation.ts around lines 59 and 105. The issue describes several analyzer behaviors to investigate; identify the relevant tests or add focused coverage for each. Done when variable handling, CI-provided variables, URL counting, and missing .env.example findings match the suggested direction.

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

描述

bug

Found in the 8.0.0 self-audit triage: RoC 7.29.1 (npm, 5fc54afe) on a clean clone of develop at 2d2fa9a, with typescript resolvable (verdict compliance, 0 failed / 46 warnings). The bucket method and per-law tables are kept by QA; counts are from that run.

What happens

EnvironmentVariablesUsageAnalyzer (shared by Environment Security and Environment Parity, so every finding is counted in both laws):

  • the fallback window for every occurrence of a variable is taken at content.indexOf(match) — 50 chars before, 100 after the first occurrence (environment-variables-usage-configuration.ts:174-177);
  • "fallback" is a substring search for ||, ??, ? , default (:27, :185); real handling such as candidate?.trim(); if (!name) continue; or process.env.NODE_ENV !== 'production' is not recognised (git-law-base.ts:78-90 reads CI branch variables and skips undefined);
  • three overlapping URL regexes (:57) report one quoted URL twice (bare host and full string); doc-reference URLs count as endpoints;
  • .env.example missing is reported by two analyzers (environment-files-analyzer-validation.ts:59 and :105).

Suggested direction

Judge each process.env.X read at its own offset, ideally from the AST, and treat ?., ??, ||, comparisons and truthiness guards as handled; do not report well-known CI-provided variables as missing fallbacks; one URL pass de-duplicated by position; one .env.example finding.

主要语言
TypeScript
星标
0
派生
0
平均合并
38 分钟
30 天内合并 PR
96

环境准备

从这里开始

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

Rule-Of-Code/RoC 的其他 Issue

查看 Rule-Of-Code/RoC 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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