# Unused functions or variables

Source: https://findproxyforurl.net/rules/unused-code/ · last updated 2026-10-04

Rule PAC-B003 (`unused-code`), severity low, category: Best practice and maintainability.

Helper functions and variables that nothing references are leftovers from earlier versions. They are harmless to the engine but mislead reviewers and hide the rules that actually run.

## Why it matters

PAC files accumulate: an old proxy string kept "just in case", a helper that was replaced
by an inline check, a list that no longer feeds any rule. Each unused item costs review
time and can be mistaken for an active rule. Helper functions that *are* called from
`FindProxyForURL` are fine and often improve readability; only unreferenced ones are
reported.


## How to fix

Delete unused declarations; keep history in version control, not in the file.

## Bad

```js
var OLD_PROXY = "PROXY old-proxy.corp.example:8080";
function isLab(host) {
  return dnsDomainIs(host, ".lab.example");
}
function FindProxyForURL(url, host) {
  if (dnsDomainIs(host, ".corp.example")) {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
}
```

## Good

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