Skip to content

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Jun 26, 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^

sedoc = {}
for k in codes:
sedoc[codes[k]] = k
sedoc = {codes[k]: k for k in codes}
Copy link
Author

Choose a reason for hiding this comment

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

Lines 506-508 refactored with the following changes:

  • Convert for loop into dictionary comprehension (dict-comprehension)

Comment on lines -26 to +27
totalNumOf = totalNumOf + numOf
totalTimeOf = totalTimeOf + timeOf
totalNumOf += numOf
totalTimeOf += timeOf
Copy link
Author

Choose a reason for hiding this comment

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

Function registrationsFromFile refactored with the following changes:

  • Replace assignment with augmented assignment (aug-assign)

Comment on lines -60 to +62
isOrd = True
for (left, right) in deps:
if module == left:
if right not in ordered:
# It's not already ordered, so this is not this order
isOrd = False
isOrd = not any(module == left and right not in ordered
for (left, right) in deps)
Copy link
Author

Choose a reason for hiding this comment

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

Function nextOrder refactored with the following changes:

  • Merge nested if conditions (merge-nested-ifs)
  • Use any() instead of for loop (use-any)

Comment on lines -84 to +82
isGen = True
for (left, right) in deps:
if module == right:
if left not in gened:
isGen = False
isGen = not any(module == right and left not in gened
for (left, right) in deps)
Copy link
Author

Choose a reason for hiding this comment

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

Function nextGeneration refactored with the following changes:

  • Merge nested if conditions (merge-nested-ifs)
  • Use any() instead of for loop (use-any)

sedoc = {}
for k in codes:
sedoc[codes[k]] = k
sedoc = {codes[k]: k for k in codes}
Copy link
Author

Choose a reason for hiding this comment

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

Lines 506-508 refactored with the following changes:

  • Convert for loop into dictionary comprehension (dict-comprehension)

Comment on lines -65 to +73

boost = (0,1,4,5,16,17,20,21)
ret = ''
for i in range(precision):
for _ in range(precision):
ret+=_base32[(boost[a&7]+(boost[b&3]<<1))&0x1F]
t = a>>3
a = b>>2
b = t

Copy link
Author

Choose a reason for hiding this comment

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

Function _encode_i2c refactored with the following changes:

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

Comment on lines -134 to +135
lon = lon<<3
lat = lat<<2
lon <<= 3
lat <<= 2
Copy link
Author

Choose a reason for hiding this comment

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

Function _decode_c2i refactored with the following changes:

  • Replace assignment with augmented assignment (aug-assign)

i = 0
for csv in self.csvs:
i = i + 1
i += 1
Copy link
Author

Choose a reason for hiding this comment

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

Function PpidCounts2KML.run refactored with the following changes:

  • Replace assignment with augmented assignment (aug-assign)

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Jun 26, 2020

Sourcery Code Quality Report (beta)

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

Before After Change
Quality 7.45 7.51 0.06
Complexity 6.6 6.09 -0.51
Method Length 161.45 160.77 -0.69
Lines 1714 1704 -10
Changed files Quality Before Quality After Quality Change
bin/CsvJoiner.py 7.24 7.29 0.05 ⬆️
bin/avgRegistrationResponseTimes 9.12 9.14 0.03 ⬆️
bin/drawDeps.py 5.98 6.38 0.4 ⬆️
geo/CountryCodeToName.py 7.24 7.29 0.05 ⬆️
geo/geohash.py 6.78 6.79 0.01 ⬆️
geo/ppidCounts2kml.py 8.98 8.99 0.01 ⬆️

Here are some functions in these files that still need a tune-up:

File Function Quality Recommendation
geo/geohash.py expand_uint64 0.57 Reduce complexity. Split out functionality
geo/geohash.py encode 3.8 Split out functionality
geo/geohash.py bbox 5.48 Split out functionality
geo/geohash.py decode 5.6 Split out functionality
geo/geohash.py _float_hex_to_int 6.5 Split out functionality

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.

2 participants