A tool to analyze code and provide formatting improvement suggestions
Project description
Code-Formatter-Advisor
Code-Formatter-Advisor is a command-line tool that leverages GroqCloud API to analyze code and provide formatting improvement suggestions. It offers a streamlined interface for specifying input files, customizing outputs, and enhancing code readability and consistency. The tool supports multiple programming languages and integrates seamlessly into your workflow by delivering suggestions directly in the terminal or saving them to a file.
📜Description
- Provides code formatting suggestions based on best practices.
- Supports multiple programming languages.
- Easy-to-use command-line interface.
- Ability to output suggestions to a file or display them in the terminal.
⚙️Installation
-
Clone the repository:
git clone https://github.com/Elisassa/Code-Formatter-Advisor.git cd Code-Formatter-Advisor
-
Create a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required dependencies:
pip install -r requirements.txt
📝Usage
Command-Line Arguments
--outputor-o: Specify the output file name for the suggestions.--versionor-v: Display the version of the tool.files: The code files to be analyzed (one or more).
Example Commands
-
Analyze a single file and display suggestions in the terminal:
python main.py test.py
-
Analyze multiple files and save suggestions to an output file:
python main.py test1.py test2.py --output suggestions.txt
-
Check the version of the tool:
python main.py --version
🔍Demonstration
The Code-Formatter-Advisor analyzes your code and provides actionable formatting suggestions to improve readability and consistency. Below is a demonstration of how the tool works:
Original Unformatted Code:
Below is an example of code before using Code-Formatter-Advisor. Notice the issues such as inconsistent indentation, missing type hints, and lack of descriptive comments.
Suggested Improvements by Code-Formatter-Advisor:
After running the code through Code-Formatter-Advisor, the tool suggests various improvements such as:
- Consistent Indentation: Standardizes indentation to 4 spaces for better readability.
- Removal of Extra Spaces: Removes unnecessary spaces around function arguments, colons, and assignment operators.
- Descriptive Function Names: Renames functions to be more descriptive, like changing
add_numberstosum_numbers. - Addition of Docstrings: Adds docstrings to describe the purpose and usage of functions, making the code self-documenting.
- Type Hints: Adds type hints to function arguments and return values to clarify the expected input and output.
🛠️How Code-Formatter-Advisor Was Created
Project Setup
-
Initialization: The project was initialized by setting up a basic Python environment using
venvto manage dependencies. -
Dependencies: Required libraries were defined and installed via a
requirements.txtfile, includingargparsefor command-line argument parsing,dotenvfor environment variable management, and others for formatting analysis. -
Development:
- The main logic is implemented in
main.py, which handles reading files, interacting with the code formatting API, and processing user inputs. argparseis used to handle command-line arguments, allowing users to specify files, output locations, and other options.- A custom API client (
Groq) was integrated to analyze code and provide formatting suggestions.
- The main logic is implemented in
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_formatter_advisor-0.1.0.tar.gz.
File metadata
- Download URL: code_formatter_advisor-0.1.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e315a4d467f0ad614b5b9c34ebfefb091d0d6c0cf2fad361828566a806e8b74
|
|
| MD5 |
e455c9af02431afccb749714c00a573f
|
|
| BLAKE2b-256 |
2cb91dacab6c0b9f14fb131f03d12dac6a06e4d2688542f3e3057bc4e4ba4cb0
|
File details
Details for the file code_formatter_advisor-0.1.0-py3-none-any.whl.
File metadata
- Download URL: code_formatter_advisor-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f0654f642b7733ce8883d955616d2c2ccff1ad9af7b8fbdd93db777d26508c0
|
|
| MD5 |
08eac43eef07f1cb7e4eaf6dc80b29b0
|
|
| BLAKE2b-256 |
e463432039460c74e44da514664f3a8a1cf90569fb40cc309814bc8fe2853b02
|