Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Lint about comparing booleans to boolean literals #3973

Merged
merged 3 commits into from
Apr 18, 2023

Conversation

oprypin
Copy link
Contributor

@oprypin oprypin commented Jan 9, 2023

This lints against any expression like x == true or false == x.
It kicks in only if the variable is of type bool, non-nullable.

Fixes dart-lang/sdk#58533
Ref dart-lang/sdk#58533
Ref dart-lang/sdk#58966

@coveralls
Copy link

coveralls commented Jan 9, 2023

Coverage Status

Coverage: 95.691% (+0.009%) from 95.682% when pulling 3b738ec on no_literal_bool_comparisons into c30bfe1 on main.

@oprypin oprypin force-pushed the no_literal_bool_comparisons branch from fc290bd to 6612a04 Compare January 9, 2023 10:03
Copy link
Contributor

@pq pq left a comment

Choose a reason for hiding this comment

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

💎

@pq
Copy link
Contributor

pq commented Jan 9, 2023

/fyi @MaryaBelanger

@oprypin
Copy link
Contributor Author

oprypin commented Jan 9, 2023

Ah and I added a test that this works for any expression, not just a variable.

@pq
Copy link
Contributor

pq commented Jan 10, 2023

@oprypin: is this ready to land?

@oprypin
Copy link
Contributor Author

oprypin commented Jan 10, 2023

Yes

@srawlins srawlins merged commit ca2a9fe into main Apr 18, 2023
@srawlins srawlins deleted the no_literal_bool_comparisons branch April 18, 2023 05:48
copybara-service bot pushed a commit to dart-lang/sdk that referenced this pull request Aug 23, 2023
…r#3973)

* Lint about comparing booleans to boolean literals

* fixup! Lint about comparing booleans to boolean literals

* Add test that the lint works for any expression, not just variables
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Lint that warns about comparing boolean expressions against literals
5 participants