Releases: ysk8hori/typescript-graph
v0.19.1
v0.19.0
v0.18.0
🚀 Code Metrics (ベータ版) が登場!
--metrics
オプションを使って、コードの複雑さや保守性を測定可能にしました。以下のメトリクスが計測可能です:
📊 保守容易性指数 (Maintainability Index)
以下のリソースを参考に、保守容易性指数の計測を実装しました:
Maintainability Index は 0〜100 までの値であり、関数やクラスのメソッドにおいては 20 を下回ると注意表示、10を下回ると警告表示となります。
TypeScript Graph オリジナル仕様:
- Cyclomatic Complexity と Cognitive Complexity を等価に考慮。
- Halstead Volume の代わりに「意味のある構文要素量」を使用した Semantic Syntax Volume を採用。
🔄 循環的複雑度 (Cyclomatic Complexity)
コード内の線形的に独立した経路数を直接数えるメトリクスです。(wiki)
🧠 認知的複雑度 (Cognitive Complexity)
SonarSource 社の G. Ann Campbell 氏によるホワイトペーパー「A new way of measuring understandability」を参考に実装しています。
※このプロジェクトは SonarSource 社と提携していません。
📏 行数 (Lines)
対象コードの行数を単純にカウントします。
📐 Semantic Syntax Volume
Halstead Volume の代替として、意味のある構文ノードを用いて計測した指標です。この方法を Semantic Syntax Volume と呼びます。
その他
オペランド数や Semantic Syntax 数も計測可能です。
🚀 Introducing Code Metrics (Beta)!
With the --metrics
option, you can now measure code complexity and maintainability. The following metrics are available:
📊 Maintainability Index
We implemented the Maintainability Index based on the following references:
- Microsoft's Code Metrics Values
- Maintainability Index Range and Meaning
- IBM's Maintainability Index Report
TypeScript Graph Custom Features:
- Equal consideration of Cyclomatic Complexity and Cognitive Complexity.
- Replaced Halstead Volume with a metric based on "meaningful syntax nodes," named Semantic Syntax Volume.
🔄 Cyclomatic Complexity
This metric counts the number of linearly independent paths through the code. (wiki)
🧠 Cognitive Complexity
Implemented following G. Ann Campbell's white paper “A new way of measuring understandability” by SonarSource.
※ This project is not affiliated with SonarSource.
📏 Lines
Simple count of the total lines of code.
📐 Semantic Syntax Volume
Instead of Halstead Volume, this metric measures "meaningful syntax nodes" in the code. We refer to this approach as Semantic Syntax Volume.
Additional Metrics
Operands and Semantic Syntax counts are also available.
例えば、 TypeScript Graph のプロジェクトの Metrics は以下のように出力されます。
tsg --metrics
Code Metrics
file | scope | name | Maintainability Index | Cyclomatic Complexity | Cognitive Complexity | lines | semantic syntax volume | total operands | unique operands | total semantic syntax | unique semantic syntax |
---|---|---|---|---|---|---|---|---|---|---|---|
src/graph/createGraph.ts | file | - | 13.19 | 32 | 50 | 277 | 10010.82 | 591 | 179 | 678 | 58 |
src/graph/createGraph.ts | function | analyzeSoucreFile | 33.61 | 16 | 29 | 68 | 2186.21 | 157 | 61 | 175 | 35 |
src/graph/createGraph.ts | function | createGraphForVue | 34.96 | 4 | 6 | 74 | 2337.19 | 166 | 77 | 180 | 31 |
src/graph/createGraph.ts | function | createGraph | 39.65 | 6 | 5 | 49 | 1771.08 | 122 | 66 | 144 | 35 |
src/graph/createGraph.ts | function | getVueAndTsFilePathsRecursive | 45.6 | 3 | 5 | 39 | 544.63 | 48 | 33 | 49 | 16 |
src/graph/createGraph.ts | function | getName | 54.16 | 5 | 2 | 17 | 442.8 | 37 | 17 | 48 | 20 |
src/graph/createGraph.ts | function | getFilePath | 63.42 | 2 | 2 | 8 | 235.56 | 21 | 11 | 28 | 17 |
src/graph/createGraph.ts | function | findNode | 74.54 | 1 | 0 | 3 | 138.24 | 11 | 7 | 20 | 15 |
src/graph/createGraph.ts | function | removeSlash | 75.51 | 2 | 1 | 3 | 96 | 10 | 6 | 14 | 10 |
src/mermaidify.ts | file | - | 13.9 | 26 | 41 | 291 | 9482.75 | 551 | 139 | 675 | 74 |
src/mermaidify.ts | function | createDirAndNodesTree | 31.09 | 9 | 19 | 94 | 2660.94 | 171 | 52 | 242 | 35 |
src/mermaidify.ts | function | addGraph | 39.46 | 8 | 9 | 51 | 1457.45 | 109 | 48 | 119 | 36 |
src/mermaidify.ts | function | mermaidify | 40.91 | 9 | 9 | 48 | 1068 | 88 | 41 | 90 | 23 |
src/mermaidify.ts | function | writeRelations | 48.35 | 3 | 4 | 26 | 796.32 | 66 | 24 | 79 | 21 |
src/mermaidify.ts | function | addLink | 53.87 | 1 | 0 | 18 | 465.12 | 40 | 22 | 48 | 17 |
src/mermaidify.ts | function | writeFileLink | 66.46 | 1 | 0 | 7 | 140.55 | 13 | 9 | 19 | 12 |
src/mermaidify.ts | function | fileNameToMermaidId | 66.92 | 1 | 0 | 6 | 195.04 | 17 | 13 | 25 | 12 |
src/mermaidify.ts | function | writeFileNodesWithSubgraph | 68.37 | 1 | 0 | 6 | 121.01 | 11 | 8 | 17 | 12 |
src/mermaidify.ts | function | fileNameToMermaidName | 76.76 | 1 | 0 | 3 | 66.61 | 7 | 6 | 11 | 7 |
src/metrics/calculateCodeMetrics.ts | file | - | 17.59 | 18 | 16 | 268 | 7555.93 | 447 | 165 | 520 | 60 |
src/metrics/calculateCodeMetrics.ts | function | calculateCodeMetrics | 35.15 | 6 | 4 | 73 | 2294.7 | 165 | 86 | 169 | 31 |
src/metrics/calculateCodeMetrics.ts | function | convert | 37.13 | 2 | 0 | 73 | 1426.48 | 120 | 43 | 116 | 23 |
src/metrics/calculateCodeMetrics.ts | function | hoge | 45.68 | 2 | 2 | 40 | 535.29 | 37 | 17 | 65 | 21 |
src/metrics/calculateCodeMetrics.ts | function | getFilePath | 63.42 | 2 | 2 | 8 | 235.56 | 21 | 11 | 28 | 17 |
src/metrics/calculateCodeMetrics.ts | function | getMarker | 64.24 | 3 | 1 | 10 | 89.92 | 9 | 8 | 13 | 9 |
src/metrics/calculateCodeMetrics.ts | function | getFileMIStatus | 69.78 | 3 | 2 | 5 | 122.98 | 11 | 9 | 17 | 12 |
src/metrics/calculateCodeMetrics.ts | function |
v0.17.3
v0.17.2
v0.17.1
v0.17.0
🌟 Experimental support Vue [0.17.0](v0.16.2...v0.17.0) (2024-11-29)
with ChatGPT
新機能
-
creategraph: Vueの解析がついに可能に! ([d39e54f](d39e54f))
Vueユーザーの君、待たせたわね。これからは君のフロントエンドだってしっかりサポートしてあげるわ。 -
option:
.vue
ファイルを解析するかどうかを、vueフラグでお好み設定! ([5e8c09a](5e8c09a))
Issue [#207](https://github.com/ysk8hori/typescript-graph/issues/207)を華麗にクローズ。 自由自在のカスタマイズで、もっと自分らしくコントロールするのよ。
新規コントリビューター
完全な変更履歴はこちら: [Changelog](https://github.com/ysk8hori/typescript-graph/compare/v0.16.2...v[0.17.0](https://github.com/ysk8hori/typescript-graph/compare/v0.16.2...v0.17.0))
🌟 0.17.0 (2024-11-29)
Features
-
creategraph: Now you can analyze Vue files like a pro! ([d39e54f](d39e54f))
For all you Vue devs out there, we’ve got your back. You’re welcome. -
option: Toggle Vue file analysis with the
vue
flag ([5e8c09a](5e8c09a))
Closed Issue [#207](#207). Customization at your fingertips—flex your workflow as you see fit.
New Contributors
- @roottool made their debut! Thanks for your awesome contribution. ([PR #204](#204))
Fresh talent, driving innovation like never before.
Check out the full changelog here: [Changelog](v0.16.2...v0.17.0)
What's Changed
- Fix typo by @roottool in #204
- chore(deps): update actions/checkout digest to cbb7224 by @renovate in #205
- chore(deps): update all minor and patch dependencies by @renovate in #206
- chore(deps): update all minor and patch dependencies by @renovate in #208
- chore(deps): update dependency typescript to v5.7.2 by @renovate in #209
- chore(deps): update eslint related packages by @renovate in #210
- Support vue (experimental) by @ysk8hori in #213
New Contributors
Full Changelog: v0.16.2...v0.17.0