tools
tools copied to clipboard
`match_str_case_mismatch`
https://rust-lang.github.io/rust-clippy/master/#match_str_case_mismatch
For this rule, we should try to implement simple cases such as:
const lorem = "foo";
if (lorem == "Foo") { // trigger the rule
}
This issue is stale because it has been open 14 days with no activity.
Hi @ematipico.
Is the goal here to find mismatching comparison of const/effectively const variables?
or is it to find toUpperCase/toLowerCase comparisons?
const lorem = "foo";
if (lorem == "Foo") { // trigger the rule
}
I doubt that a rule limited to this pattern will catch many bugs and isn't what the clippy equivalent is testing for.
or is it to find toUpperCase/toLowerCase comparisons?
This feels more valuable to me (testing in all places where conditions can appear: if/else, switch, maybe for, and while?)
Should it only raise for conditional statements mentioned above or in general as well?
For example, this also look right to me:
! This expression always returns false.
> 10 │ const a = s.toUpperCase() === "abc";
│ ^^^^^^^^^^^^^^^^^^^^^^^^^
11 │
i This call convert the string to upper case
> 10 │ const a = s.toUpperCase() === "abc";
│ ^^^^^^^^^^^^^^^
11 │
i ... but this value is not in upper case
> 10 │ const a = s.toUpperCase() === "abc";
│ ^^^^^
11 │
It probably makes sense in all positions where a value is compared with a string.