AdguardTeam / AdguardTeam/AGLint

Add rule for detecting invalid logical expressions

Đang mở
#237 0 bình luận 0 reaction 1 người được giao Được @maximtop nhận Xem trên GitHub
Priority: P4 T: Linter rule
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

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.