Skip to content

Commit d506e7e

Browse files
authored
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.
1 parent 9118d33 commit d506e7e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

addons/namingng.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def process(dumpfiles, configfile, debugprint=False):
132132

133133
if conf["skip_one_char_variables"] and len(var.nameToken.str) == 1:
134134
continue
135-
if varType in conf["var_prefixes"]:
135+
if varType in conf.get("var_prefixes",{}):
136136
if not var.nameToken.str.startswith(conf["var_prefixes"][varType]):
137137
errors.append(reportError(
138138
var.typeStartToken.file,
@@ -192,7 +192,7 @@ def process(dumpfiles, configfile, debugprint=False):
192192
if debugprint:
193193
print("\t:: {} {}".format(retval, token.function.name))
194194

195-
if retval and retval in conf["function_prefixes"]:
195+
if retval and retval in conf.get("function_prefixes",{}):
196196
if not token.function.name.startswith(conf["function_prefixes"][retval]):
197197
errors.append(reportError(
198198
token.file, token.linenr, 'style', 'Function ' + token.function.name + ' violates naming convention'))

0 commit comments

Comments
 (0)