# Condition is a constant

Source: https://findproxyforurl.net/rules/constant-condition/ · last updated 2026-10-04

Rule PAC-C017 (`constant-condition`), severity medium, category: Correctness.

if (true), if (0) or if ("DIRECT") does not depend on the request. Everything after an always-true branch that returns is dead; an always-false branch is dead itself.

## Why it matters

Constant conditions are usually debugging leftovers ("temporarily force DIRECT") or the
result of a typo that turned a comparison into a literal. In a PAC an always-true `if`
with a return makes the whole rest of the function unreachable, including the real default
route. A string literal is truthy when non-empty, so `if ("DIRECT")` is always taken.


## How to fix

Replace the constant with the intended comparison or remove the branch.

## Bad

```js
function FindProxyForURL(url, host) {
  if (true) {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
}
```

## Good

```js
function FindProxyForURL(url, host) {
  if (isPlainHostName(host)) {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
}
```
