cppcheckdata.py: Fix PEP 8 and Inspection warnings (#2350)

This commit is contained in:
Sebastian 2019-11-12 09:30:43 +01:00 committed by GitHub
parent f5a6aa530d
commit bd5d82c9bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 9 deletions

View File

@ -6,7 +6,7 @@ This is a Python module that helps you access Cppcheck dump data.
License: No restrictions, use this as you need.
"""
import xml.etree.ElementTree as ET
from xml.etree import ElementTree
import argparse
from fnmatch import fnmatch
import json
@ -321,7 +321,8 @@ class Scope:
self.nestedInId = element.get('nestedIn')
self.nestedIn = None
self.type = element.get('type')
self.isExecutable = (self.type in ('Function', 'If', 'Else', 'For', 'While', 'Do', 'Switch', 'Try', 'Catch', 'Unconditional', 'Lambda'))
self.isExecutable = (self.type in ('Function', 'If', 'Else', 'For', 'While', 'Do',
'Switch', 'Try', 'Catch', 'Unconditional', 'Lambda'))
def setId(self, IdMap):
self.bodyStart = IdMap[self.bodyStartId]
@ -523,6 +524,7 @@ class ValueFlow:
for value in element:
self.values.append(ValueFlow.Value(value))
class Suppression:
"""
Suppression class
@ -555,6 +557,7 @@ class Suppression:
else:
return False
class Configuration:
"""
Configuration class
@ -684,6 +687,7 @@ class Platform:
self.long_long_bit = int(platformnode.get('long_long_bit'))
self.pointer_bit = int(platformnode.get('pointer_bit'))
class Standards:
"""
Standards class
@ -698,7 +702,8 @@ class Standards:
def __init__(self, standardsnode):
self.c = standardsnode.find("c").get("version")
self.cpp = standardsnode.find("cpp").get("version")
self.posix = standardsnode.find("posix") != None
self.posix = standardsnode.find("posix") is not None
class CppcheckData:
"""
@ -744,7 +749,7 @@ class CppcheckData:
def __init__(self, filename):
self.configurations = []
data = ET.parse(filename)
data = ElementTree.parse(filename)
for platformNode in data.getroot():
if platformNode.tag == 'platform':
@ -765,13 +770,11 @@ class CppcheckData:
self.rawTokens[i + 1].previous = self.rawTokens[i]
self.rawTokens[i].next = self.rawTokens[i + 1]
for suppressionsNode in data.getroot():
if suppressionsNode.tag == "suppressions":
for suppression in suppressionsNode:
self.suppressions.append(Suppression(suppression))
# root is 'dumps' node, each config has its own 'dump' subnode.
for cfgnode in data.getroot():
if cfgnode.tag == 'dump':