code-complexity: nested callbacks are counted into the enclosing function, and object-literal-returning functions are never measured

オープン
#430 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
typescript
領域
tooling

調査の方向性

Start with code-complexity-control.ts, especially lines 274–276, 336–365, and the file and function count checks at 130–174; read how the detector currently strips comments and finds function bodies. The issue suggests using TypeScript AST function-like nodes and ESLint’s complexity rule as a reference. Done means nested callbacks and literals no longer distort each function’s score, object-literal-returning functions are measured, and existing debt above 10 remains reported.

索引モデルが 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

  • worstFunctionComplexity scores the brace body including inner functions (code-complexity-control.ts:336-365): 16 of 121 "function complexity" findings are an outer function charged with its callbacks (e.g. a score of 13 for a function whose own complexity is about 3).
  • Keywords, ?, || and braces inside strings/regex literals are counted and used for brace matching (only comments are stripped, :274-276): 23 more findings, e.g. a "function" scored 39 because brace matching ran on for 200 lines.
  • The other way round: a function whose return type is a multi-line object literal is never measured (admitted in the comment at :339-343); in already-flagged files this hides at least 12 functions over 10 (e.g. error-handling-completeness.ts:106, own complexity 22).
  • File length counts comment and blank lines (:130-139) and applies to data/constant tables; "too many functions" is a per-file ceiling independent of complexity (:148-174). These are threshold questions for the maintainers.

The detector reproduces exactly (121 of 121 worst-function numbers); 82 functions are genuinely over 10 and stay as debt.

Suggested direction

Standard per-function cyclomatic complexity of each function's own body (as ESLint's complexity rule), from the TypeScript AST; measure every function-like node.

主要言語
TypeScript
スター
0
フォーク
0
平均マージ
38分
マージ済み PR(30日)
96

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Rule-Of-Code/RoC のほかの issue

Rule-Of-Code/RoC の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。