Skip to content

Commit

Permalink
Assure variable naming rule always use a pattern (#1667)
Browse files Browse the repository at this point in the history
Fixes bug which made the rule raise an error when options were
not initialized (var_naming_pattern being None).
  • Loading branch information
ssbarnea committed Jul 15, 2021
1 parent 97d74ee commit 1fe4e47
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
1 change: 0 additions & 1 deletion src/ansiblelint/cli.py
Expand Up @@ -327,7 +327,6 @@ def merge_config(file_config: Dict[Any, Any], cli_config: Namespace) -> Namespac
scalar_map = {
"loop_var_prefix": None,
"project_dir": ".",
"var_naming_pattern": "^[a-z_][a-z0-9_]*$",
}

if not file_config:
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/rules/VariableNamingRule.py
Expand Up @@ -44,7 +44,7 @@ class VariableNamingRule(AnsibleLintRule):

@lru_cache()
def re_pattern(self) -> Pattern[str]:
return re.compile(options.var_naming_pattern)
return re.compile(options.var_naming_pattern or "^[a-z_][a-z0-9_]*$")

def is_invalid_variable_name(self, ident: str) -> bool:
"""Check if variable name is using right pattern."""
Expand Down

0 comments on commit 1fe4e47

Please sign in to comment.