Skip to main content

A Python tool for analyzing code complexity

Project description

Code Complexity Pro

This is a command-line tool that analyzes the complexity of source code files using Groq's LLM API. It supports multiple file inputs, customizable AI model selection, and various configuration options to suit your workflow. The project is Code-Complexity-Pro, and here you will find everything you need to know about using this tool.

Features

  • Version Display: Use the --version or -v flag to display the tool's name and current version.
  • Help/Usage Instructions: Use the --help or -h flag to display how to run the tool, along with available flags and arguments.
  • File Input: Analyze one or more source code files.
  • Customizable Output: By default, results are printed to the terminal (stdout), but you can specify an output file using the --output or -o flag.
  • AI Model Selection: Specify a model for the analysis using the --model or -m flag (default is llama-v2).
  • API Key Configuration: API keys can be passed via the --api-key or -a flag, or you can configure them in a .env file.
  • Error Logging: All debug and error messages are logged to stderr, keeping output clean.

Usage

You can run the tool from the command line with various flags and options. Here are some examples:

1. Display Version

python main.py --version

2. Show Help/Usage

python main.py --help

3. Run the Analyzer on a Single File

python main.py path/to/your_file.py

4. Analyze Multiple Files

python main.py file1.py file2.py

5. Save Results to a File

python main.py your_file.py --output analysis_results.txt

6. Specify a Different AI Model

python main.py your_file.py --model gpt-3.5

7. Pass API Key and Base URL via Command Line

python main.py your_file.py --api-key your_grok_api_key --base-url https://api.custom-url.com

8. Error Handling

For example:

python main.py nonexistent_file.py

Examples

For sample files, check out the examples/ directory in this repository. It contains test files that you can use to run the tool and see how it works.

Running on Example File

python main.py examples/test_code.py

New Features

1. Support for Multiple Files or Directories

You can now provide multiple files and directories as input for complexity analysis. The tool will recursively process directories and analyze all relevant files within them.

2. Enhanced Error Handling with Exit Codes

The tool now properly exits with a status code based on success or failure:

  • Exit code 0 for successful processing.
  • Exit code 1 for errors such as missing files, invalid inputs, or missing API keys.

Demo

Demo Video

License

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

code_complexity_pro-1.1.2.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

code_complexity_pro-1.1.2-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file code_complexity_pro-1.1.2.tar.gz.

File metadata

  • Download URL: code_complexity_pro-1.1.2.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for code_complexity_pro-1.1.2.tar.gz
Algorithm Hash digest
SHA256 e345f72cf0d4df3e1bebb3c20ff1199f04b73b68ede72adb48987a96d92fa843
MD5 29f7932089c7a9fc0d835a13248106d8
BLAKE2b-256 f068417b85e077bef4d22d5b454a781f58376d375598231f65849b600793674b

See more details on using hashes here.

File details

Details for the file code_complexity_pro-1.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for code_complexity_pro-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 96ddcf284c700f58b460e2020a835cf530b84be33f594aa722abba2b9755a5fd
MD5 7aeedc01d93b3de21e25f79e67675c30
BLAKE2b-256 36125b65b578e30b6c3976a02da7196f0d0274a3f9edbaf55663d90c75d6196c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page