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