Skip to content

Conversation

FMorschel
Copy link
Contributor

It was found, at the issue below, a false-negative for the avoid_redundant_argument_values lint where it wasn't triggered for annotations. This PR simply removes the redundant arguments.

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request focuses on code cleanup by removing redundant arguments in annotations, addressing a lint for avoid_redundant_argument_values. The changes are applied to TypedShellRoute annotations in test files for go_router_builder and a JsonKey annotation in in_app_purchase_storekit. The changes are straightforward and improve code conciseness.

@@ -384,7 +384,7 @@ class SKProductDiscountWrapper {
/// A string used to uniquely identify a discount offer for a product.
///
/// You set up offers and their identifiers in App Store Connect.
@JsonKey(defaultValue: null)
@JsonKey()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Thanks for removing the redundant defaultValue: null. However, it looks like the corresponding generated file, sk_product_wrapper.g.dart, hasn't been updated. As noted in the file header, changes to @JsonSerializable classes require running the build runner. Please run the generator and commit the updated .g.dart file to ensure the generated code is in sync with this change.

@FMorschel FMorschel marked this pull request as draft September 8, 2025 15:17
@FMorschel FMorschel changed the title [go_router_builder] Removes redundant arguments from annotations [go_router_builder] [in_app_purchase_storekit] Removes redundant arguments from annotations Sep 8, 2025
@FMorschel FMorschel marked this pull request as ready for review September 8, 2025 19:31
Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for go_router part

@@ -121,6 +121,7 @@ class _SerializedEnums {
late SKPaymentTransactionStateWrapper response;
late SKSubscriptionPeriodUnit unit;
late SKProductDiscountPaymentMode discountPaymentMode;
late SKProductDiscountType discountType;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @LouiseHsu this class doesn't seem to be read by anyone, and the code generator seems to be generating _$SKProductDiscountTypeEnumMap just fine without it being added to _SerializedEnums. Do you think this type can be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and the code generator seems to be generating _$SKProductDiscountTypeEnumMap just fine without it being added to _SerializedEnums.

I couldn't do without it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with json_serializable.dart, but the following code already exists in enum_converters.g.dart today:

const _$SKProductDiscountTypeEnumMap = {
  SKProductDiscountType.introductory: 0,
  SKProductDiscountType.subscription: 1,
};

you mean if you rerun code gen the above map const is removed from the generated source code, without that new field in _SerializedEnums?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean if you rerun code gen the above map const is removed from the generated source code, without that new field

Exactly. See the second commit on this branch, I simply ran the build and pushed, expecting any diagnostics to be stale analysis that would get fixed once it was updated. Once I saw the bots failed, I actually looked at the output and diagnostics.

So I had to add that and remove the ? from the map key for it to build. It was also warning on the terminal (while building) about the annotations version, so I upgraded it as well.

I'm not sure why this line was missing, if it was removed by mistake or something, but it would not generate this without it.

@LongCatIsLooong
Copy link
Contributor

The CI is complaining about missing versionbump / changelog (see: https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#version-and-changelog-updates). The IAP change seems to involve a signature change, could you bump the version of that package?

@FMorschel
Copy link
Contributor Author

I'd asked about it at #9964 (comment). Will do. Thanks!

@LongCatIsLooong
Copy link
Contributor

@chunhtai do you think the go_router_builder change needs a version bump (I think that's blocking the CI)? If not I think we should put on the override tag.

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

Successfully merging this pull request may close these issues.

3 participants