AdguardTeam / AdguardTeam/AGLint
Add rule for detecting invalid logical expressions
- Ngôn ngữ chính
- TypeScript
- Star
- 70
- Fork
- 4
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
We should check conditions in `if` preprocessor directive.
A logical expression can be invalid if it is contradictory or always produces the same result regardless of the input. Here are some examples:
### 1. **Self-Contradiction**
- `(A && !A)`
- This states that "A is true and A is not true" simultaneously, which is logically impossible.
### 2. **Redundancy**
- `(A || A)`
- This always produces the same result as `A`. One of the conditions is unnecessary.
### 3. **Unnecessary Expressions**
- `(A && true)` or `(A || false)`
- Such expressions are not logically invalid but redundant, as `true` or `false` does not change the outcome.
### 4. **Always True (Tautology)**
- `(A || !A)`
- This is always true because either `A` is true, or `A` is not true (this is an axiom).
### 5. **Disconnected Conditions**
- `(A && B && !B)`
- Here, `B` and `!B` exclude each other, so the entire expression will always be false, regardless of the value of `A`.
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.