mirror of
https://github.com/thegeeklab/ansible-later.git
synced 2024-11-22 04:40:42 +00:00
fix linting issues
This commit is contained in:
parent
675bb6271e
commit
ccc9e5b6d7
18
.flake8
18
.flake8
@ -1,8 +1,18 @@
|
||||
[flake8]
|
||||
# Temp disable Docstring checks D101, D102, D103, D107
|
||||
ignore = E501, W503, F401, N813, D101, D102, D103, D107
|
||||
max-line-length = 110
|
||||
ignore = D102, D103, D107, D202, W503
|
||||
max-line-length = 99
|
||||
inline-quotes = double
|
||||
exclude = .git,.tox,__pycache__,build,dist,tests,*.pyc,*.egg-info,.cache,.eggs
|
||||
exclude =
|
||||
.git
|
||||
.tox
|
||||
__pycache__
|
||||
build
|
||||
dist
|
||||
tests
|
||||
*.pyc
|
||||
*.egg-info
|
||||
.cache
|
||||
.eggs
|
||||
env*
|
||||
application-import-names = ansiblelater
|
||||
format = ${cyan}%(path)s:%(row)d:%(col)d${reset}: ${red_bold}%(code)s${reset} %(text)s
|
||||
|
@ -189,6 +189,7 @@ class Candidate(object):
|
||||
|
||||
|
||||
class RoleFile(Candidate):
|
||||
"""Object classified as Ansible role file."""
|
||||
|
||||
def __init__(self, filename, settings={}, standards=[]):
|
||||
super(RoleFile, self).__init__(filename, settings, standards)
|
||||
@ -203,10 +204,13 @@ class RoleFile(Candidate):
|
||||
|
||||
|
||||
class Playbook(Candidate):
|
||||
"""Object classified as Ansible playbook."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class Task(RoleFile):
|
||||
"""Object classified as Ansible task file."""
|
||||
|
||||
def __init__(self, filename, settings={}, standards=[]):
|
||||
super(Task, self).__init__(filename, settings, standards)
|
||||
@ -214,6 +218,7 @@ class Task(RoleFile):
|
||||
|
||||
|
||||
class Handler(RoleFile):
|
||||
"""Object classified as Ansible handler file."""
|
||||
|
||||
def __init__(self, filename, settings={}, standards=[]):
|
||||
super(Handler, self).__init__(filename, settings, standards)
|
||||
@ -221,10 +226,13 @@ class Handler(RoleFile):
|
||||
|
||||
|
||||
class Vars(Candidate):
|
||||
"""Object classified as Ansible vars file."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class Unversioned(Candidate):
|
||||
"""Object classified as unversioned file."""
|
||||
|
||||
def __init__(self, filename, settings={}, standards=[]):
|
||||
super(Unversioned, self).__init__(filename, settings, standards)
|
||||
@ -232,50 +240,74 @@ class Unversioned(Candidate):
|
||||
|
||||
|
||||
class InventoryVars(Unversioned):
|
||||
"""Object classified as Ansible inventory vars."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class HostVars(InventoryVars):
|
||||
"""Object classified as Ansible host vars."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class GroupVars(InventoryVars):
|
||||
"""Object classified as Ansible group vars."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class RoleVars(RoleFile):
|
||||
"""Object classified as Ansible role vars."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class Meta(RoleFile):
|
||||
"""Object classified as Ansible meta file."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class Inventory(Unversioned):
|
||||
"""Object classified as Ansible inventory file."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class Code(Unversioned):
|
||||
"""Object classified as code file."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class Template(RoleFile):
|
||||
"""Object classified as Ansible template file."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class Doc(Unversioned):
|
||||
"""Object classified as documentation file."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class Makefile(Unversioned):
|
||||
"""Object classified as makefile."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class File(RoleFile):
|
||||
"""Object classified as generic file."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class Rolesfile(Unversioned):
|
||||
"""Object classified as Ansible roles file."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
@ -310,6 +342,7 @@ class Error(object):
|
||||
|
||||
|
||||
class Result(object):
|
||||
"""Generic result object."""
|
||||
|
||||
def __init__(self, candidate, errors=None):
|
||||
self.candidate = candidate
|
||||
@ -335,8 +368,10 @@ def classify(filename, settings={}, standards=[]):
|
||||
return HostVars(filename, settings, standards)
|
||||
if parentdir in ["meta"]:
|
||||
return Meta(filename, settings, standards)
|
||||
if parentdir in ["library", "lookup_plugins", "callback_plugins", "filter_plugins"
|
||||
] or filename.endswith(".py"):
|
||||
if (
|
||||
parentdir in ["library", "lookup_plugins", "callback_plugins", "filter_plugins"]
|
||||
or filename.endswith(".py")
|
||||
):
|
||||
return Code(filename, settings, standards)
|
||||
if "inventory" == basename or "hosts" == basename or parentdir in ["inventories"]:
|
||||
return Inventory(filename, settings, standards)
|
||||
|
@ -33,8 +33,10 @@ def check_braces_spaces(candidate, settings):
|
||||
[leading, trailing] = count_spaces(line)
|
||||
sum_spaces = leading + trailing
|
||||
|
||||
if ((sum_spaces < conf["min-spaces-inside"] * 2)
|
||||
or (sum_spaces > conf["min-spaces-inside"] * 2)):
|
||||
if (
|
||||
sum_spaces < conf["min-spaces-inside"] * 2
|
||||
or sum_spaces > conf["min-spaces-inside"] * 2
|
||||
):
|
||||
errors.append(Error(i, description))
|
||||
return Result(candidate.path, errors)
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
import codecs
|
||||
import glob
|
||||
import imp
|
||||
import inspect
|
||||
import os
|
||||
|
||||
import ansible.parsing.mod_args
|
||||
@ -453,11 +452,9 @@ def action_tasks(yaml, file):
|
||||
block_rescue_always = ("block", "rescue", "always")
|
||||
tasks[:] = [task for task in tasks if all(k not in task for k in block_rescue_always)]
|
||||
|
||||
return [
|
||||
task for task in tasks
|
||||
if set(["include", "include_tasks", "import_playbook", "import_tasks"]
|
||||
).isdisjoint(task.keys())
|
||||
]
|
||||
allowed = ["include", "include_tasks", "import_playbook", "import_tasks"]
|
||||
|
||||
return [task for task in tasks if set(allowed).isdisjoint(task.keys())]
|
||||
|
||||
|
||||
def task_to_str(task):
|
||||
|
Loading…
Reference in New Issue
Block a user