Thank you for your interest in contributing to GreenCodeAnalyzer! We welcome contributions that help improve the tool and make it more effective for identifying energy-inefficient patterns in Python code.
If you encounter a bug or have a feature request, please:
- Check the issue tracker to see if it has already been reported.
- If not, create a new issue with:
- A clear and descriptive title.
- Steps to reproduce the issue (if applicable).
- Any relevant logs, screenshots, or code snippets.
We accept contributions in the form of bug fixes, new features, or documentation updates. Follow these steps to contribute:
-
Fork the Repository
Fork the repository to your GitHub account and clone it locally:git clone https://github.com/ianjoshi/green-code-analyzer.git cd green-code-analyzer -
Set Up the Development Environment
Install the required dependencies:# Using conda conda env create -f environment.yml conda activate gsl_venv # Or using pip pip install -r requirements.txt npm install npm run compile
-
Make Your Changes
- Follow the existing code style and structure as described here.
- Add new rules as described here.
- Add or update files in the
GreenCodeAnalyzer/data/testsdirectory to cover your changes. - Run tests through main.py to ensure your changes add the desired functionality.
- Change the file path in
main.pyto the file you want to test. - Run the following command to execute the tests:
python main.py
- Change the file path in
-
Commit Your Changes
Write clear and concise commit messages:git add . git commit -m "Brief description of your changes"
-
Push and Create a Pull Request
Push your changes to your fork and create a pull request:git push origin <your-branch-name>
- Go to the original repository and open a pull request.
- Provide a detailed description of your changes and link any related issues.
- Use TypeScript for the VS Code extension and Python for the analysis rules.
If you want to add a new energy-efficiency rule:
- Create a new file in the
GreenCodeAnalyzer/rulesdirectory. - Implement the rule by extending the
BaseRuleclass. - Add a test file for the rule in the
GreenCodeAnalyzer/data/testsdirectory. - Update the
README.mdto document the new rule under the Supported Rules section.
To test the extension:
- Open the project in VS Code.
- Press
F5or run the command Debug: Start Debugging from the Command Palette (Ctrl+Shift+P). - Use the new VS Code window to test your changes.
If you improve or add documentation:
- Update the
README.mdor create new markdown files as needed. - Ensure the documentation is clear and concise.
By contributing, you agree to abide by our Code of Conduct.
If you have any questions, feel free to open an issue or reach out to the maintainers.
Thank you for contributing to GreenCodeAnalyzer!