Skip to the content.

Getting Started

This guide will help you run your first code analysis with Metripy.

Step 1: Install Metripy

pip install metripy

Verify installation:

metripy --version

Step 2: Create a Configuration File

In your project root, create metripy.json:

For Python Projects

{
    "configs": {
        "my-project": {
            "base_path": "./",
            "includes": ["src/"],
            "excludes": ["__pycache__", ".venv", "tests/"],
            "extensions": ["py"],
            "pip": true,
            "git": {
                "branch": "main"
            },
            "reports": {
                "html": "./build/report"
            },
            "trends": "./build/historical/metrics.json"
        }
    }
}

For TypeScript Projects

{
    "configs": {
        "my-project": {
            "base_path": "./",
            "includes": ["src/"],
            "excludes": ["node_modules", "dist/", "*.test.ts"],
            "extensions": ["ts", "tsx"],
            "npm": true,
            "git": {
                "branch": "main"
            },
            "reports": {
                "html": "./build/report"
            }
        }
    }
}

For PHP Projects

{
    "configs": {
        "my-project": {
            "base_path": "./",
            "includes": ["src/"],
            "excludes": ["vendor/", "tests/"],
            "extensions": ["php"],
            "composer": true,
            "git": {
                "branch": "main"
            },
            "reports": {
                "html": "./build/report"
            }
        }
    }
}

Step 3: Run Analysis

metripy --config=metripy.json

You should see output like:

Analying Project metripy...
Analyzing git history...
Git history analyzed
Analyzing code...
... 100% ...
Code analyzed
Analyzing pip packages...
Pip packages analyzed
Analyzing trends...
Importing data from ./build/historical-json-report/metripy.json...
Data imported successfuly
Trends analyzed
Done analying Project metripy
Generating reports for metripy...
Generating HTML report...
Rendering index page
Done rendering index page
Rendering files page
Files page generated successfully
Rendering git analysis page
Git analysis page generated successfully
Rendering dependencies page
Dependencies page generated successfully
Rendering top offenders page
Top offenders page generated successfully
Rendering trends page
HTML report generated in ./build/report/metripy directory
Create json report in ./build/json-report/metripy.json
Create git json report in ./build/json-report/metripy-git.json
Reports generated for metripy

Step 4: View the Report

Open the HTML report in your browser:

# macOS
open ./build/report/index.html

# Linux
xdg-open ./build/report/index.html

# Windows
start ./build/report/index.html

Understanding the Report

Dashboard (index.html)

The main overview shows:

Color coding:

Files Page

Browse your codebase with:

Git Analysis Page (if enabled)

Insights from your Git history:

Dependencies Page (if enabled)

View your project dependencies:

Track changes over time:

To enable trend tracking, add a trends path to your config, this is the json output file from your past run:

{
    "configs": {
        "my-project": {
            // ... other settings ...
            "trends": "./build/historical/metrics.json"
        }
    }
}

Run analysis regularly:

# Run daily, weekly, or after significant changes
metripy --config=metripy.json

Metripy will:

  1. Load previous metrics from the trends file
  2. Compare with current analysis
  3. Show trend indicators and deltas
  4. Update the trends file

Common Workflows

Quick Check

Just want a quick overview without Git or dependencies:

{
    "configs": {
        "quick": {
            "base_path": "./",
            "includes": ["src/"],
            "extensions": ["py"],
            "reports": {
                "html": "./build/report"
            }
        }
    }
}

Git Only

Only interested in Git metrics:

{
    "configs": {
        "git-stats": {
            "base_path": "./",
            "git": {"branch": "main"},
            "reports": {
                "json-git": "./build/git-metrics.json"
            }
        }
    }
}

Next Steps

Now that you’re up and running:

Need Help?


Happy analyzing! πŸŽ‰