From d506e7e9372fbcf912c65ac6876250b42aa077c6 Mon Sep 17 00:00:00 2001 From: thingsconnected <45596685+thingsconnected@users.noreply.github.com> Date: Sat, 23 Dec 2023 22:33:36 +0100 Subject: [PATCH] addons/namingng.py: allow function/variable name test without prefixes (#5801) This patch allows a config file to have RE_VARNAME and RE_FUNCTIONNAME without the corresponding var_prefixes and function_prefixes keys. The namingng.py processing function would otherwise raise an exception trying to get these keys, while they are not strictly necessary, if no prefixes are required. --- addons/namingng.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/namingng.py b/addons/namingng.py index 73f1b08ec..a543669d5 100755 --- a/addons/namingng.py +++ b/addons/namingng.py @@ -132,7 +132,7 @@ def process(dumpfiles, configfile, debugprint=False): if conf["skip_one_char_variables"] and len(var.nameToken.str) == 1: continue - if varType in conf["var_prefixes"]: + if varType in conf.get("var_prefixes",{}): if not var.nameToken.str.startswith(conf["var_prefixes"][varType]): errors.append(reportError( var.typeStartToken.file, @@ -192,7 +192,7 @@ def process(dumpfiles, configfile, debugprint=False): if debugprint: print("\t:: {} {}".format(retval, token.function.name)) - if retval and retval in conf["function_prefixes"]: + if retval and retval in conf.get("function_prefixes",{}): if not token.function.name.startswith(conf["function_prefixes"][retval]): errors.append(reportError( token.file, token.linenr, 'style', 'Function ' + token.function.name + ' violates naming convention'))