refactorcode
v1.0.0
Published
A console application to reduce bugs, improve performance and improve readability of your code.
Readme
RefactorCode
A console application to reduce bugs, improve performance and improve readability of your code.
https://github.com/user-attachments/assets/9ca694a3-da23-4ae3-b476-1c071e675a66
Features
- Checks for any bugs and corrects them (out of bounds, performance issues, logical bugs).
- Removes commented out and unreachable code.
- Adds comments to explain existing code.
- Splits very large functions into smaller functions for better modularity.
Usage
refactorcode ./yourfileBy the refactored code is displayed in the console. To specify an output file, use -o. See Options
Setup Instructions
Clone the repo
git clone https://github.com/brokoli777/RefactorCode.gitInstall node libraries
pnpm installOR
npm installGet an API Key from here: https://ai.google.dev/aistudio
Configuration Setup
To configure your application, there are 2 options, creating a .env file or a .toml file:
Option 1: Create a .env file in your project root directory, and add the API key like this:
API_KEY=YOURAPIKEYHEREOption 2: Create a .toml file named .refactorcode.toml in your home directory, and add your API key and/or preferences:
Create the TOML File:
Open your terminal and run the following command to create a new TOML file in your home directory:touch ~/.refactorcode.tomlCopy the Sample Configuration:
Next, copy the sample configuration from.refactorcode.toml.exampleinto your newly created.refactorcode.tomlfile:cp .refactorcode.toml.example ~/.refactorcode.tomlEdit the Configuration:
Open the.refactorcode.tomlfile in your preferred text editor, and add your API key value, and any other preferences (e.g. MODEL) you need.
Link the application
npm link
Run the application
refactorcode examples/test.py
Options
-m or --model: Allows to specify the model
Choices:
- 1.5f (gemini-1.5-flash) (default)
- 1.5p (gemini-1.5-pro)
refactorcode examples/test.py -m 1.5p
-o or --output- Allows to set the output file
-t or --token-usage: Allows get information on the tokens used
-s or --stream Streams the response as it is received
refactorcode examples/test.py -o hello.py
