phodal / coca

Coca is a toolbox which is design for legacy system refactoring and analysis, includes call graph, concept analysis, api tree, design patterns suggest. Coca 是一个用于系统重构、系统迁移和系统分析的工具箱。它可以分析代码中的测试坏味道、模块化分析、行数统计、分析调用与依赖、Git 分析以及自动化重构等。
https://coca.migration.ink/
Mozilla Public License 2.0
957 stars 110 forks source link

how use in golang project #28

Closed kangyujian closed 1 year ago

kangyujian commented 1 year ago
  1. cd my_project,my_project is a golang project
  2. go mod tidy, get the depend of the project
  3. coca analysis
  4. show nothing
    2022/11/16 10:35:43 profile: cpu profiling enabled, /var/folders/f6/x0fpn6ws1psbrv1jkrz_vvr40000gp/T/profile536435785/cpu.pprof
    | REFS COUNT | METHOD |
    |------------|--------|
    App elapsed:  824.074µs
    2022/11/16 10:35:43 profile: cpu profiling disabled, /var/folders/f6/x0fpn6ws1psbrv1jkrz_vvr40000gp/T/profile536435785/cpu.pprof
phodal commented 1 year ago

the Golang support was removed, the parsed exist in https://github.com/modernizing/coca/tree/master/pkg/infrastructure/ast/ast_go

kangyujian commented 1 year ago

thank for your suggest. I want input a golang project local path , and get the function was called count each method, weather I can use your project. the main reason is to analysis code coupling in golang project. 感谢您的建议,我这边希望输入一个golang项目的本地路径,希望获取到项目中每一个函数被引用的次数,用此来检测代码的耦合度,请问您有一些工具或者方法吗?我自己尝试写,不太能写出来。

phodal commented 1 year ago

理论上用 Coca 也可以实现,Coca 里的 Go 解析已经移动到这里了:https://github.com/modernizing/chapi

不过,我觉得直接去找基于 Golang parser 的依赖分析工具会比 Antlr 写的靠谱得多,至少语言版本是最新的。Antlr 适用于跨语言的,详细可以看这个:https://github.com/modernizing/modernization