From 3e555f91b8b54d2ccb9d2def30152fb47992c990 Mon Sep 17 00:00:00 2001 From: Santobert Date: Mon, 18 Jan 2021 19:30:18 +0100 Subject: [PATCH] Add more static code analysis (#69) * Add isort, flake8 and bandit * Add codespell * Sort files --- .github/workflows/main.yaml | 4 ++++ pybotvac/neato.py | 2 +- pybotvac/robot.py | 2 +- pybotvac/vorwerk.py | 2 +- requirements.txt | 6 +++++- setup.cfg | 19 +++++++++++++++++++ 6 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 setup.cfg diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 170512c..d775fc6 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -14,5 +14,9 @@ jobs: python-version: "3.8" architecture: "x64" - run: pip install -r requirements.txt + - run: codespell - run: black --check . + - run: isort --check --diff . - run: pylint pybotvac + - run: flake8 pybotvac + - run: bandit -r pybotvac diff --git a/pybotvac/neato.py b/pybotvac/neato.py index 616dcde..fdbf4d0 100644 --- a/pybotvac/neato.py +++ b/pybotvac/neato.py @@ -22,6 +22,6 @@ class Neato(Vendor): name = "neato" endpoint = "https://beehive.neatocloud.com/" auth_endpoint = "https://apps.neatorobotics.com/oauth2/authorize" - token_endpoint = "https://beehive.neatocloud.com/oauth2/token" + token_endpoint = "https://beehive.neatocloud.com/oauth2/token" # nosec scope = ["public_profile", "control_robots", "maps"] cert_path = os.path.join(os.path.dirname(__file__), "cert", "neatocloud.com.crt") diff --git a/pybotvac/robot.py b/pybotvac/robot.py index 01229ee..f79dc30 100644 --- a/pybotvac/robot.py +++ b/pybotvac/robot.py @@ -51,7 +51,7 @@ def __init__( # pylint: disable=anomalous-backslash-in-string self._url = "{endpoint}/vendors/{vendor_name}/robots/{serial}/messages".format( - endpoint=re.sub(":\d+", "", endpoint), # Remove port number + endpoint=re.sub(":\d+", "", endpoint), # noqa: W605, Remove port number vendor_name=vendor.name, serial=self.serial, ) diff --git a/pybotvac/vorwerk.py b/pybotvac/vorwerk.py index 228d01d..97f266d 100644 --- a/pybotvac/vorwerk.py +++ b/pybotvac/vorwerk.py @@ -5,7 +5,7 @@ class Vorwerk(Vendor): name = "vorwerk" endpoint = "https://beehive.ksecosys.com/" passwordless_endpoint = "https://mykobold.eu.auth0.com/passwordless/start" - token_endpoint = "https://mykobold.eu.auth0.com/oauth/token" + token_endpoint = "https://mykobold.eu.auth0.com/oauth/token" # nosec scope = ["openid", "email", "profile", "read:current_user", "offline_access"] audience = "https://mykobold.eu.auth0.com/userinfo" source = "vorwerk_auth0" diff --git a/requirements.txt b/requirements.txt index 4f6d736..102252d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,9 @@ urllib3 requests requests_oauthlib +bandit>=1 black -pylint +codespell>=2 +flake8>=3 +isort>=5 +pylint>=2.6 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..211a3a7 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,19 @@ +[codespell] +skip = ./.git,./.mypy_cache,./.vscode,./venv + +[flake8] +exclude = .vscode,venv +max-line-length = 88 +ignore = + F401, # Import error, pylint covers this + # Formatting errors that are covered by black + D202, + E203, + E501, + W503, + W504, + +[isort] +profile=black +multi_line_output = 3 +src_paths=pybotvac, sample