diff -r ca1ce1e0fcff -r 382f89c11e27 eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/__init__.py --- a/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/__init__.py Mon Jun 08 08:17:14 2020 +0200 +++ b/eric6/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/__init__.py Mon Jun 08 20:08:27 2020 +0200 @@ -8,23 +8,29 @@ """ import collections - -_checkermodules = [ - "blackListCalls", - "blackListImports", -] +import os def generateCheckersDict(): """ - Function generate the dictionary with checkers. + Function to generate the dictionary with checkers. + + Checker modules are searched for inside this package. Each module + defining some checks must contain a function 'getChecks()' returning + a dictionary containing the check type as key and a list of tuples + with the check function and associated message codes. @return dictionary containing list of tuples with checker data @rtype dict """ checkersDict = collections.defaultdict(list) - for checkerModule in _checkermodules: + checkersDirectory = os.path.dirname(__file__) + checkerModules = [os.path.splitext(m)[0] + for m in os.listdir(checkersDirectory) + if m != "__init__.py" and m.endswith(".py")] + + for checkerModule in checkerModules: modName = "Security.Checks.{0}".format(checkerModule) try: mod = __import__(modName) @@ -38,7 +44,7 @@ continue modCheckersDict = mod.getChecks() - for checktype, check in modCheckersDict.items(): - checkersDict[checktype].append(check) + for checktype, checks in modCheckersDict.items(): + checkersDict[checktype].extend(checks) return checkersDict