Skip to content
This repository has been archived by the owner on Aug 27, 2021. It is now read-only.

All day event timezone fix (Sourcery refactored) #116

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented May 22, 2021

Pull Request #115 refactored by Sourcery.

Since the original Pull Request was opened as a fork in a contributor's
repository, we are unable to create a Pull Request branching from it.

To incorporate these changes, you can either:

  1. Merge this Pull Request instead of the original, or

  2. Ask your contributor to locally incorporate these commits and push them to
    the original Pull Request

    Incorporate changes via command line
    git fetch https://github.com/PTST/O365-HomeAssistant pull/115/head
    git merge --ff-only FETCH_HEAD
    git push

NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.

See our documentation here.

Run Sourcery locally

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

mshish and others added 2 commits May 22, 2021 06:58
Attempts to fix #85
Two changes:
1. Bring in fix from home-assistant/core#48642 which doesn't make much of a difference here (branch doesn't appear to get hit with all day events).
1. Fix the timezone shift for all day events. I'm not sure this is in the right place since it appears o365 is returning the event as if it were on GMT (but it's not). This may only work if the all day event was actually in the local timezone.
Comment on lines -264 to +270

return enddate
return obj.start + timedelta(days=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 O365CalendarData.get_end_date refactored with the following changes:

@sourcery-ai
Copy link
Author

sourcery-ai bot commented May 22, 2021

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 2.28 ⭐ 2.48 ⭐ 0.20 👎
Method Length 53.00 ⭐ 54.91 ⭐ 1.91 👎
Working memory 9.40 🙂 9.51 🙂 0.11 👎
Quality 71.62% 🙂 70.72% 🙂 -0.90% 👎
Other metrics Before After Change
Lines 304 310 6
Changed files Quality Before Quality After Quality Change
custom_components/o365/calendar.py 71.62% 🙂 70.72% 🙂 -0.90% 👎

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

File Function Complexity Length Working Memory Quality Recommendation
custom_components/o365/calendar.py setup_platform 8 ⭐ 160 😞 12 😞 50.41% 🙂 Try splitting into smaller methods. Extract out complex expressions
custom_components/o365/calendar.py CalendarServices.respond_calendar_event 5 ⭐ 136 😞 11 😞 57.61% 🙂 Try splitting into smaller methods. Extract out complex expressions
custom_components/o365/calendar.py O365CalendarData.async_update 1 ⭐ 110 🙂 15 😞 58.79% 🙂 Extract out complex expressions
custom_components/o365/calendar.py O365CalendarData.async_get_events 4 ⭐ 114 🙂 10 😞 63.16% 🙂 Extract out complex expressions
custom_components/o365/calendar.py O365CalendarEventDevice.async_update 1 ⭐ 98 🙂 12 😞 64.65% 🙂 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!

Let us know what you think of it by mentioning @sourcery-ai in a comment.

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

Successfully merging this pull request may close these issues.

1 participant