jabesq / netatmo-api-python

Simple API to access Netatmo weather station data from any python script (for Netatmo information, see www.netatmo.com)
MIT License
10 stars 34 forks source link

Simplify with defaultdict #135

Closed jabesq closed 3 years ago

jabesq commented 3 years ago

defaultdict have better performance that checking a key in a dict

Signed-off-by: Hugo Dupras hugo.dupras@nxp.com

sourcery-ai[bot] commented 3 years ago

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.33%.

Quality metrics Before After Change
Complexity 6.80 ⭐ 5.73 ⭐ -1.07 👍
Method Length 69.31 🙂 66.43 🙂 -2.88 👍
Working memory 7.47 🙂 7.47 🙂 0.00
Quality 75.94% 76.27% 0.33% 👍
Other metrics Before After Change
Lines 836 809 -27
Changed files Quality Before Quality After Quality Change
src/pyatmo/camera.py 73.17% 🙂 73.35% 🙂 0.18% 👍
src/pyatmo/thermostat.py 80.71% ⭐ 81.30% ⭐ 0.59% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
src/pyatmo/camera.py CameraData.__init__ 34 ⛔ 414 ⛔ 18 ⛔ 14.37% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
src/pyatmo/thermostat.py HomeData.__init__ 28 😞 243 ⛔ 12 😞 29.15% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
src/pyatmo/camera.py CameraData.__init__.update_events 23 😞 248 ⛔ 9 🙂 37.51% 😞 Refactor to reduce nesting. Try splitting into smaller methods
src/pyatmo/thermostat.py HomeData.__init__.get_thermostat_type.HomeStatus.__init__ 18 🙂 218 ⛔ 9 🙂 42.76% 😞 Try splitting into smaller methods
src/pyatmo/camera.py CameraData.__init__.person_seen_by_camera 18 🙂 130 😞 12 😞 45.10% 😞 Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

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.