-
Notifications
You must be signed in to change notification settings - Fork 22
added rule GCI 110 - avoid wildcard imports #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
added rule GCI 110 - avoid wildcard imports #109
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @hassineabd,
thank you a lot for this interesting PR ...
before accepting this PR, please, you must do following tasks :
- update CHANGELOG.md with your upgrade in the current repository
- follow process for a new rule : https://github.com/green-code-initiative/creedengo-common/blob/main/doc/starter-pack.md#implement-a-new-rule
Please, in the rule documentation in creedengo-rules-specifications, I will particularly vigilent about the proof of your ideas ... please feel free to giver some URLs to prove your idea. A full example : https://github.com/green-code-initiative/creedengo-rules-specifications/blob/main/src/main/rules/GCI107/python/GCI107.asciidoc
Please, also, take into account Copilot review, bottom, and adapt / complete your unit tests with new modifications.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new rule GCI110 to detect and flag wildcard imports in Python code, which helps reduce memory usage and follows PEP 8 best practices.
- Implements a check that detects
from module import *patterns - Adds comprehensive test coverage with both compliant and non-compliant examples
- Integrates the new rule into the existing rule repository and profile configuration
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/org/greencodeinitiative/creedengo/python/checks/AvoidWildcardImportsCheck.java | Main rule implementation that detects wildcard imports |
| src/test/java/org/greencodeinitiative/creedengo/python/checks/AvoidWildcardImportsCheckTest.java | Unit test for the new rule |
| src/test/resources/checks/avoidWildcardImports.py | Test cases showing compliant and non-compliant code examples |
| src/main/java/org/greencodeinitiative/creedengo/python/PythonRuleRepository.java | Registers the new rule in the repository |
| src/main/resources/org/greencodeinitiative/creedengo/python/creedengo_way_profile.json | Adds GCI110 to the profile configuration |
| src/it/test-projects/creedengo-python-plugin-test-project/src/avoidWildcardImports.py | Integration test file with example cases |
| src/it/java/org/greencodeinitiative/creedengo/python/integration/tests/GCIRulesIT.java | Integration test that validates rule behavior |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| 4, 5, 6, 16, 21, 28, 29 | ||
| }; | ||
| int[] endLines = new int[]{ | ||
| 4, 5, 6, 16, 21, 28, 29 |
Copilot
AI
Oct 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line numbers in the integration test don't match the actual wildcard import lines in the test file. Based on the test file, wildcard imports are on lines 2, 3, 5, and 8, not the specified lines.
| 4, 5, 6, 16, 21, 28, 29 | |
| }; | |
| int[] endLines = new int[]{ | |
| 4, 5, 6, 16, 21, 28, 29 | |
| 2, 3, 5, 8 | |
| }; | |
| int[] endLines = new int[]{ | |
| 2, 3, 5, 8 |
|
Hi @hassineabd, thank you for last modifications but it lacks the part about "creedengo-specifications-rules" in my last comment. |
|
Hello @dedece35 , |
this rule detects all wildcard import statements using the from module import * pattern.
using wildcard imports (from module import *) is an anti-pattern that impacts memory
exemple:
why this matters:
-everything in the lib is loaded into memory, even the ones that are not used