mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-27 18:50:21 -07:00
Fix module validator blacklist handling.
Process the blacklist before creating a validator instance.
This commit is contained in:
parent
8382ed7200
commit
442768c45e
1 changed files with 21 additions and 11 deletions
|
@ -834,20 +834,26 @@ class ModuleValidator(Validator):
|
||||||
(option, should_be, version_added))
|
(option, should_be, version_added))
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def is_blacklisted(path):
|
||||||
|
base_name = os.path.basename(path)
|
||||||
|
file_name, _ = os.path.splitext(base_name)
|
||||||
|
|
||||||
|
if file_name.startswith('_') and os.path.islink(path):
|
||||||
|
return True
|
||||||
|
|
||||||
|
if not frozenset((base_name, file_name)).isdisjoint(ModuleValidator.BLACKLIST):
|
||||||
|
return True
|
||||||
|
|
||||||
|
for pat in ModuleValidator.BLACKLIST_PATTERNS:
|
||||||
|
if fnmatch(base_name, pat):
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
super(ModuleValidator, self).validate()
|
super(ModuleValidator, self).validate()
|
||||||
|
|
||||||
if self.object_name.startswith('_') and os.path.islink(self.object_path):
|
|
||||||
return
|
|
||||||
|
|
||||||
# Blacklists -- these files are not checked
|
|
||||||
if not frozenset((self.basename,
|
|
||||||
self.name)).isdisjoint(self.BLACKLIST):
|
|
||||||
return
|
|
||||||
for pat in self.BLACKLIST_PATTERNS:
|
|
||||||
if fnmatch(self.basename, pat):
|
|
||||||
return
|
|
||||||
|
|
||||||
# if self._powershell_module():
|
# if self._powershell_module():
|
||||||
# self.warnings.append('Cannot check powershell modules at this '
|
# self.warnings.append('Cannot check powershell modules at this '
|
||||||
# 'time. Skipping')
|
# 'time. Skipping')
|
||||||
|
@ -974,6 +980,8 @@ def main():
|
||||||
path = module
|
path = module
|
||||||
if args.exclude and args.exclude.search(path):
|
if args.exclude and args.exclude.search(path):
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
if ModuleValidator.is_blacklisted(path):
|
||||||
|
sys.exit(0)
|
||||||
with ModuleValidator(path, analyze_arg_spec=args.arg_spec,
|
with ModuleValidator(path, analyze_arg_spec=args.arg_spec,
|
||||||
base_branch=args.base_branch, git_cache=git_cache) as mv:
|
base_branch=args.base_branch, git_cache=git_cache) as mv:
|
||||||
mv.validate()
|
mv.validate()
|
||||||
|
@ -997,6 +1005,8 @@ def main():
|
||||||
path = os.path.join(root, filename)
|
path = os.path.join(root, filename)
|
||||||
if args.exclude and args.exclude.search(path):
|
if args.exclude and args.exclude.search(path):
|
||||||
continue
|
continue
|
||||||
|
if ModuleValidator.is_blacklisted(path):
|
||||||
|
continue
|
||||||
with ModuleValidator(path, analyze_arg_spec=args.arg_spec,
|
with ModuleValidator(path, analyze_arg_spec=args.arg_spec,
|
||||||
base_branch=args.base_branch, git_cache=git_cache) as mv:
|
base_branch=args.base_branch, git_cache=git_cache) as mv:
|
||||||
mv.validate()
|
mv.validate()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue