244 self.__project.getRelativePath(filename)]) |
244 self.__project.getRelativePath(filename)]) |
245 self.__lastFileItem.setFirstColumnSpanned(True) |
245 self.__lastFileItem.setFirstColumnSpanned(True) |
246 self.__lastFileItem.setExpanded(True) |
246 self.__lastFileItem.setExpanded(True) |
247 self.__lastFileItem.setData(0, self.filenameRole, filename) |
247 self.__lastFileItem.setData(0, self.filenameRole, filename) |
248 |
248 |
|
249 msgCode = result["code"].split(".", 1)[0] |
|
250 |
249 fixable = False |
251 fixable = False |
250 itm = QTreeWidgetItem( |
252 itm = QTreeWidgetItem( |
251 self.__lastFileItem, [ |
253 self.__lastFileItem, [ |
252 "{0:6}".format(result["line"]), |
254 "{0:6}".format(result["line"]), |
253 result["code"], |
255 msgCode, |
254 result["display"] |
256 result["display"] |
255 ] |
257 ] |
256 ) |
258 ) |
257 if result["code"].startswith(("W", "-", "C", "M")): |
259 if msgCode.startswith(("W", "-", "C", "M")): |
258 itm.setIcon(1, UI.PixmapCache.getIcon("warning")) |
260 itm.setIcon(1, UI.PixmapCache.getIcon("warning")) |
259 elif result["code"].startswith(("A", "N")): |
261 elif msgCode.startswith(("A", "N")): |
260 itm.setIcon(1, UI.PixmapCache.getIcon("namingError")) |
262 itm.setIcon(1, UI.PixmapCache.getIcon("namingError")) |
261 elif result["code"].startswith("D"): |
263 elif msgCode.startswith("D"): |
262 itm.setIcon(1, UI.PixmapCache.getIcon("docstringError")) |
264 itm.setIcon(1, UI.PixmapCache.getIcon("docstringError")) |
263 elif result["code"].startswith("S"): |
265 elif msgCode.startswith("S"): |
264 if "severity" in result: |
266 if "severity" in result: |
265 if result["severity"] == "H": |
267 if result["severity"] == "H": |
266 itm.setIcon(1, UI.PixmapCache.getIcon("securityLow")) |
268 itm.setIcon(1, UI.PixmapCache.getIcon("securityLow")) |
267 elif result["severity"] == "M": |
269 elif result["severity"] == "M": |
268 itm.setIcon(1, UI.PixmapCache.getIcon("securityMedium")) |
270 itm.setIcon(1, UI.PixmapCache.getIcon("securityMedium")) |
275 else: |
277 else: |
276 itm.setIcon(1, UI.PixmapCache.getIcon("syntaxError")) |
278 itm.setIcon(1, UI.PixmapCache.getIcon("syntaxError")) |
277 if result["fixed"]: |
279 if result["fixed"]: |
278 itm.setIcon(0, UI.PixmapCache.getIcon("issueFixed")) |
280 itm.setIcon(0, UI.PixmapCache.getIcon("issueFixed")) |
279 elif ( |
281 elif ( |
280 result["code"] in FixableCodeStyleIssues and |
282 msgCode in FixableCodeStyleIssues and |
281 not result["autofixing"] and |
283 not result["autofixing"] and |
282 result["code"] not in self.__noFixCodesList |
284 msgCode not in self.__noFixCodesList |
283 ): |
285 ): |
284 itm.setIcon(0, UI.PixmapCache.getIcon("issueFixable")) |
286 itm.setIcon(0, UI.PixmapCache.getIcon("issueFixable")) |
285 fixable = True |
287 fixable = True |
286 |
288 |
287 itm.setTextAlignment(0, Qt.AlignRight) |
289 itm.setTextAlignment(0, Qt.AlignRight) |
294 itm.setData(0, self.filenameRole, filename) |
296 itm.setData(0, self.filenameRole, filename) |
295 itm.setData(0, self.lineRole, int(result["line"])) |
297 itm.setData(0, self.lineRole, int(result["line"])) |
296 itm.setData(0, self.positionRole, int(result["offset"])) |
298 itm.setData(0, self.positionRole, int(result["offset"])) |
297 itm.setData(0, self.messageRole, result["display"]) |
299 itm.setData(0, self.messageRole, result["display"]) |
298 itm.setData(0, self.fixableRole, fixable) |
300 itm.setData(0, self.fixableRole, fixable) |
299 itm.setData(0, self.codeRole, result["code"].split(".", 1)[0]) |
301 itm.setData(0, self.codeRole, msgCode) |
300 itm.setData(0, self.ignoredRole, result["ignored"]) |
302 itm.setData(0, self.ignoredRole, result["ignored"]) |
301 itm.setData(0, self.argsRole, result["args"]) |
303 itm.setData(0, self.argsRole, result["args"]) |
302 |
304 |
303 if result["ignored"]: |
305 if result["ignored"]: |
304 font = itm.font(0) |
306 font = itm.font(0) |
325 itm.setData(0, self.messageRole, result["display"]) |
327 itm.setData(0, self.messageRole, result["display"]) |
326 else: |
328 else: |
327 itm.setIcon(0, QIcon()) |
329 itm.setIcon(0, QIcon()) |
328 itm.setData(0, self.fixableRole, False) |
330 itm.setData(0, self.fixableRole, False) |
329 |
331 |
330 def __updateStatistics(self, statistics, fixer, ignoredErrors): |
332 def __updateStatistics(self, statistics, fixer, ignoredErrors, securityOk): |
331 """ |
333 """ |
332 Private method to update the collected statistics. |
334 Private method to update the collected statistics. |
333 |
335 |
334 @param statistics dictionary of statistical data with |
336 @param statistics dictionary of statistical data with |
335 message code as key and message count as value |
337 message code as key and message count as value |
336 @type dict |
338 @type dict |
337 @param fixer reference to the code style fixer |
339 @param fixer reference to the code style fixer |
338 @type CodeStyleFixer |
340 @type CodeStyleFixer |
339 @param ignoredErrors number of ignored errors |
341 @param ignoredErrors number of ignored errors |
|
342 @type int |
|
343 @param securityOk number of acknowledged security reports |
340 @type int |
344 @type int |
341 """ |
345 """ |
342 self.__statistics["_FilesCount"] += 1 |
346 self.__statistics["_FilesCount"] += 1 |
343 stats = [k for k in statistics.keys() if k[0].isupper()] |
347 stats = [k for k in statistics.keys() if k[0].isupper()] |
344 if stats: |
348 if stats: |
348 self.__statistics[key] += statistics[key] |
352 self.__statistics[key] += statistics[key] |
349 else: |
353 else: |
350 self.__statistics[key] = statistics[key] |
354 self.__statistics[key] = statistics[key] |
351 self.__statistics["_IssuesFixed"] += fixer |
355 self.__statistics["_IssuesFixed"] += fixer |
352 self.__statistics["_IgnoredErrors"] += ignoredErrors |
356 self.__statistics["_IgnoredErrors"] += ignoredErrors |
|
357 self.__statistics["_SecurityOK"] += securityOk |
353 |
358 |
354 def __updateFixerStatistics(self, fixer): |
359 def __updateFixerStatistics(self, fixer): |
355 """ |
360 """ |
356 Private method to update the collected fixer related statistics. |
361 Private method to update the collected fixer related statistics. |
357 |
362 |
367 self.__statistics = {} |
372 self.__statistics = {} |
368 self.__statistics["_FilesCount"] = 0 |
373 self.__statistics["_FilesCount"] = 0 |
369 self.__statistics["_FilesIssues"] = 0 |
374 self.__statistics["_FilesIssues"] = 0 |
370 self.__statistics["_IssuesFixed"] = 0 |
375 self.__statistics["_IssuesFixed"] = 0 |
371 self.__statistics["_IgnoredErrors"] = 0 |
376 self.__statistics["_IgnoredErrors"] = 0 |
|
377 self.__statistics["_SecurityOK"] = 0 |
372 |
378 |
373 def prepare(self, fileList, project): |
379 def prepare(self, fileList, project): |
374 """ |
380 """ |
375 Public method to prepare the dialog with a list of filenames. |
381 Public method to prepare the dialog with a list of filenames. |
376 |
382 |
810 self.resultList.setUpdatesEnabled(False) |
816 self.resultList.setUpdatesEnabled(False) |
811 self.resultList.setSortingEnabled(False) |
817 self.resultList.setSortingEnabled(False) |
812 |
818 |
813 fixed = None |
819 fixed = None |
814 ignoredErrors = 0 |
820 ignoredErrors = 0 |
|
821 securityOk = 0 |
815 if self.__itms: |
822 if self.__itms: |
816 for itm, result in zip(self.__itms, results): |
823 for itm, result in zip(self.__itms, results): |
817 self.__modifyFixedResultItem(itm, result) |
824 self.__modifyFixedResultItem(itm, result) |
818 self.__updateFixerStatistics(fixes) |
825 self.__updateFixerStatistics(fixes) |
819 else: |
826 else: |
826 result["display"] = self.tr( |
833 result["display"] = self.tr( |
827 "{0} (ignored)" |
834 "{0} (ignored)" |
828 ).format(result["display"]) |
835 ).format(result["display"]) |
829 else: |
836 else: |
830 continue |
837 continue |
|
838 |
|
839 elif result["securityOk"]: |
|
840 securityOk += 1 |
|
841 continue |
|
842 |
831 self.results = CodeStyleCheckerDialog.hasResults |
843 self.results = CodeStyleCheckerDialog.hasResults |
832 self.__createResultItem(fn, result) |
844 self.__createResultItem(fn, result) |
833 |
845 |
834 self.__updateStatistics( |
846 self.__updateStatistics( |
835 codeStyleCheckerStats, fixes, ignoredErrors) |
847 codeStyleCheckerStats, fixes, ignoredErrors, securityOk) |
836 |
848 |
837 if fixed: |
849 if fixed: |
838 vm = e5App().getObject("ViewManager") |
850 vm = e5App().getObject("ViewManager") |
839 editor = vm.getOpenEditor(fn) |
851 editor = vm.getOpenEditor(fn) |
840 if editor: |
852 if editor: |