Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[<Health> <12.0.1>] Non-exhaustive type alignment for sleep options #1124

Open
cachapa opened this issue Feb 2, 2025 · 0 comments
Open

[<Health> <12.0.1>] Non-exhaustive type alignment for sleep options #1124

cachapa opened this issue Feb 2, 2025 · 0 comments
Labels
bugfix a bug fix

Comments

@cachapa
Copy link
Contributor

cachapa commented Feb 2, 2025

Plugin Name

health

Plugin Version

12.0.1

Describe the bug

The method _alignValue(HealthDataType) has a repeated check for SLEEP_ASLEEP and only covers 5 of the 10 possible SLEEP types:

static double _alignValue(HealthDataType type) => switch (type) {
        HealthDataType.SLEEP_IN_BED => 0,
        HealthDataType.SLEEP_ASLEEP => 1,
        HealthDataType.SLEEP_AWAKE => 2,
        HealthDataType.SLEEP_ASLEEP => 3,
        HealthDataType.SLEEP_DEEP => 4,
        HealthDataType.SLEEP_REM => 5,
        HealthDataType.HEADACHE_UNSPECIFIED => 0,
        HealthDataType.HEADACHE_NOT_PRESENT => 1,
        HealthDataType.HEADACHE_MILD => 2,
        HealthDataType.HEADACHE_MODERATE => 3,
        HealthDataType.HEADACHE_SEVERE => 4,
        _ => throw HealthException(type,
            "HealthDataType was not aligned correctly - please report bug at https://github.com/cph-cachet/flutter-plugins/issues"),
      };

https://github.com/cph-cachet/flutter-plugins/blob/master/packages/health/lib/src/health_plugin.dart#L1105

The types are:

  SLEEP_ASLEEP,
  SLEEP_AWAKE_IN_BED,
  SLEEP_AWAKE,
  SLEEP_DEEP,
  SLEEP_IN_BED,
  SLEEP_LIGHT,
  SLEEP_OUT_OF_BED,
  SLEEP_REM,
  SLEEP_SESSION,
  SLEEP_UNKNOWN,

https://github.com/cph-cachet/flutter-plugins/blob/master/packages/health/lib/src/heath_data_types.dart#L76

@cachapa cachapa added the bugfix a bug fix label Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix a bug fix
Projects
None yet
Development

No branches or pull requests

1 participant