https://github.com/halleck45/ast-metrics
AST Metrics is a language-agnostic static code analyzer.
https://github.com/halleck45/ast-metrics
quality static-analysis
Last synced: 11 days ago
JSON representation
AST Metrics is a language-agnostic static code analyzer.
- Host: GitHub
- URL: https://github.com/halleck45/ast-metrics
- Owner: Halleck45
- License: mit
- Created: 2023-11-03T14:29:26.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-09-17T07:57:27.000Z (29 days ago)
- Last Synced: 2025-09-17T08:35:47.562Z (29 days ago)
- Topics: quality, static-analysis
- Language: Go
- Homepage: https://halleck45.github.io/ast-metrics/
- Size: 30.8 MB
- Stars: 99
- Watchers: 5
- Forks: 12
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
![]()
AST Metrics is a multi-language static code analyzer.
It provides architectural insights, complexity metrics, and activity analysis - all in a fast, standalone binary ready for CI/CD.
Documentation | Contributing | Twitter
HTML Report
CLI
![]()
![]()
## Getting Started
Open your terminal and run the following command:
```console
curl -s https://raw.githubusercontent.com/Halleck45/ast-metrics/main/scripts/download.sh|bash
./ast-metrics analyze --report-html= /path/to/your/code
```> To install it manually follow the detailed [installation instructions](https://halleck45.github.io/ast-metrics/getting-started/install/).
## Linting your code
Run:
```bash
# create a .ast-metrics.yaml config file
ast-metrics init# Add ruleset to your config file
ast-metrics ruleset add architecture
ast-metrics ruleset add volume
ast-metrics ruleset list # see the list of available rulesets# Run the linter
ast-metrics lint
```You can declare thresholds in your YAML config (*Lines of code per method, Coupling, Maintainability...*).
Example:
```yaml
requirements:
rules:
architecture:
coupling:
forbidden:
- from: Controller
to: Repository
- from: Repository
to: Service
max_afferent_coupling: 10
max_efferent_coupling: 10
min_maintainability: 70
volume:
max_loc: 1000
max_logical_loc: 600
max_loc_by_method: 30
max_logical_loc_by_method: 20
complexity:
max_cyclomatic: 10
golang:
no_package_name_in_method: true
max_nesting: 4
max_file_size: 1000
max_files_per_package: 50
slice_prealloc: true
ignored_error: true
context_missing: true
context_ignored: true
```This makes it **easy to enforce architecture and quality at scale**.
Run `ast-metrics ruleset list` to see the list of available rulesets. Then `ast-metrics ruleset add ` to apply a ruleset to your project.
## CI usage
Use the dedicated CI command to run lint and generate all reports in one go:
```bash
ast-metrics ci [options] /path/to/your/code
```Notes:
- This command runs the linter first, then generates HTML, Markdown, JSON, OpenMetrics and SARIF reports.
- If any lint violations are found, the command exits with a non-zero status but still produces the reports.
- The previous alias `analyze --ci` is deprecated and will display a warning. Please migrate to `ast-metrics ci`.## Github Action
Create a `.github/workflows/ast-metrics.yml` file in your project with the following content:
```yaml
name: "AST Metrics"
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: halleck45/action-ast-metrics@v1
```## Why AST Metrics?
- **Catch issues early**: detect complex or tightly coupled code.
- **Ensure architectural coherence**: validate dependencies and layering.
- **Understand your project at scale**: from cyclomatic complexity to bus factor.## Features
+ **Architectural analysis**: community detection, coupling, instability.
+ **Linter**: enforce coding standards and best practices.
+ **CI/CD ready**: plug into GitHub Actions, GitLab CI, or any pipeline.
+ **Fast & dependency-free**: single binary, no setup required.
+ **Code metrics**: complexity, maintainability, size.
+ **Activity metrics**: commits, bus factor.
+ **Readable reports**: detailed HTML dashboards.[Read more in the documentation](https://halleck45.github.io/ast-metrics/)
## Supported languages
+ ✅ **Golang** `any version`
+ ✅ **Python** `Python 2, Python 3`
+ ✅ **Rust** `any version`
+ ✅ **PHP** `<= PHP 8.4`
+ 🕛 **TypeScript**
+ 🕛 **Flutter**
+ 🕛 **Java**
+ 🕛 **C++**
+ 🕛 **Ruby**## License
AST Metrics is open-source software [licensed under the MIT license](LICENSE)
## Contributing
AST Metrics is an actively evolving project.
We welcome discussions, bug reports, and pull requests.
➡️ Start [contributing here](.github/CONTRIBUTING.md)