Skip to main content

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

  1. Clone the repository:

    git clone https://github.com/Elisassa/Code-Formatter-Advisor.git
    cd Code-Formatter-Advisor
    
  2. Create a virtual environment (optional but recommended):

    python -m venv venv
    source venv/bin/activate # On Windows use `venv\Scripts\activate`
    
  3. Install the required dependencies:

    pip install -r requirements.txt
    

📝Usage

Command-Line Arguments

  • --output or -o: Specify the output file name for the suggestions.
  • --version or -v: Display the version of the tool.
  • files: The code files to be analyzed (one or more).

Example Commands

  1. Analyze a single file and display suggestions in the terminal:

    python main.py test.py
    
  2. Analyze multiple files and save suggestions to an output file:

    python main.py test1.py test2.py --output suggestions.txt
    
  3. 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.

image

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_numbers to sum_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.

Formatted Code Suggestions

🛠️How Code-Formatter-Advisor Was Created

Project Setup

  1. Initialization: The project was initialized by setting up a basic Python environment using venv to manage dependencies.

  2. Dependencies: Required libraries were defined and installed via a requirements.txt file, including argparse for command-line argument parsing, dotenv for environment variable management, and others for formatting analysis.

  3. Development:

    • The main logic is implemented in main.py, which handles reading files, interacting with the code formatting API, and processing user inputs.
    • argparse is 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.

Metadata

Release files for code-formatter-advisor 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for code-formatter-advisor 0.1.0
File Size Uploaded Provenance Actions
code_formatter_advisor-0.1.0.tar.gz 4.0 kB Without provenance Details for code_formatter_advisor-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for code-formatter-advisor 0.1.0
File Interpreter ABI Platform Actions
code_formatter_advisor-0.1.0-py3-none-any.whl Python 3 none any Details for code_formatter_advisor-0.1.0-py3-none-any.whl

Total release size: 7.9 kB

Release files / code_formatter_advisor-0.1.0.tar.gz

Download URL code_formatter_advisor-0.1.0.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7e315a4d467f0ad614b5b9c34ebfefb091d0d6c0cf2fad361828566a806e8b74
BLAKE2b-256 checksum
How to use checksums
2cb91dacab6c0b9f14fb131f03d12dac6a06e4d2688542f3e3057bc4e4ba4cb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release files / code_formatter_advisor-0.1.0-py3-none-any.whl

Download URL code_formatter_advisor-0.1.0-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6f0654f642b7733ce8883d955616d2c2ccff1ad9af7b8fbdd93db777d26508c0
BLAKE2b-256 checksum
How to use checksums
e463432039460c74e44da514664f3a8a1cf90569fb40cc309814bc8fe2853b02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Security for code-formatter-advisor 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page