Skip to content
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

add imports (Sourcery refactored) #117

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 21 additions & 25 deletions gilded_rose_original.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,29 @@ def __init__(self, items):

def update_quality(self):
for item in self.items:
if item.name != "Aged Brie" and item.name != "Backstage passes to a TAFKAL80ETC concert":
if item.quality > 0:
if item.name != "Sulfuras, Hand of Ragnaros":
item.quality = item.quality - 1
else:
if item.name == "Sulfuras, Hand of Ragnaros":
continue
if item.name == "Aged Brie":
if item.quality < 50:
item.quality = item.quality + 1
if item.sell_in < 1 and item.quality < 50:
item.quality = item.quality + 1

elif item.name == "Backstage passes to a TAFKAL80ETC concert":
if item.quality < 50:
item.quality = item.quality + 1
if item.name == "Backstage passes to a TAFKAL80ETC concert":
if item.sell_in < 11:
if item.quality < 50:
item.quality = item.quality + 1
if item.sell_in < 6:
if item.quality < 50:
item.quality = item.quality + 1
if item.name != "Sulfuras, Hand of Ragnaros":
item.sell_in = item.sell_in - 1
if item.sell_in < 0:
if item.name != "Aged Brie":
if item.name != "Backstage passes to a TAFKAL80ETC concert":
if item.quality > 0:
if item.name != "Sulfuras, Hand of Ragnaros":
item.quality = item.quality - 1
else:
item.quality = item.quality - item.quality
else:
if item.quality < 50:
item.quality = item.quality + 1
if item.sell_in < 11 and item.quality < 50:
item.quality = item.quality + 1
if item.sell_in < 6 and item.quality < 50:
item.quality = item.quality + 1
if item.sell_in < 1:
item.quality = item.quality - item.quality
else:
if item.quality > 0:
item.quality = item.quality - 1
if item.sell_in < 1 and item.quality > 0:
item.quality = item.quality - 1
item.sell_in = item.sell_in - 1
Comment on lines -26 to +48
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function GildedRose.update_quality refactored with the following changes:

  • Simplify conditional into switch-like form (switch)
  • Merge nested if conditions (merge-nested-ifs)
  • Swap positions of nested conditionals (swap-nested-ifs)
  • Remove redundant conditional (remove-redundant-if)
  • Remove empty elif clause (remove-pass-elif)
  • Replace multiple comparisons of same variable with in operator (merge-comparisons)
  • Ensure first condition in if is positive (swap-if-else-branches)
  • Split conditional into multiple branches (split-or-ifs)
  • Hoist conditional out of nested conditional (hoist-if-from-if)
  • Extract guard clause from elif block (guard)
  • Hoist repeated code outside conditional statement (hoist-statement-from-if)
  • Simplify numeric comparison (simplify-numeric-comparison)



class Item:
Expand Down