Skip to content

analyze: Fix new lints on latest Flutter main#1739

Merged
gnprice merged 2 commits intozulip:mainfrom
chrisbobbe:pr-fix-new-lints
Jul 24, 2025
Merged

analyze: Fix new lints on latest Flutter main#1739
gnprice merged 2 commits intozulip:mainfrom
chrisbobbe:pr-fix-new-lints

Conversation

@chrisbobbe
Copy link
Collaborator

flutter analyze has started giving the following, which breaks CI:

info • Unnecessary comparison to a boolean literal • lib/api/model/events.dart:1177:10 •
no_literal_bool_comparisons
info • Unnecessary comparison to a boolean literal • lib/model/channel.dart:158:13 •
no_literal_bool_comparisons

Fixed.

@chrisbobbe chrisbobbe requested a review from gnprice July 23, 2025 23:18
@chrisbobbe chrisbobbe added the integration review Added by maintainers when PR may be ready for integration label Jul 23, 2025
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of this! Comments below.

Comment on lines +155 to +157
if (!role.isAtLeast(UserRole.member)) return false;
return role == UserRole.member
? hasPassedWaitingPeriod(user, byDate: byDate)
: true;
return role != UserRole.member
|| hasPassedWaitingPeriod(user, byDate: byDate);
Copy link
Member

Choose a reason for hiding this comment

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

The new code here seems more confusing than the old. I feel like to understand it, I have to unpack it back into basically what we have now.

So this looks like an overzealous lint rule to me. But probably easier to accommodate it than to ignore it.

How about:

        if (!role.isAtLeast(UserRole.member)) return false;
        if (role == UserRole.member) {
          return hasPassedWaitingPeriod(user, byDate: byDate);
        }
        return true;

Comment on lines 1175 to 1176
// Crunchy-shell validation
if (
result.flag == MessageFlag.read
&& true // (we assume `event_types` has `message` and `update_message_flags`)
) {
// (we assume `event_types` has `message` and `update_message_flags`)
if (result.flag == MessageFlag.read) {
result.messageDetails as Map<int, UpdateMessageFlagsMessageDetail>;
Copy link
Member

Choose a reason for hiding this comment

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

Here I don't really understand what the comment was saying about this true 🙂, so the lint seems helpful.

Looking at the API docs (https://zulip.com/api/get-events#update_message_flags-remove), I don't understand the comment now either. It looks like messageDetails is supposed to be there if the flag is "read". What's the other condition about?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah: looks like the doc used to say message_details was "Present if message and update_message_flags are both present in event_types and the flag is read and the op is remove." But the event_types part was deleted in zulip/zulip@48a1cf0.

Copy link
Member

Choose a reason for hiding this comment

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

Aha — thanks for tracking that down.

@sm-sayedi
Copy link
Collaborator

Thanks for fixing this. I think this is the reason #1738 is also failing. I didn't expect that "info-level" warning would also break CI!

@gnprice
Copy link
Member

gnprice commented Jul 24, 2025

Yeah, when the PR itself introduces an info-level warning, we want to know that so we fix it before merging the PR — that's how we keep the tree in a state where it's totally clean of warning noise.

But then this becomes one of several ways that a change upstream can cause our CI to start failing for all PRs. The root cause of that really is the fact that we run CI on the latest upstream. Started a chat thread on that: #mobile-team > CI on latest upstream

… doc

The doc for message_details on this event says the field is present
if the flag is "read", with no mention of event_types. Looking
through zulip/zulip's Git history, it turns out it had been
mentioned in the past, but the mention was removed, in
zulip/zulip@48a1cf04d:

-  Present if `message` and `update_message_flags` are both present in
-  `event_types` and the `flag` is `read` and the `op` is `remove`.
+  Only present if the specified `flag` is `"read"`.

So the comment (and no-op `&& true`) isn't necessary; remove it.

We noticed this because the analyzer started flagging an info-level
`no_literal_bool_comparisons` here.
`flutter analyze` has started giving the following, which breaks CI:

   info • Unnecessary comparison to a boolean literal • lib/api/model/events.dart:1177:10 •
          no_literal_bool_comparisons
   info • Unnecessary comparison to a boolean literal • lib/model/channel.dart:158:13 •
          no_literal_bool_comparisons

We fixed the first one in the previous commit; this fixes the
second.

See discussion:
  https://chat.zulip.org/#narrow/channel/243-mobile-team/topic/CI.20on.20latest.20upstream/near/2228858
@chrisbobbe
Copy link
Collaborator Author

Thanks for the review and that explanation! Revision pushed.

@gnprice
Copy link
Member

gnprice commented Jul 24, 2025

Thanks! Looks good; merging.

@gnprice gnprice merged commit 0ce94c4 into zulip:main Jul 24, 2025
1 check passed
@chrisbobbe chrisbobbe deleted the pr-fix-new-lints branch July 24, 2025 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration review Added by maintainers when PR may be ready for integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants