-
-
Notifications
You must be signed in to change notification settings - Fork 122
GCI97 PreferAppendLeft #Python #DLG #RulesSpecifications #381
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
Merged
dedece35
merged 6 commits into
green-code-initiative:main
from
cleophass:PreferAppendLeft
Aug 2, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b8fd4c5
GCI97 PreferAppendLeft
cleophass 151528b
PreferAppendLeft add Rules.MD and CHANGELOG.md
cleophass 4903b8c
PreferAppendLeft Conflicts resolution
cleophass 64ab276
PreferAppendLeft update/GCI97.json: include data in title and correct…
cleophass 6b832b2
GCI108 PreferAppendLeft fix: change rule number (97->108), resolve co…
cleophass f617019
Merge branch 'main' into PreferAppendLeft
dedece35 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "title": "DATA: Prefer AppendLeft Over Insert(0)", | ||
| "type": "CODE_SMELL", | ||
| "status": "ready", | ||
| "remediation": { | ||
| "func": "Constant\/Issue", | ||
| "constantCost": "10min" | ||
| }, | ||
| "tags": [ | ||
| "creedengo", | ||
| "eco-design", | ||
| "performance", | ||
| "data" | ||
| ], | ||
| "defaultSeverity": "Minor" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,48 @@ | ||||||||||
| When you want to insert an element at the beginning of a list, it's better to use a deques or a double linked list. | ||||||||||
|
|
||||||||||
| == Non compliant Code Example | ||||||||||
|
|
||||||||||
| [source,python] | ||||||||||
| ---- | ||||||||||
| numbers.insert(0,val) | ||||||||||
| ---- | ||||||||||
|
|
||||||||||
| == Compliant Solution | ||||||||||
|
|
||||||||||
| [source,python] | ||||||||||
| ---- | ||||||||||
| numbers.appendleft(val) | ||||||||||
| ---- | ||||||||||
|
|
||||||||||
| == Relevance Analysis | ||||||||||
|
|
||||||||||
| The following results were obtained through local experiments. | ||||||||||
|
|
||||||||||
| === Configuration | ||||||||||
|
|
||||||||||
| * Processor: Intel(R) Core(TM) Ultra 5 135U, 2100 MHz, 12 cores, 14 logical processors | ||||||||||
| * RAM: 16 GB | ||||||||||
| * CO2 Emissions Measurement: Using CodeCarbon | ||||||||||
|
|
||||||||||
| === Context | ||||||||||
|
|
||||||||||
| We'll analyze the impact of inserting 10**6 elements at index 0 of a list and compare this with inserting the same number of elements using a deque (deque stands for Double-Ended Queue. It is a data structure that allows adding and removing elements from both ends efficiently. Unlike regular queues, which are typically operated on using FIFO (First In, First Out) principles, a deque supports both FIFO and LIFO (Last In, First Out)) | ||||||||||
|
|
||||||||||
|
|
||||||||||
|
Comment on lines
+29
to
+31
|
||||||||||
| We'll analyze the impact of inserting 10**6 elements at index 0 of a list and compare this with inserting the same number of elements using a deque (deque stands for Double-Ended Queue. It is a data structure that allows adding and removing elements from both ends efficiently. Unlike regular queues, which are typically operated on using FIFO (First In, First Out) principles, a deque supports both FIFO and LIFO (Last In, First Out)) | |
| We'll analyze the impact of inserting 10**6 elements at index 0 of a list and compare this with inserting the same number of elements using a deque. | |
| A deque (short for Double-Ended Queue) is a data structure that allows adding and removing elements from both ends efficiently. Unlike regular queues, which are typically operated on using FIFO (First In, First Out) principles, a deque supports both FIFO and LIFO (Last In, First Out) operations. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,4 +13,4 @@ | |
| ], | ||
| "defaultSeverity": "Minor" | ||
| } | ||
|
|
||
|
|
||
|
dedece35 marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.