find-mismatch

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Find Mismatch

查找不匹配问题

Walk through every file. Focus only on runtime failures/bugs. Do NOT report style, formatting, performance suggestions, docs/tests, or "consider using X".
遍历所有文件。仅关注运行时故障/Bug。不要报告样式、格式、性能建议、文档/测试相关问题,或「建议使用X」这类内容。

1. Process

1. 流程

  1. JS/TS (Pre-check): Run static analysis.
    • Check if installed:
      fallow --version
      .
    • Install globally if missing:
      npm install -g fallow
      .
    • Execute audit:
      fallow audit --format json --quiet
      .
    • Filter findings by git status:
      git diff --staged --name-only
      .
    • If staged: auto-apply safe fixes, re-run audit to verify.
    • If unstaged: report-only (no modification).
  2. Review Checklist: Apply checklist to all changes.
  3. Report: Format findings using the specified template.

  1. JS/TS(预检查):执行静态分析。
    • 检查是否已安装:
      fallow --version
      。
    • 若缺失则全局安装:
      npm install -g fallow
      。
    • 执行审计:
      fallow audit --format json --quiet
      。
    • 按git状态过滤结果:
      git diff --staged --name-only
      。
    • 若为暂存文件:自动应用安全修复,重新运行审计验证。
    • 若为未暂存文件:仅报告问题(不修改代码)。
  2. 审查清单:对所有变更应用审查清单。
  3. 报告:使用指定模板格式化问题结果。

2. Checklist Categories

2. 清单分类

1. Cross-Boundary Contracts

1. 跨边界契约

  • Calling mismatch: Check RPC, HTTP, IPC, event name/subject match receiver.
  • Param names/types:
    userId
    vs
    user_id
    , string vs number, flat vs wrapped.
  • Return type: Field accesses (
    result.field
    ) must match return signature.
  • 调用不匹配:检查RPC、HTTP、IPC、事件名称/主题是否与接收方匹配。
  • 参数名称/类型:
    userId
    与
    user_id
    不统一、字符串与数字类型混淆、扁平结构与封装结构不匹配。
  • 返回类型:字段访问(
    result.field
    )必须与返回签名一致。

2. Serialization & Deserialization

2. 序列化与反序列化

  • Casing:
    snake_case
    in DB/backend vs
    camelCase
    in JSON/frontend.
  • Optionals: Field expected by receiver but optional in producer.
  • Enums/discriminators: Discriminant fields (
    type
    ,
    kind
    ) and variants match.
  • Base64: Double-encoding layers.
  • 命名风格:数据库/后端的
    snake_case
    与JSON/前端的
    camelCase
    不统一。
  • 可选字段:接收方要求必填的字段,在生产方是可选的。
  • 枚举/鉴别器:鉴别字段(
    type
    、
    kind
    )与枚举值是否匹配。
  • Base64:多层重复编码问题。

3. Logic Bugs

3. 逻辑Bug

  • Double counting: Counters incremented both in loop/branch and outside.
  • Off-by-one: Index, pagination bounds (
    page <= total
    vs
    page < total
    ).
  • Conditions: Redundant/dead flags, unreachable statements, shadowed variables.
  • 重复计数:计数器在循环/分支内和外部都执行了递增。
  • 差一错误:索引、分页边界错误(如
    page <= total
    与
    page < total
    混淆)。
  • 条件问题:冗余/无效标志、不可达语句、变量遮蔽。

4. Property & Method Access

4. 属性与方法访问

  • Null derefs: Method calls or array index access (
    items[0].name
    ) without null/length checks.
  • Optional chaining: Stop check too early (e.g.
    user?.address.street
    still crashes if
    address
    is null).
  • This context: Callback bindings in classes.
  • 空指针解引用:未做空值/长度检查就调用方法或访问数组索引(
    items[0].name
    )。
  • 可选链:检查终止过早(例如
    user?.address.street
    在
    address
    为null时仍会崩溃)。
  • This上下文:类中的回调绑定问题。

5. Async & Concurrency

5. 异步与并发

  • Race conditions: Shared mutable states, parallel filesystem accesses without coordination.
  • Missing
    await
    : Promise ignored, silent errors.
  • Leaks: File/DB/network connections not closed in error paths.
  • 竞态条件:共享可变状态、无协调的并行文件系统访问。
  • 缺失
    await
    :Promise被忽略,错误静默丢失。
  • 资源泄漏:错误路径下未关闭文件/数据库/网络连接。

6. CSS & Styling

6. CSS与样式

  • HSL variables: Raw HSL components (
    0 0% 100%
    ) instead of functional format (
    hsl(0 0% 100%)
    ) fail in Tailwind v4 (unlike v3).
  • Inline themes: Circular references, selector mismatch (class vs data-theme).
  • HSL变量:使用原始HSL分量(
    0 0% 100%
    )而非函数格式(
    hsl(0 0% 100%)
    ),会在Tailwind v4中失效(v3中支持)。
  • 内联主题:循环引用、选择器不匹配(class与data-theme混淆)。

7. Placeholder & Stub Code

7. 占位符与存根代码

  • Unused declarations/files/dependencies, TODO comments, empty catch blocks.

  • 未使用的声明/文件/依赖、TODO注释、空catch块。

3. Language-Specific Pitfalls

3. 各语言特有陷阱

  • Python: Hallucinated library methods (pandas, numpy, requests), sync/asyncio confusion, mutable default arguments (
    def f(x=[])
    ), silent indentation drops.
  • JS/TS: Backend (Node) vs Frontend (Browser) API mix-ups,
    any
    abuse, type-only import mismatches, barrel file false positives (exported but unused in production, used in tests/libraries).
  • C++: Raw vs smart pointer mix-ups, missing standard library header
    #include
    , uninitialized variables, buffer overflows.
  • Rust: Borrow checker lifetime overcomplication,
    unwrap()
    on
    None
    /
    Err
    , locking across
    .await
    yield points.
  • Java / .NET: Hallucinated annotations/attributes, LINQ N+1 queries, Entity Framework model snapshot drift / missing migrations (check model changes under
    Entities/
    against
    Migrations/
    ).
  • Go: WaitGroup/Channel deadlocks, unexported struct fields in JSON, defer in loop, map concurrent access.
  • PHP: Loose type comparisons (
    ==
    vs
    ===
    ), array vs object access, key undefined.

  • Python:臆造的库方法(pandas、numpy、requests)、sync/asyncio混用混淆、可变默认参数(
    def f(x=[])
    )、缩进意外丢失。
  • JS/TS:后端(Node)与前端(Browser)API混淆、
    any
    滥用、仅类型导入不匹配、桶文件误报(导出的内容在生产环境未使用,仅在测试/库中使用)。
  • C++:裸指针与智能指针混用、缺失标准库头文件
    #include
    、变量未初始化、缓冲区溢出。
  • Rust:借用检查器生命周期过度复杂、对
    None
    /
    Err
    调用
    unwrap()
    、跨
    .await
    挂起点持有锁。
  • Java / .NET:臆造的注解/特性、LINQ N+1查询问题、Entity Framework模型快照漂移/缺失迁移(需对比
    Entities/
    下的模型变更与
    Migrations/
    目录)。
  • Go:WaitGroup/Channel死锁、JSON序列化时结构体字段未导出、循环中使用defer、map并发访问问题。
  • PHP:松散类型比较(
    ==
    与
    ===
    混淆)、数组与对象访问混淆、键未定义。

4. Fallow Finding Mapping & Fixes

4. Fallow问题映射与修复方案

Fallow TypeChecklist CategoryAuto-Fix Action
unused_exports
Placeholder & StubRemove
export
(if used locally) or entire declaration.
unused_files
Placeholder & StubDelete file (check dynamic imports first).
unused_dependencies
Placeholder & StubRemove dependency from
package.json
.
circular_dependencies
Cross-BoundaryDefer to manual review (causes init bugs).
complexity
/
duplication
Logic BugsDefer to manual review.

Fallow 问题类型对应清单分类自动修复操作
unused_exports
占位符与存根移除
export
(若本地有使用)或删除整个声明。
unused_files
占位符与存根删除文件(先检查是否有动态导入)。
unused_dependencies
占位符与存根从
package.json
中移除依赖。
circular_dependencies
跨边界契约转人工审查(会导致初始化Bug)。
complexity
/
duplication
逻辑Bug转人工审查。

5. Output Format

5. 输出格式

Include
## Review Summary
header (only if JS/TS project):
undefined
包含
## Review Summary
标题(仅JS/TS项目需要):
undefined

Review Summary

Review Summary

  • Manual review bugs found: N
  • Fallow auto-fixed: N findings (staged files only)
  • Fallow non-auto-fixable: N findings
  • Fallow verdict: pass / fail

Format individual findings (add `[fallow]` tag for fallow-sourced bugs):
  • Manual review bugs found: N
  • Fallow auto-fixed: N findings (staged files only)
  • Fallow non-auto-fixable: N findings
  • Fallow verdict: pass / fail

单个问题的格式如下(fallow检出的Bug需添加`[fallow]`标签):

Bug #1

Bug #1

  • File: <path>:<line>
  • Category: <category>
  • What's wrong: <description>
  • Runtime effect: <effect>
  • Fix: <code>
undefined
  • File: <path>:<line>
  • Category: <category>
  • What's wrong: <description>
  • Runtime effect: <effect>
  • Fix: <code>
undefined