A GitHub Action for comprehensive code analysis using HowMany. This action provides detailed insights into code quality, complexity, maintainability, and development time estimates.
- π Comprehensive Analysis: Lines of code, complexity metrics, quality scores
- π Quality Gates: Fail builds based on configurable quality thresholds
- π PR Comments: Automatic pull request comments with analysis results
- π Multiple Formats: JSON, HTML, and SARIF output support
- π Fast Installation: Automatic installation of HowMany CLI
- π― Targeted Analysis: Support for specific file extensions and paths
- π GitHub Integration: Native integration with GitHub workflows
name: Code Analysis
on: [push, pull_request]
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: GriffinCanCode/howmany-action@v1
with:
path: '.'
output-format: 'json'
create-pr-comment: true| Input | Description | Required | Default |
|---|---|---|---|
path |
Directory to analyze | No | . |
output-format |
Output format: text, json, csv, html |
No | json |
show-files |
Show individual file statistics | No | false |
verbose |
Show detailed breakdown by extension | No | true |
max-depth |
Maximum directory depth to traverse | No | |
extensions |
Specific extensions to analyze (comma-separated) | No | |
include-hidden |
Include hidden files and directories | No | false |
sort-by |
Sort by: files, lines, code, comments, size |
No | lines |
descending |
Sort in descending order | No | true |
ignore-patterns |
Additional ignore patterns (comma-separated) | No |
| Input | Description | Required | Default |
|---|---|---|---|
cli-mode |
Use simple CLI mode for basic output | No | false |
min-lines |
Minimum lines per file to include | No | |
max-lines |
Maximum lines per file to include | No | |
min-size |
Minimum file size to include (e.g., 1KB, 500MB) | No | |
max-size |
Maximum file size to include (e.g., 1KB, 500MB) | No | |
only-languages |
Include only these languages (comma-separated) | No | |
exclude-languages |
Exclude these languages (comma-separated) | No | |
show-complexity |
Show complexity information in CLI mode | No | false |
show-quality |
Show quality scores in CLI mode | No | false |
show-time |
Show time estimates in CLI mode | No | false |
show-ratios |
Show code ratios in CLI mode | No | false |
show-size |
Show size information in CLI mode | No | false |
| Input | Description | Required | Default |
|---|---|---|---|
fail-on-quality-gate |
Fail if quality gate not met | No | false |
quality-threshold |
Minimum overall quality score (0-100) | No | 70 |
maintainability-threshold |
Minimum maintainability score (0-100) | No | 65 |
documentation-threshold |
Minimum documentation coverage (0-100) | No | 20 |
complexity-threshold |
Maximum average complexity per function | No | 10 |
| Input | Description | Required | Default |
|---|---|---|---|
create-pr-comment |
Create/update PR comment with results | No | true |
upload-sarif |
Generate SARIF report for Code Scanning | No | false |
artifact-name |
Name for uploaded report artifact | No | howmany-report |
| Input | Description | Required | Default |
|---|---|---|---|
howmany-version |
HowMany version to install | No | latest |
| Output | Description |
|---|---|
report-path |
Path to generated report file |
quality-score |
Overall quality score (0-100) |
maintainability-score |
Maintainability index score (0-100) |
documentation-score |
Documentation coverage score (0-100) |
complexity-score |
Average complexity per function |
total-files |
Total number of files analyzed |
total-lines |
Total lines of code |
code-lines |
Lines of actual code |
comment-lines |
Lines of comments |
passed |
Whether quality gate passed (true/false) |
recommendations |
Quality improvement recommendations (JSON) |
name: Code Analysis
on: [push, pull_request]
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Analyze code
uses: GriffinCanCode/howmany-action@v1
with:
path: './src'
verbose: truename: Quality Gate
on: [pull_request]
jobs:
quality-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Quality Gate
uses: GriffinCanCode/howmany-action@v1
with:
fail-on-quality-gate: true
quality-threshold: 80
maintainability-threshold: 70
documentation-threshold: 25
complexity-threshold: 8
create-pr-comment: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}name: Multi-Language Analysis
on: [push]
jobs:
analyze-backend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Analyze Rust Backend
uses: GriffinCanCode/howmany-action@v1
with:
path: './backend'
extensions: 'rs,toml'
artifact-name: 'backend-analysis'
analyze-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Analyze TypeScript Frontend
uses: GriffinCanCode/howmany-action@v1
with:
path: './frontend'
extensions: 'ts,tsx,js,jsx'
artifact-name: 'frontend-analysis'name: Filtered Analysis
on: [push]
jobs:
large-files-analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Analyze Large Files Only
uses: GriffinCanCode/howmany-action@v1
with:
min-lines: 100
min-size: '1KB'
only-languages: 'rs,py,ts'
cli-mode: true
show-complexity: true
show-quality: true
quick-stats:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Quick Stats Check
uses: GriffinCanCode/howmany-action@v1
with:
cli-mode: true
exclude-languages: 'md,txt,json,yaml'
show-size: true
show-ratios: truename: Generate Reports
on: [push]
jobs:
reports:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate HTML Report
uses: GriffinCanCode/howmany-action@v1
with:
output-format: 'html'
show-files: true
verbose: true
- name: Upload HTML Report
uses: actions/upload-artifact@v4
with:
name: howmany-html-report
path: howmany-reports/name: Security and Quality Scan
on: [push, pull_request]
jobs:
scan:
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- uses: actions/checkout@v4
- name: Code Quality Analysis
uses: GriffinCanCode/howmany-action@v1
with:
upload-sarif: true
fail-on-quality-gate: true
quality-threshold: 75
- name: Upload SARIF to GitHub
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: howmany-reports/howmany-results.sarifname: Conditional Analysis
on: [push, pull_request]
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Analyze on main branch
if: github.ref == 'refs/heads/main'
uses: GriffinCanCode/howmany-action@v1
with:
fail-on-quality-gate: true
quality-threshold: 85
- name: Analyze on PR
if: github.event_name == 'pull_request'
uses: GriffinCanCode/howmany-action@v1
with:
create-pr-comment: true
quality-threshold: 70name: Multi-Project Analysis
on: [push]
jobs:
analyze:
runs-on: ubuntu-latest
strategy:
matrix:
project:
- { name: 'backend', path: './backend', extensions: 'rs,toml' }
- { name: 'frontend', path: './frontend', extensions: 'js,ts,vue' }
- { name: 'docs', path: './docs', extensions: 'md,rst' }
steps:
- uses: actions/checkout@v4
- name: Analyze ${{ matrix.project.name }}
uses: GriffinCanCode/howmany-action@v1
with:
path: ${{ matrix.project.path }}
extensions: ${{ matrix.project.extensions }}
artifact-name: ${{ matrix.project.name }}-analysisThe action evaluates several quality metrics:
Weighted combination of all quality factors:
- 85-100: Excellent code quality
- 70-84: Good code quality
- 55-69: Fair code quality
- 40-54: Poor code quality
- 0-39: Very poor code quality
Industry-standard metric based on:
- Cyclomatic complexity
- Lines of code
- Halstead volume
- Comment density
Percentage of code with documentation:
- Comments and docstrings
- README and documentation files
- Inline code comments
- Cyclomatic Complexity: Decision points in code
- Cognitive Complexity: Mental effort to understand
- Nesting Depth: Maximum indentation levels
- Function Length: Average and maximum sizes
When create-pr-comment is enabled, the action creates rich PR comments:
## π HowMany Code Analysis
| Metric | Value | Status |
|--------|-------|--------|
| **Files Analyzed** | 127 | |
| **Total Lines** | 15,847 | |
| **Code Lines** | 11,234 | |
| **Overall Quality** | 82.4/100 | π’ |
| **Maintainability** | 78.2/100 | π’ |
| **Documentation** | 75.1% | π’ |
### π Development Time Estimate
3 days, 2 hours
### ποΈ Project Structure
- **rs**: 45 files, 8,234 lines
- **js**: 32 files, 4,123 lines
- **py**: 28 files, 2,456 lines
- **md**: 15 files, 1,034 linesIf HowMany installation fails:
- Ensure the runner has Rust/Cargo available
- Check network connectivity for crates.io
- Try specifying a specific version instead of 'latest'
- uses: GriffinCanCode/howmany-action@v1
with:
howmany-version: '0.3.2'For PR comments and SARIF uploads:
permissions:
contents: read
pull-requests: write # For PR comments
security-events: write # For SARIF uploadFor very large repositories, consider:
- Setting
max-depthto limit traversal - Using specific
extensionsto focus analysis - Adding
ignore-patternsfor irrelevant directories
- uses: GriffinCanCode/howmany-action@v1
with:
max-depth: 5
extensions: 'rs,py,js'
ignore-patterns: 'vendor,node_modules,target'Contributions are welcome! Please see the contributing guide for details.
This action is distributed under the MIT License. See LICENSE for more information.
- HowMany CLI - The core analysis tool
- HowMany VS Code Extension - IDE integration