百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

complexity

> 开发工具
开源

一个命令行工具,用于识别复杂代码

171 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

一个命令行工具,用于识别复杂代码

complexity

Calculate an approximation of code complexity per file in a language-agnostic way.

Motivation

If you're new to a codebase, it's helpful to understand at a glance what files may be particularly complex. With that guidance, developers can more quickly read through the code to understand hotspots.

At thoughtbot, we work in codebases of all shapes and languages, including Ruby, Elixir, Python, Scala, TypeScript/JavaScript, Go, Elm, Swift, and Java. This CLI tool aims to highlight complexity across any of these codebases by assigning simple heuristics to increases in indentation.

This concept has been discussed in this paper; complexity does not intend to mimic approaches in this paper directly, although the motivations discussed in the paper – especially avoiding calculating cyclomatic complexity (McCabe) given requirements of AST parsing and analysis due to time and language requirements – are of considerable overlap.

Installation

MacOS with Homebrew

bash
brew tap thoughtbot/formulae
brew install complexity

Configuration

complexity has configuration options to ignore certain file extensions or substrings with paths.

To install this default configuration, run:

bash
complexity install-configuration

This creates/overwrites a yaml configuration at $HOME/.config/complexity/complexity.yml.

By default, extensions including lock, toml, json, and md are ignored.

complexity will automatically honor .gitignore settings.

Usage

Basic

Let's grab the 20 most complex files:

bash
complexity | sort -n --reverse | head -n 20

Within the Discourse codebase, for example, here's what the output might look like:

…

Advanced

complexity supports alternative formatting options, like JSON and CSV. Additionally, you can limit results by substring with the --only flag, or modify paths to ignore with --ignore.

bash
// This filters the .rs files inside all directories and outputs scores in a json format
complexity --format json --only .rs

// This filters the .rs and .md files inside all directories
complexity --only .rs,.md

// This filters all the files inside src/scoring directory
complexity --only src/scoring

You can view the full suite of options by running complexity help.

License

Copyright 2020 Josh Clayton and thoughtbot, inc. See the LICENSE.

Issues· 5 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rustclicode-analysiscomplexityrust

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类开发工具
定价开源

> 相关工具

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具