Skip to content

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Feb 1, 2023

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^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from bryoh February 1, 2023 10:36
a.sort(key = lambda x: str(x.date_obj.minute)) # sort by minute
for i in a:
print('{}, {}, {}'.format(i.date_str, i.constraint, i.whole_msg))
print(f'{i.date_str}, {i.constraint}, {i.whole_msg}')
Copy link
Author

Choose a reason for hiding this comment

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

Lines 50-50 refactored with the following changes:

print(scripts)
body_str = body(divs, scripts)
whole_thing = '<html>' + header_str + body_str + '</html>'
whole_thing = f'<html>{header_str}{body_str}</html>'
Copy link
Author

Choose a reason for hiding this comment

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

Function construct_page refactored with the following changes:

Comment on lines -90 to +93
# eg. src and dest are the same file
except shutil.Error as e:
print('Error: %s' % e)
# eg. source or destination doesn't exist
print(f'Error: {e}')
except IOError as e:
print('Copy Error: %s' % e.strerror)
print(f'Copy Error: {e.strerror}')
Copy link
Author

Choose a reason for hiding this comment

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

Function copy_file refactored with the following changes:

This removes the following comments ( why? ):

# eg. src and dest are the same file
# eg. source or destination doesn't exist

Comment on lines -103 to +101
parser.error("The file %s does not exist!" % arg)
parser.error(f"The file {arg} does not exist!")
Copy link
Author

Choose a reason for hiding this comment

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

Function is_valid_file refactored with the following changes:

Comment on lines -57 to +58
full_day = 86400
hr_val = past.hour > present.hour
day_diff = (present - past).total_seconds()/full_day >= 1
day_diff = (present - past).total_seconds() >= 86400
Copy link
Author

Choose a reason for hiding this comment

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

Function day_has_passed refactored with the following changes:

Comment on lines -24 to +28
if '__main__'==__name__:
if __name__ == '__main__':
url = 'http://localhost'
port = 8000
ServerThread(port).start()
url_n_port = "{}:{}/".format(url,str(port))
url_n_port = f"{url}:{port}/"
Copy link
Author

Choose a reason for hiding this comment

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

Lines 24-28 refactored with the following changes:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented Feb 1, 2023

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 0.21%.

Quality metrics Before After Change
Complexity 3.59 ⭐ 3.60 ⭐ 0.01 👎
Method Length 43.33 ⭐ 43.33 ⭐ 0.00
Working memory 6.46 🙂 6.53 🙂 0.07 👎
Quality 78.37% 78.16% -0.21% 👎
Other metrics Before After Change
Lines 272 269 -3
Changed files Quality Before Quality After Quality Change
constraint_processing.py 81.31% ⭐ 80.43% ⭐ -0.88% 👎
dygraph.py 78.61% ⭐ 78.36% ⭐ -0.25% 👎
perf_tools.py 72.16% 🙂 72.18% 🙂 0.02% 👍
simpleserver3.py 92.87% ⭐ 92.94% ⭐ 0.07% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
perf_tools.py add_date 9 🙂 167 😞 10 😞 52.43% 🙂 Try splitting into smaller methods. Extract out complex expressions
constraint_processing.py ConstraintObj.__init__ 0 ⭐ 77 🙂 11 😞 70.40% 🙂 Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


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!

Help us improve this quality report!

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