def unknown_globals(self, scope): # helper functions not_jsignored = inverse(gs.test_ident_is_jsignored) not_builtin = inverse(gs.test_ident_is_builtin()) not_libsymbol = inverse(curry3(gs.test_for_libsymbol, self.opts.class_namespaces)(self.known_globals_bases)) not_confsymbol = lambda node: globals_table[node] not in self.opts.allowed_globals def warn_appender(global_nodes): for node in global_nodes: issue = warn("Unknown global symbol used: '%s'" % globals_table[node], self.file_name, node) self.issues.append(issue) # ------------------------------ # collect scope's global use locations globals_table = {} # {node: assembled} for id_, scopeVar in scope.globals().items(): for head_node in scopeVar.uses: var_top = treeutil.findVarRoot(head_node) assembled = (treeutil.assembleVariable(var_top))[0] globals_table[head_node] = assembled # filter and add remains to warnings pipeline( globals_table.keys() , bind(filter, not_builtin) , bind(filter, not_jsignored) , bind(filter, not_libsymbol) , bind(filter, not_confsymbol) , warn_appender )
def unknown_globals(self, scope): # helper functions not_jsignored = inverse(gs.test_ident_is_jsignored) not_builtin = inverse(gs.test_ident_is_builtin()) not_libsymbol = inverse(curry3(gs.test_for_libsymbol, self.opts.class_namespaces)(self.known_globals_bases)) not_confsymbol = lambda node: globals_table[node] not in self.opts.allowed_globals def warn_appender(global_nodes): for node in global_nodes: issue = warn("Unknown global symbol used: '%s'" % globals_table[node], self.file_name, node) issue.name = globals_table[node] # @deprecated {3.0} to filter against #ignore later self.issues.append(issue) # ------------------------------ # collect scope's global use locations globals_table = {} # {node: assembled} for id_, scopeVar in scope.globals().items(): for head_node in scopeVar.uses: var_top = treeutil.findVarRoot(head_node) assembled = (treeutil.assembleVariable(var_top))[0] globals_table[head_node] = assembled # filter and add remains to warnings pipeline( globals_table.keys() , bind(filter, not_builtin) , bind(filter, not_jsignored) , bind(filter, not_libsymbol) , bind(filter, not_confsymbol) , warn_appender )
def filter_libsymbols(self, global_nodes): is_libsymbol = curry3(gs.test_for_libsymbol, self.opts.class_namespaces)(self.known_globals_bases) # known classes (classList + namespaces) return dict([(key,nodes) for (key,nodes) in global_nodes.items() if not is_libsymbol(key)])