src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/NameOrder/NameOrderChecker.py

branch
eric7
changeset 11142
2f0fb22c1d63
parent 11090
f5f5f5803935
child 11145
d328a7b74fd8
equal deleted inserted replaced
11141:2f5f73c51c7c 11142:2f0fb22c1d63
26 "NO102", 26 "NO102",
27 "NO103", 27 "NO103",
28 "NO104", 28 "NO104",
29 "NO105", 29 "NO105",
30 ] 30 ]
31 Prefix = "NO"
31 32
32 def __init__(self, source, filename, tree, select, ignore, expected, repeat, args): 33 def __init__(self, source, filename, tree, select, ignore, expected, repeat, args):
33 """ 34 """
34 Constructor 35 Constructor
35 36
48 @param repeat flag indicating to report each occurrence of a code 49 @param repeat flag indicating to report each occurrence of a code
49 @type bool 50 @type bool
50 @param args dictionary of arguments for the various checks 51 @param args dictionary of arguments for the various checks
51 @type dict 52 @type dict
52 """ 53 """
53 self.__select = tuple(select) 54 self.__select = tuple(
54 self.__ignore = ("",) if select else tuple(ignore) 55 x for x in select if x.startswith(NameOrderChecker.Prefix)
56 )
57 self.__ignore = tuple(
58 x for x in ignore if x.startswith(NameOrderChecker.Prefix)
59 )
55 self.__expected = expected[:] 60 self.__expected = expected[:]
56 self.__repeat = repeat 61 self.__repeat = repeat
57 self.__filename = filename 62 self.__filename = filename
58 self.__source = source[:] 63 self.__source = source[:]
59 self.__tree = copy.deepcopy(tree) 64 self.__tree = copy.deepcopy(tree)
89 @param code message code to check for 94 @param code message code to check for
90 @type str 95 @type str
91 @return flag indicating to ignore the given code 96 @return flag indicating to ignore the given code
92 @rtype bool 97 @rtype bool
93 """ 98 """
94 return code.startswith(self.__ignore) and not code.startswith(self.__select) 99 return (
100 code in self.__ignore
101 or (code.startswith(self.__ignore) and not code.startswith(self.__select))
102 )
95 103
96 def __error(self, lineNumber, offset, code, *args): 104 def __error(self, lineNumber, offset, code, *args):
97 """ 105 """
98 Private method to record an issue. 106 Private method to record an issue.
99 107

eric ide

mercurial