tomorrowkey / danger-compose_compiler_metrics

MIT License
13 stars 0 forks source link

Error: NoMethodError for Hash when using this with Kotlin v2.0.20+ and feature flags #3

Open KoheiMoroi opened 1 week ago

KoheiMoroi commented 1 week ago

Description

When using this plugin with Kotlin v2.0.20 or newer, an error occurs due to changes in the Compose Compiler Metrics JSON structure. The error is triggered by the Strong Skippable mode, which is enabled by default in Kotlin v2.0.20.(see this)

Error Log:

/vendor/bundle/ruby/3.3.0/gems/danger-compose_compiler_metrics-0.0.4/lib/compose_compiler_metrics/plugin.rb:71:in `block (2 levels) in report_metrics_report': undefined method `-' for an instance of Hash (NoMethodError)
        diff_value = (new_value - reference_value).then do |v|

Cause

From Kotlin v2.0.20, Strong Skippable mode is enabled by default. This results in the generated compose compiler metrics JSON file containing the following new object:

"featureFlags": {
    "StrongSkipping": true,
    "IntrinsicRemember": true,
    "OptimizeNonSkippingGroups": false
  }

The plugin attempts to perform a subtraction operation on this Hash object, resulting in the NoMethodError.

 diff_value = (new_value - reference_value).then do |v|

Steps to Reproduce

  1. Use Kotlin v2.0.20 or above in a Android project with Jetpack Compose.
  2. Set up danger-compose_compiler_metrics in Dangerfile.
  3. Run Danger as part of CI process.

Expected Behavior

The plugin should handle the new JSON structure gracefully, either by ignoring the featureFlags object or by updating its parsing logic to accommodate the new format.

Additional Information

KoheiMoroi commented 1 week ago

@tomorrowkey I would be grateful if you could look into this issue. Thank you.