Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py

branch
6_0_x
changeset 4448
a04937db5f68
parent 4022
f5f42921717e
equal deleted inserted replaced
4442:3485061166ca 4448:a04937db5f68
152 docStyleChecker.run() 152 docStyleChecker.run()
153 stats.update(docStyleChecker.counters) 153 stats.update(docStyleChecker.counters)
154 154
155 errors = report.errors + docStyleChecker.errors 155 errors = report.errors + docStyleChecker.errors
156 156
157 deferredFixes = {} 157 errorsDict = {}
158 results = []
159 for fname, lineno, position, text in errors: 158 for fname, lineno, position, text in errors:
160 if lineno > len(source): 159 if lineno > len(source):
161 lineno = len(source) 160 lineno = len(source)
162 if source: 161 # inverse processing of messages and fixes
163 if "__IGNORE_WARNING__" not in \ 162 errorLine = errorsDict.setdefault(lineno, [])
164 extractLineFlags(source[lineno - 1].strip()): 163 errorLine.append([position, text])
165 if fixer: 164 deferredFixes = {}
166 res, msg, id_ = fixer.fixIssue(lineno, position, text) 165 results = []
167 if res == -1: 166 for lineno, errors in errorsDict.items():
168 itm = [lineno, position, text] 167 errors.sort(key=lambda x: x[0], reverse=True)
169 deferredFixes[id_] = itm 168 for position, text in errors:
169 if source:
170 if "__IGNORE_WARNING__" not in \
171 extractLineFlags(source[lineno - 1].strip()):
172 if fixer:
173 res, msg, id_ = fixer.fixIssue(lineno, position, text)
174 if res == -1:
175 itm = [lineno, position, text]
176 deferredFixes[id_] = itm
177 else:
178 itm = [lineno, position, text, False,
179 res == 1, True, msg]
170 else: 180 else:
171 itm = [lineno, position, text, False, 181 itm = [lineno, position, text, False,
172 res == 1, True, msg] 182 False, False, '']
183 results.append(itm)
173 else: 184 else:
174 itm = [lineno, position, text, False, 185 results.append([lineno, position, text, True,
175 False, False, ''] 186 False, False, ''])
176 results.append(itm)
177 else: 187 else:
178 results.append([lineno, position, text, True, 188 results.append([lineno, position, text, False,
179 False, False, '']) 189 False, False, ''])
180 else:
181 results.append([lineno, position, text, False,
182 False, False, ''])
183 190
184 if fixer: 191 if fixer:
185 deferredResults = fixer.finalize() 192 deferredResults = fixer.finalize()
186 for id_ in deferredResults: 193 for id_ in deferredResults:
187 fixed, msg = deferredResults[id_] 194 fixed, msg = deferredResults[id_]

eric ide

mercurial