<s> from vint . ast . node_type import NodeType <EOL> from vint . linting . level import Level <EOL> from vint . linting . policy . abstract_policy import AbstractPolicy <EOL> from vint . linting . policy_registry import register_policy <EOL> from vint . ast . plugin . scope_plugin import ScopeVisibility <EOL> @ register_policy <EOL> class ProhibitUsingUndeclaredVariable ( AbstractPolicy ) : <EOL> def __init__ ( self ) : <EOL> super ( ProhibitUsingUndeclaredVariable , self ) . __init__ ( ) <EOL> self . description = '<STR_LIT>' <EOL> self . reference = '<STR_LIT>' <EOL> self . level = Level . WARNING <EOL> def listen_node_types ( self ) : <EOL> return [ NodeType . IDENTIFIER ] <EOL> def is_valid ( self , identifier , lint_context ) : <EOL> """<STR_LIT>""" <EOL> scope_plugin = lint_context [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> is_reachable = not scope_plugin . is_unreachable_reference_identifier ( identifier ) <EOL> scope_visibility = scope_plugin . get_objective_scope_visibility ( identifier ) <EOL> is_global = scope_visibility is ScopeVisibility . GLOBAL_LIKE <EOL> is_builtin = scope_visibility is ScopeVisibility . BUILTIN <EOL> is_unanalyzable = scope_visibility is ScopeVisibility . UNANALYZABLE <EOL> is_valid = is_reachable or is_global or is_builtin or is_unanalyzable <EOL> if not is_valid : <EOL> self . _make_description ( identifier ) <EOL> return is_valid <EOL> def _make_description ( self , identifier ) : <EOL> self . description = '<STR_LIT>' . format ( <EOL> var_name = identifier [ '<STR_LIT:value>' ] ) </s>
