Skip to content

kenhuangus/function-point-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Function Point Estimator

A Streamlit web application that analyzes GitHub repositories to estimate Function Points (FP) based on Source Lines of Code (SLOC) for Python, JavaScript/TypeScript, and CSS files.

Features

  • Multi-Repository Analysis: Input one or multiple GitHub repository URLs for batch processing
  • Comprehensive Language Support:
    • Python: .py, .pyw, .ipynb (Jupyter notebooks with code extraction)
    • JavaScript/TypeScript: .js, .ts, .tsx, .jsx, .mjs, .cjs
    • CSS: .css, .scss, .sass, .less
  • Accurate SLOC Counting: Ignores comments and blank lines with language-specific handling
  • Function Point Calculation: Uses standard SLOC-to-FP conversion ratios
    • Python: 45 SLOC per FP
    • JavaScript/TypeScript/CSS: 54 SLOC per FP
  • Interactive Dashboard:
    • Data table sorted by total FP (highest first)
    • Bar chart comparison across repositories
    • Download results as JSON or CSV
  • Progress Tracking: Real-time status updates during repository cloning and analysis
  • URL Validation: Ensures valid GitHub repository URLs

Installation

  1. Clone this repository:
git clone https://github.com/kenhuangus/function-point-calculator.git
cd function-point-calculator
  1. Install dependencies:
pip install streamlit gitpython pandas

Usage

  1. Run the Streamlit app:
streamlit run app.py
  1. Open your browser to the provided local URL (typically http://localhost:8501)

  2. Enter GitHub repository URLs (one per line) in the text area

  3. Click "Analyze Repositories" and wait for processing

  4. View the results table, sorted by total FP, and download if needed

Example Input

https://github.com/octocat/Hello-World.git
https://github.com/microsoft/vscode
https://github.com/facebook/react

Algorithm

The application performs the following steps:

  1. URL Validation: Ensures each input is a valid GitHub repository URL
  2. Repository Cloning: Uses GitPython to clone repos into a temporary directory
  3. File Discovery: Recursively scans for supported file types
  4. Code Extraction: For .ipynb files, extracts code from code cells only
  5. SLOC Counting:
    • Skips blank lines
    • Ignores comments:
      • Python: # comments
      • JavaScript/TypeScript: // and /* ... */ blocks
      • CSS: /* ... */ blocks
  6. FP Calculation: SLOC / Ratio (rounded to 2 decimal places)
  7. Aggregation: Sums FP across all languages for total FP per repo
  8. Presentation: Sorts results by total FP descending

Tech Stack

  • Streamlit: Web framework for the UI
  • GitPython: For Git repository operations
  • Pandas: Data manipulation and CSV export
  • JSON: For notebook file parsing

Security Notes

  • Repositories are cloned into system temporary directories
  • Application performs read-only operations on files
  • No code execution; only static analysis of source files

Contributing

Feel free to submit issues and enhancement requests!

License

This project is open source. Please use responsibly for GitHub repository analysis.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages