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
--versionor-vflag to display the tool's name and current version. - Help/Usage Instructions: Use the
--helpor-hflag 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
--outputor-oflag. - AI Model Selection: Specify a model for the analysis using the
--modelor-mflag (default isllama-v2). - API Key Configuration: API keys can be passed via the
--api-keyor-aflag, or you can configure them in a.envfile. - 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
0for successful processing. - Exit code
1for errors such as missing files, invalid inputs, or missing API keys.
Demo
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e345f72cf0d4df3e1bebb3c20ff1199f04b73b68ede72adb48987a96d92fa843
|
|
| MD5 |
29f7932089c7a9fc0d835a13248106d8
|
|
| BLAKE2b-256 |
f068417b85e077bef4d22d5b454a781f58376d375598231f65849b600793674b
|
File details
Details for the file code_complexity_pro-1.1.2-py3-none-any.whl.
File metadata
- Download URL: code_complexity_pro-1.1.2-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96ddcf284c700f58b460e2020a835cf530b84be33f594aa722abba2b9755a5fd
|
|
| MD5 |
7aeedc01d93b3de21e25f79e67675c30
|
|
| BLAKE2b-256 |
36125b65b578e30b6c3976a02da7196f0d0274a3f9edbaf55663d90c75d6196c
|