Skip to content

Commit

Permalink
mitigated pylint findings from CI
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Jun 10, 2024
1 parent 9c64240 commit 5ae19c0
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
1 change: 1 addition & 0 deletions .github/workflows/scriptcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ jobs:
python -m pip install pygments
python -m pip install requests
python -m pip install psutil
python -m pip install setuptools
- name: run Shellcheck
if: matrix.python-latest
Expand Down
40 changes: 20 additions & 20 deletions addons/namingng.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ class Config:
if have_error:
sys.exit(1)

# pylint: disable-next=no-member - TODO: fix this
if config.include_guard:
# pylint: disable-next=no-member - TODO: fix this
config.include_guard_header_re = config.include_guard.get('RE_HEADERFILE',"[^/].*\\.h\\Z")

return config


Expand Down Expand Up @@ -208,6 +213,7 @@ def report_pending_ifndef(directive,column):

last_fn = None
pending_ifndef = None
guard_column = None
phase = 0
for directive in cfg.directives:
if last_fn != directive.file:
Expand All @@ -219,7 +225,7 @@ def report_pending_ifndef(directive,column):
if phase == -1:
# ignore (the remainder of) this file
continue
if not re.match(include_guard_header_re,directive.file):
if not re.match(conf.include_guard_header_re,directive.file):
phase = -1
continue

Expand Down Expand Up @@ -263,22 +269,16 @@ def report_pending_ifndef(directive,column):
if pending_ifndef:
report_pending_ifndef(pending_ifndef,guard_column)

def process(dumpfiles, configfile):
def process(dumpfiles, configfile, cli, debugprint):
conf = loadConfig(configfile)

# pylint: disable-next=no-member - TODO: fix this
if conf.include_guard:
global include_guard_header_re
# pylint: disable-next=no-member - TODO: fix this
include_guard_header_re = conf.include_guard.get('RE_HEADERFILE',"[^/].*\\.h\\Z")

for afile in dumpfiles:
if not afile[-5:] == '.dump':
continue
if not args.cli:
if not cli:
print('Checking ' + afile + '...')
data = cppcheckdata.CppcheckData(afile)
process_data(conf,data)
process_data(conf,data,cli,debugprint)

def check_file_naming(conf,data):
for source_file in data.files:
Expand All @@ -299,7 +299,7 @@ def check_namespace_naming(conf,data):
for exp in conf.namespace:
evalExpr(conf.namespace, exp, mockToken, 'Namespace')

def check_variable_naming(conf,cfg):
def check_variable_naming(conf,cfg,debugprint):
for var in cfg.variables:
if not var.nameToken:
continue
Expand All @@ -311,7 +311,7 @@ def check_variable_naming(conf,cfg):
prev = prev.previous
varType = prev.str + varType

if args.debugprint:
if debugprint:
print("Variable Name: " + str(var.nameToken.str))
print("original Type Name: " + str(var.nameToken.valueType.originalTypeName))
print("Type Name: " + var.nameToken.valueType.type)
Expand Down Expand Up @@ -344,7 +344,7 @@ def check_gpp_naming(conf_list,cfg,access,message):
for exp in conf_list:
evalExpr(conf_list, exp, mockToken, message)

def check_function_naming(conf,cfg):
def check_function_naming(conf,cfg,debugprint):
for token in cfg.tokenlist:
if not token.function:
continue
Expand All @@ -355,7 +355,7 @@ def check_function_naming(conf,cfg):
while "*" in retval and len(retval.replace("*", "")) == 0:
prev = prev.previous
retval = prev.str + retval
if args.debugprint:
if debugprint:
print("\t:: {} {}".format(retval, token.function.name))

if retval and retval in conf.function_prefixes:
Expand All @@ -375,7 +375,7 @@ def check_class_naming(conf,cfg):
for exp in conf.class_name:
evalExpr(conf.class_name, exp, mockToken, msgType)

def process_data(conf,data):
def process_data(conf,data,cli,debugprint):
if conf.file:
check_file_naming(conf,data)

Expand All @@ -384,21 +384,21 @@ def process_data(conf,data):

unguarded_include_files = []
if conf.include_guard and conf.include_guard.get('required',1):
unguarded_include_files = [fn for fn in data.files if re.match(include_guard_header_re,fn)]
unguarded_include_files = [fn for fn in data.files if re.match(conf.include_guard_header_re,fn)]

for cfg in data.configurations:
if not args.cli:
if not cli:
print('Checking config %s...' % cfg.name)
if conf.variable:
check_variable_naming(conf,cfg)
check_variable_naming(conf,cfg,debugprint)
if conf.private_member:
check_gpp_naming(conf.private_member,cfg,'Private','Private member variable')
if conf.public_member:
check_gpp_naming(conf.public_member,cfg,'Public','Public member variable')
if conf.global_variable:
check_gpp_naming(conf.global_variable,cfg,'Global','Global variable')
if conf.function_name:
check_function_naming(conf,cfg)
check_function_naming(conf,cfg,debugprint)
if conf.class_name:
check_class_naming(conf,cfg)
if conf.include_guard:
Expand All @@ -416,6 +416,6 @@ def process_data(conf,data):
help="Naming check config file")

args = parser.parse_args()
process(args.dumpfile, args.configfile)
process(args.dumpfile, args.configfile, args.cli, args.debugprint)

sys.exit(0)
3 changes: 2 additions & 1 deletion htmlreport/cppcheck-htmlreport
Original file line number Diff line number Diff line change
Expand Up @@ -888,11 +888,12 @@ def main() -> None:
except KeyError:
pass

cwe_url = ""
try:
if error['cwe']:
cwe_url = "<a href=\"https://cwe.mitre.org/data/definitions/" + error['cwe'] + ".html\">" + error['cwe'] + "</a>"
except KeyError:
cwe_url = ""
pass

if error['severity'] in ['error', 'warning']:
message_class = error['severity']
Expand Down
4 changes: 2 additions & 2 deletions tools/donate-cpu-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/
# Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic
# changes)
SERVER_VERSION = "1.3.53"
SERVER_VERSION = "1.3.54"

OLD_VERSION = '2.14.0'

Expand Down Expand Up @@ -1204,7 +1204,7 @@ def run(self):
text = check_library_function_name(self.resultPath, var_name, queryParams, nonfunc_id='unknownMacro')
httpGetResponse(self.connection, text, 'text/plain')
else:
filename = resultPath + url
filename = self.resultPath + url
if not os.path.isfile(filename):
print_ts('HTTP/1.1 404 Not Found')
self.connection.send(b'HTTP/1.1 404 Not Found\r\n\r\n')
Expand Down
2 changes: 2 additions & 0 deletions tools/matchcompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,8 @@ def convertFile(self, srcname, destname, line_directive):
for line in srclines:
if not modified:
line_orig = line
else:
line_orig = None

linenr += 1
# Compile Token::Match and Token::simpleMatch
Expand Down

0 comments on commit 5ae19c0

Please sign in to comment.