Skip to content

Commit

Permalink
addons/namingng.py: allow function and variable name test without req…
Browse files Browse the repository at this point in the history
…uiring prefixes

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.
  • Loading branch information
mvds00 committed Dec 23, 2023
1 parent 5a222b8 commit 75488f4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions addons/namingng.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'))
Expand Down

0 comments on commit 75488f4

Please sign in to comment.