PAC-B002 · nonstandard-parameter-names

Parameters not named url and host

info · Best practice and maintainability

Engines pass the arguments by position, so function FindProxyForURL(u, h) works. Every document, example and reviewer assumes url and host; deviating names invite mix-ups between the two (PAC-C001).

Why it matters

The two parameters are easy to confuse even with the standard names. Non-standard names remove the one cue that tells a reader which string is which, and they defeat pattern-based review tools that look for host and url. There is no benefit in renaming them.

How to fix

Declare function FindProxyForURL(url, host).

Examples

Bad

function FindProxyForURL(u, h) {
  if (isPlainHostName(h)) {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
}
Open bad example in checker

Good

function FindProxyForURL(url, host) {
  if (isPlainHostName(host)) {
    return "DIRECT";
  }
  return "PROXY proxy.corp.example:8080";
}
Open good example in checker

Related rules

References