Skip to content

PriyavKaneria/CodeStats

Repository files navigation

CodeStats

A quick project to calculate and analyze stats for all my github, gitlab, local projects

Clones the repositories, counts the lines of code, and calculates the stats.

Output stats

CLI Visualization visualization_screenshot

Demo

code-stats-demo.mp4

loc_analysis.json

    "repo_name": {
        "total_files": "number",
        "total_lines": "number",
        "total_blanks": "number",
        "total_comments": "number",
        "total_lines_of_code": "number",
        "boilerplate_lines": "number", // import statements, require statements, etc for now
        "actual_code_lines": "number",
        "language_distribution": {
            "language_extension": "number_of_lines", // supports any language can be configured as below
        },
        "description": "string",
        "stars": "number", // if repo accessible
        "topics": ["string"], // if repo accessible
        "contributions": {
            "total_commits": "number",
            "total_lines_changed": {
                "additions": "number",
                "deletions": "number",
            },
            "first_commit_date": "datetime_string",
            "last_commit_date": "datetime_string",
            "median_commit_size": "float",
        }
    },

Usage

Requirements

Recommended Python version: 3.10+

pip install -r requirements.txt

Configuration

Create a repos.json file in the root directory with the following structure:

[
    {
        "source": "github", // only github supported for now [local, gitlab to be added]
        "path": "REPO_OWNER/REPO_NAME",
        "ignore": ["files", "to", "ignore"],
        "contributor": true // optional, default: false
    },
]

Set environment variables for the following:

CONTRIBUTION_AUTHOR_NAMES={COMMA_SEPARATED_AUTHOR_NAMES}
GITHUB_ACCESS_TOKEN={YOUR_GITHUB_ACCESS_TOKEN}

Run

If you have cmake installed, you can use make commands to run the project

Getting unique languages across all repos

make languages

OR

python main.py languages

The languages can be configured in the main.py file using the analyze_file_types variable

Calculating analysis for all repos

make analyze

OR

python main.py analyze

Visualizing the stats

make visualize

OR

python main.py visualize

About

A quick project to calculate and analyze code and contribution stats for all my github, gitlab, local projects along with those I have contributed to

Topics

Resources

License

Stars

Watchers

Forks

Contributors