AdguardTeam / AdguardTeam/AGLint

Add rule for detecting invalid logical expressions

Aberta
#237 0 comentários 0 reações 1 responsável Reivindicada por @maximtop Ver no GitHub
Priority: P4 T: Linter rule
Linguagem predominante
TypeScript
Estrelas
71
Forks
4
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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`.

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.