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

Sourcery refactored master branch #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Jul 31, 2020

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

elif a == "easy-medium" or a == "medium":
elif a in ["easy-medium", "medium"]:
Copy link
Author

Choose a reason for hiding this comment

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

Lines 13-13 refactored with the following changes:

  • Replace multiple comparisons of same variable with in operator (merge-comparisons)

Comment on lines -6 to +15
ans = 0
for i in range(4,len(a)+1):
li.append(a[count:i])
count += 1

for i in li:
if "c" in i and "h" in i and "e" in i and "f" in i:
ans += 1

ans = sum(1 for i in li if "c" in i and "h" in i and "e" in i and "f" in i)
if ans == 0:
print("normal")
else:
print("lovely",ans)

Copy link
Author

Choose a reason for hiding this comment

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

Lines 6-18 refactored with the following changes:

  • Convert for loop into call to sum() (sum-comprehension)

Comment on lines -7 to +16
for i in range(user_test):
for _ in range(user_test):
user_string = input().split()
cases.append(user_string)

for i in range(len(cases)):
for j in range(len(cases[i])):
cases[i][j] = int(cases[i][j])
for case_ in cases:
for j in range(len(case_)):
case_[j] = int(case_[j])

for i in range(len(cases)):
if (cases[i][0] * (2 ** 0.5) / cases[i][1]) < (cases[i][0] / cases[i][2] * 2):
for case in cases:
if case[0] * 2 ** 0.5 / case[1] < case[0] / case[2] * 2:
Copy link
Author

Choose a reason for hiding this comment

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

Lines 7-16 refactored with the following changes:

  • Replace unused for index with underscore (for-index-underscore)
  • Replace index in for loop with direct reference (for-index-replacement)

Comment on lines -8 to +19

for i in range(n):
if n_hand[i] <= n_glove[i]:
front += 1
if n_hand[i] <= n_glove[n-1-i]:
back += 1

if front == n == back:
print("both")
elif front == n and back != n:
elif front == n:
print("front")
elif back == n and front != n:
elif back == n:
Copy link
Author

Choose a reason for hiding this comment

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

Lines 8-19 refactored with the following changes:

  • Remove redundant conditional (remove-redundant-if)

for i in l:
if i[2] == g:
return True
return False
return any(i[2] == g for i in l)
Copy link
Author

Choose a reason for hiding this comment

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

Function compare refactored with the following changes:

  • Use any() instead of for loop (use-any)

new_list = []
for _ in range(n):
new_list.append(0)

new_list = [0 for _ in range(n)]
Copy link
Author

Choose a reason for hiding this comment

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

Lines 6-20 refactored with the following changes:

  • Convert for loop into list comprehension (list-comprehension)

for j in n_colors:
for _ in n_colors:
Copy link
Author

Choose a reason for hiding this comment

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

Lines 13-13 refactored with the following changes:

  • Replace unused for index with underscore (for-index-underscore)

for i in range(n):
for _ in range(n):
Copy link
Author

Choose a reason for hiding this comment

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

Lines 5-5 refactored with the following changes:

  • Replace unused for index with underscore (for-index-underscore)

Comment on lines -7 to +9
while(binary != 0):
while (binary != 0):
dec = binary % 10
decimal = decimal + dec * pow(2, i)
decimal += dec * pow(2, i)
Copy link
Author

Choose a reason for hiding this comment

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

Function binaryToDecimal refactored with the following changes:

  • Replace assignment with augmented assignment (aug-assign)

Comment on lines -18 to +25

for i in n_numbers[l-1: r]:
temp = bin(i)
bin_n_numbers.append(temp[2:])
length_temp = len(temp[2:])
if max_len < length_temp:
max_len = length_temp

Copy link
Author

Choose a reason for hiding this comment

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

Lines 18-44 refactored with the following changes:

  • Merge duplicate blocks in conditional (merge-duplicate-blocks)
  • Remove redundant conditional (remove-redundant-if)
  • Replace if statement with if expression (assign-if-exp)
  • Replace index in for loop with direct reference (for-index-replacement)

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Jul 31, 2020

Sourcery Code Quality Report (beta)

✅  Merging this PR will increase code quality in the affected files by 0.25 out of 10.

Quality metrics Before After Change
Complexity 11.00 10.06 -0.94 🔵
Method Length 93.17 84.61 -8.56 🔵
Quality 6.84 7.09 0.25 🔵
Other metrics Before After Change
Lines 306 291 -15
Changed files Quality Before Quality After Quality Change
C00K0FF.py 6.56 6.70 0.14 🔵
CHEFCHR.py 6.92 7.43 0.51 🔵
CHEFSUM.py 6.24 6.76 0.52 🔵
CHEGLOVE.py 5.80 6.13 0.33 🔵
DPAIRS.py 8.12 8.48 0.36 🔵
ELEVSTRS.py 6.24 6.76 0.52 🔵
HP18.py 6.77 7.03 0.26 🔵
MATPAN.py 5.93 5.99 0.06 🔵
MINVOTE.py 4.44 4.66 0.22 🔵
MIXCOLOR.py 6.77 6.77 0.00
TGL.py 6.96 6.96 0.00
XXOR.py 7.49 7.59 0.10 🔵

Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Let us know what you think of it via email or our Gitter!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants