PAC-B010 · empty-block

Empty block

low · Best practice and maintainability

An if, else or catch with an empty body is usually an unfinished edit. The condition is still evaluated (possibly a DNS lookup) and the reader has to guess what was intended.

Why it matters

if (dnsDomainIs(host, ".partner.example")) { } costs the evaluation and does nothing; an empty catch (e) { } swallows errors silently, which in a PAC means the request continues to whatever follows. Both are signs of a half-done change.

How to fix

Complete the branch with a return or delete it.

Examples

Bad

function FindProxyForURL(url, host) {
  if (dnsDomainIs(host, ".partner.example")) {
  }
  return "PROXY proxy.corp.example:8080";
}
Open bad example in checker

Good

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

Related rules