Imagine that you are working on a project, your primary goal is to get a working application. But because you have a lot on your hand, you don't have time to review and clean up code to make it readable for other developers. That's where RefactorCode comes in!
brokoli777 / RefactorCode
A console application to reduce bugs, improve performance and improve readability of your code.
RefactorCode
A console application to reduce bugs, improve performance and improve readability of your code.
RefactorCode.mov
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 ./yourfile
By 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.git
Install node libraries
pnpm install
OR
npm install
Get an API Key from here: https://ai.google.dev/aistudio
Create a .env file and add the API key like this:
API_KEY=YOURAPIKEYHERE
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β¦
If haven't clicked away from reading that cheesy intro, let me tell you about what it does:
Features
- It adds helpful comments to explain what a particular section of codes does.
- Removes unreachable and commented out code (y'all have done it at some point)
- If a code is implemented in an inefficient way, it rewrites it to make it more performant without changing its functionality.
- Corrects common bugs like edge case issues or out of bounds.
- Breaks down very large functions into more modular ones
Setup
There are detailed instructions in the github repo but here is a basic overview of how to set it up:
- Clone the repo and do
npm install
, andnpm link
- Get an API key from Gemini, create a .env file and add the API key like this:
API_KEY=YOURAPIKEYHERE
Finally, start improving your code, type:
refactorcode .\theFileToBeRefactored
It also supports multiple files at the same time!
Options
You can use following options to change how the application works:
-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
refactorcode examples/test.py -o hello.py
-t or --token-usage: Allows get information on the tokens used
Demo
Top comments (0)