---
title: Avoid Unintended Global Variables
description: "Impact Area Manageability Severity High Affected Element Lightning ## Rule ID **SF-0057** ## Impact Omitting the `var` keyword from a variable definition within a method creates the variable in the global scope, which clutter up the global namespace and make the code…"
url: "https://community-staging.qualityclouds.com/qcdocs/qc/pmd-rules/avoid-unintended-global-variables/"
updated: "2025-03-21"
category: PMD Rules
---

# Avoid Unintended Global Variables

Impact Area

Manageability

           Severity

High

           Affected Element

Lightning

## Rule ID

**SF-0057**

## Impact

Omitting the `var` keyword from a variable definition within a method creates the variable in the global scope, which clutter up the global namespace and make the code slower.

### Time to fix

45 min

## Remediation

Always use the `var` keyword to declare local variables.

## References

See the PMD documentation article: [GlobalVariable](https://pmd.github.io/latest/pmd_rules_ecmascript_bestpractices.html#globalvariable).
