Skip to content

Commit f65ffc8

Browse files
committed
mitigated pylint findings from CI
1 parent 51c173c commit f65ffc8

5 files changed

Lines changed: 23 additions & 19 deletions

File tree

.github/workflows/scriptcheck.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ jobs:
8989
python -m pip install pygments
9090
python -m pip install requests
9191
python -m pip install psutil
92+
python -m pip install setuptools
9293
9394
- name: run Shellcheck
9495
if: matrix.python-latest

addons/namingng.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ class Config:
146146
if have_error:
147147
sys.exit(1)
148148

149+
# pylint: disable-next=no-member - TODO: fix this
150+
if config.include_guard:
151+
# pylint: disable-next=no-member - TODO: fix this
152+
config.include_guard_header_re = config.include_guard.get('RE_HEADERFILE',"[^/].*\\.h\\Z")
153+
149154
return config
150155

151156

@@ -208,6 +213,7 @@ def report_pending_ifndef(directive,column):
208213

209214
last_fn = None
210215
pending_ifndef = None
216+
guard_column = None
211217
phase = 0
212218
for directive in cfg.directives:
213219
if last_fn != directive.file:
@@ -219,7 +225,7 @@ def report_pending_ifndef(directive,column):
219225
if phase == -1:
220226
# ignore (the remainder of) this file
221227
continue
222-
if not re.match(include_guard_header_re,directive.file):
228+
if not re.match(conf.include_guard_header_re,directive.file):
223229
phase = -1
224230
continue
225231

@@ -263,22 +269,16 @@ def report_pending_ifndef(directive,column):
263269
if pending_ifndef:
264270
report_pending_ifndef(pending_ifndef,guard_column)
265271

266-
def process(dumpfiles, configfile):
272+
def process(dumpfiles, configfile, cli, debugprint):
267273
conf = loadConfig(configfile)
268274

269-
# pylint: disable-next=no-member - TODO: fix this
270-
if conf.include_guard:
271-
global include_guard_header_re
272-
# pylint: disable-next=no-member - TODO: fix this
273-
include_guard_header_re = conf.include_guard.get('RE_HEADERFILE',"[^/].*\\.h\\Z")
274-
275275
for afile in dumpfiles:
276276
if not afile[-5:] == '.dump':
277277
continue
278-
if not args.cli:
278+
if not cli:
279279
print('Checking ' + afile + '...')
280280
data = cppcheckdata.CppcheckData(afile)
281-
process_data(conf,data)
281+
process_data(conf,data,debugprint)
282282

283283
def check_file_naming(conf,data):
284284
for source_file in data.files:
@@ -299,7 +299,7 @@ def check_namespace_naming(conf,data):
299299
for exp in conf.namespace:
300300
evalExpr(conf.namespace, exp, mockToken, 'Namespace')
301301

302-
def check_variable_naming(conf,cfg):
302+
def check_variable_naming(conf,cfg,debugprint):
303303
for var in cfg.variables:
304304
if not var.nameToken:
305305
continue
@@ -311,7 +311,7 @@ def check_variable_naming(conf,cfg):
311311
prev = prev.previous
312312
varType = prev.str + varType
313313

314-
if args.debugprint:
314+
if debugprint:
315315
print("Variable Name: " + str(var.nameToken.str))
316316
print("original Type Name: " + str(var.nameToken.valueType.originalTypeName))
317317
print("Type Name: " + var.nameToken.valueType.type)
@@ -375,7 +375,7 @@ def check_class_naming(conf,cfg):
375375
for exp in conf.class_name:
376376
evalExpr(conf.class_name, exp, mockToken, msgType)
377377

378-
def process_data(conf,data):
378+
def process_data(conf,data,debugprint):
379379
if conf.file:
380380
check_file_naming(conf,data)
381381

@@ -384,13 +384,13 @@ def process_data(conf,data):
384384

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

389389
for cfg in data.configurations:
390390
if not args.cli:
391391
print('Checking config %s...' % cfg.name)
392392
if conf.variable:
393-
check_variable_naming(conf,cfg)
393+
check_variable_naming(conf,cfg,debugprint)
394394
if conf.private_member:
395395
check_gpp_naming(conf.private_member,cfg,'Private','Private member variable')
396396
if conf.public_member:
@@ -416,6 +416,6 @@ def process_data(conf,data):
416416
help="Naming check config file")
417417

418418
args = parser.parse_args()
419-
process(args.dumpfile, args.configfile)
419+
process(args.dumpfile, args.configfile, args.cli, args.debugprint)
420420

421421
sys.exit(0)

htmlreport/cppcheck-htmlreport

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,11 +888,12 @@ def main() -> None:
888888
except KeyError:
889889
pass
890890

891+
cwe_url = ""
891892
try:
892893
if error['cwe']:
893894
cwe_url = "<a href=\"https://cwe.mitre.org/data/definitions/" + error['cwe'] + ".html\">" + error['cwe'] + "</a>"
894895
except KeyError:
895-
cwe_url = ""
896+
pass
896897

897898
if error['severity'] in ['error', 'warning']:
898899
message_class = error['severity']

tools/donate-cpu-server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/
2727
# Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic
2828
# changes)
29-
SERVER_VERSION = "1.3.53"
29+
SERVER_VERSION = "1.3.54"
3030

3131
OLD_VERSION = '2.14.0'
3232

@@ -1204,7 +1204,7 @@ def run(self):
12041204
text = check_library_function_name(self.resultPath, var_name, queryParams, nonfunc_id='unknownMacro')
12051205
httpGetResponse(self.connection, text, 'text/plain')
12061206
else:
1207-
filename = resultPath + url
1207+
filename = self.resultPath + url
12081208
if not os.path.isfile(filename):
12091209
print_ts('HTTP/1.1 404 Not Found')
12101210
self.connection.send(b'HTTP/1.1 404 Not Found\r\n\r\n')

tools/matchcompiler.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,8 @@ def convertFile(self, srcname, destname, line_directive):
691691
for line in srclines:
692692
if not modified:
693693
line_orig = line
694+
else:
695+
line_orig = None
694696

695697
linenr += 1
696698
# Compile Token::Match and Token::simpleMatch

0 commit comments

Comments
 (0)