Skip to content

Commit

Permalink
improve imvalid_comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson committed Oct 19, 2024
1 parent 34ec40c commit 42bc74d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
5 changes: 5 additions & 0 deletions hls/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions hls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
"vscode-uri": "^3.0.8"
},
"dependencies": {
"hemtt": "file:",
"portfinder": "^1.0.32",
"vscode-languageclient": "^9.0.1"
}
Expand Down
15 changes: 3 additions & 12 deletions libs/sqf/src/analyze/lints/s21_invalid_comparisons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,27 +345,18 @@ fn check_issue(a: &Comparison, b: &Comparison) -> Option<ComparisonIssue> {
span_b: b_span,
})
} else {
Some(ComparisonIssue {
issue: ComparisonIssueType::Impossible,
span_a: a_span,
span_b: b_span,
})
None
}
}
(Comparison::NotEqual(_, num_a, _), Comparison::Equal(_, num_b, _))
| (Comparison::Equal(_, num_a, _), Comparison::NotEqual(_, num_b, _)) => {
(Comparison::NotEqual(_, num_a, _), Comparison::Equal(_, num_b, _)) => {
if num_a == num_b {
Some(ComparisonIssue {
issue: ComparisonIssueType::Impossible,
span_a: a_span,
span_b: b_span,
})
} else {
Some(ComparisonIssue {
issue: ComparisonIssueType::Overlapping,
span_a: a_span,
span_b: b_span,
})
None
}
}
_ => None,
Expand Down
1 change: 1 addition & 0 deletions libs/sqf/tests/lints/s21_invalid_comparisons/source.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ if (_x < 20 && _x < 10) then {
systemChat "This is wasteful";
};

if (_key != 1 && _key != 2 && _key != 3) exitWith {false};

0 comments on commit 42bc74d

Please sign in to comment.