Skip to content

jankowiakdawid/abc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ABC Metrics Tool

A command-line tool for measuring Assignment, Branch, Condition (ABC) metrics in code.

Overview

ABC Metrics is a code complexity measurement that quantifies a method's complexity based on:

  • A: Number of assignments
  • B: Number of branches (function calls)
  • C: Number of conditions (if/else, loops, etc.)

The ABC score is calculated as sqrt(A² + B² + C²).

Understanding ABC Metrics

ABC Metrics provide a quantitative measure of code complexity:

  • Low (< 10): Simple, well-structured code
  • Medium (10-20): Moderately complex code
  • High (20-40): Complex code that may need refactoring
  • Very High (> 40): Overly complex code that should be refactored

Prerequisites

  • Go 1.22 or higher
  • Git (for cloning the repository)

Installation

From Source

# Clone the repository
git clone https://github.com/your-username/abc-metrics.git

# Navigate to the project directory
cd abc-metrics

# Build the project
go build -o abc ./cmd/abc

Build Options

# Build with custom output name
go build -o my-abc ./cmd/abc

# Build for different platforms
# Linux
GOOS=linux GOARCH=amd64 go build -o abc ./cmd/abc

# macOS
GOOS=darwin GOARCH=amd64 go build -o abc ./cmd/abc

# Windows
GOOS=windows GOARCH=amd64 go build -o abc.exe ./cmd/abc

Development Build

# Install dependencies
go mod download

# Run tests
go test ./...

# Run the application directly without building
go run ./cmd/abc analyze -f path/to/your/file.go

Usage

# Analyze a single file
./abc analyze -f path/to/your/file.go

# Alternative syntax
./abc analyze path/to/your/file.go

# Enable verbose output
./abc analyze -f path/to/your/file.go -v

# Show detailed breakdown of metrics
./abc analyze -f path/to/your/file.go --show

Supported Languages

Currently, the tool supports:

  • Go (.go files)
  • TypeScript (coming soon)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Analyzes code with ABC Metric

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published