Edit

AvoidGlobalFunctions

Severity Level: Warning

Description

This rule detects function definitions that use the global: scope modifier on the function name to define a function in the global scope. Global functions can unintentionally override existing functions in the session, leading to unexpected behavior and name collisions. Name collisions make it difficult for module consumers to diagnose issues and maintain code reliability.

To avoid this issue, define functions without the global scope modifier, or use other appropriate scope modifiers. To learn more, see about_Scopes.

Example

Noncompliant

function global:functionName {}

Compliant

function functionName {}