Files
MagicMirror/defaultmodules/weather
Kristjan ESPERANTO 3335781af4 Remove unnecessary conditionals and fix falsy property check in imperial conversion (#4135)
While removing unnecessary conditionals (for `compliments` reported in
https://github.com/MagicMirrorOrg/MagicMirror/security/code-scanning/27
and for `weather` reported in
https://github.com/MagicMirrorOrg/MagicMirror/security/code-scanning/28),
I noticed a bug in the imperial conversion path: falsy property checks
like `if (imperialWeatherObject.temperature)` silently skip the
conversion when the value is `0`. So at exactly 0 °C, the result would
show `0 °F` instead of the correct `32 °F`.

I wrote unit tests for `convertWeatherObjectToImperial` first, which
confirmed the bug, then fixed it by replacing the falsy checks with the
`in` operator. Which I also find more intuitive to read.

Weather APIs deliver floating point values, so hitting exactly `0.0`
might be rare in practice - more likely `0.1` or `-0.1`, which are
truthy and convert fine. That should explain why it went unnoticed by
users.
2026-05-03 12:49:34 +02:00
..

Weather Module

This module will be configurable to be used as a current weather view, or to show the forecast. This way the module can be used twice to fulfill both purposes.

For configuration options, please check the MagicMirror² documentation.