From 645f18881fe5880e6caa751cde5ecf523c7bab99 Mon Sep 17 00:00:00 2001 From: Tomasz Baran <110602076+tomasz-baran@users.noreply.github.com> Date: Fri, 6 Sep 2024 17:36:47 +0000 Subject: [PATCH] Fix linters --- .devcontainer/Dockerfile | 2 +- .pylintrc | 4 ++-- .vscode/tasks.json | 17 +++++++++-------- ci/pipelines/linters.yaml | 17 +++++++++-------- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index b859c6bd17..0477ca22a1 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -64,7 +64,7 @@ RUN : INSTALL PIP REQUIREMENTS \ && pip install --disable-pip-version-check --no-cache-dir --default-timeout=100 \ --requirement /requirements.txt \ && pip install --disable-pip-version-check --no-cache-dir --default-timeout=100 \ - poetry pylint==2.* pylint_junit ansible-lint==6.5.0 ansible-lint-to-junit-xml yamllint pytest pytest_mock setuptools twine wheel + poetry pylint==2.* pylint_junit ansible-lint==24.7.0 ansible-lint-junit==0.17.8 yamllint pytest pytest_mock setuptools twine wheel RUN : SETUP USER AND OTHERS \ && groupadd --gid $USER_GID $USERNAME \ diff --git a/.pylintrc b/.pylintrc index 984854faf0..e1074a80c6 100644 --- a/.pylintrc +++ b/.pylintrc @@ -349,8 +349,8 @@ int-import-graph= [EXCEPTIONS] # Exceptions that will emit a warning when being caught. Defaults to -# "Exception" -overgeneral-exceptions=Exception +# ["builtins.BaseException", "builtins.Exception"] +overgeneral-exceptions = ["builtins.BaseException", "builtins.Exception"] [TYPING] diff --git a/.vscode/tasks.json b/.vscode/tasks.json index b8c498865a..822209d2bf 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -6,7 +6,7 @@ "tasks": [ { "label": "Ensure test_results directory", - "command": "mkdir -p ${workspaceFolder}/test_results", + "command": "mkdir -p test_results", "presentation": { "echo": false, "reveal": "silent", @@ -15,28 +15,29 @@ }, { "label": "Pytest", - "command": "pytest --junitxml=${workspaceFolder}/test_results/pytest_results.xml", + "command": "pytest --junitxml=test_results/pytest_results.xml", "dependsOn": ["Ensure test_results directory"], "group": "test", }, { "label": "Pylint epicli [junit]", - "command": "pylint --rcfile .pylintrc ./cli ./tests --output ${workspaceFolder}/test_results/pylint_results.xml", + "command": "pylint --rcfile .pylintrc ./cli ./tests/unit --output test_results/pylint_results.xml --recursive y", "dependsOn": ["Ensure test_results directory"], "group": "test", }, { "label": "Pylint epicli [terminal]", - "command": "pylint --rcfile .pylintrc ./cli ./tests --output-format text", + "command": "pylint --rcfile .pylintrc ./cli ./tests/unit --output-format text --recursive y", "group": "test", }, { - "label": "Pylint repository modules", + "label": "Pylint repository role plugins", "command": "pylint", "args": [ "--rcfile", ".pylintrc", "--output-format", "text", - "./ansible/playbooks/roles/repository/library/tests", + "--recursive", "y", + "ansible/playbooks/roles/repository/library", ], "group": "test", }, @@ -54,13 +55,13 @@ }, { "label": "Ansible-lint [junit]", - "command": "ansible-lint --nocolor -q -c .ansible-lint -p ${workspaceFolder}/ansible > ${workspaceFolder}/test_results/ansiblelint_results.txt ; ansible-lint-to-junit-xml ${workspaceFolder}/test_results/ansiblelint_results.txt > ${workspaceFolder}/test_results/ansiblelint_results.xml", + "command": "ansible-lint --nocolor -q -c .ansible-lint -p ansible > test_results/ansible-lint_results.txt ; ansible-lint-junit test_results/ansible-lint_results.txt -o test_results/ansible-lint_results.xml", "dependsOn": ["Ensure test_results directory"], "group": "test", }, { "label": "Ansible-lint [terminal]", - "command": "ansible-lint -q -c .ansible-lint -p ${workspaceFolder}/ansible", + "command": "ansible-lint -q -c .ansible-lint -p ansible", "group": "test", }, { diff --git a/ci/pipelines/linters.yaml b/ci/pipelines/linters.yaml index fb2bc1d5ac..aa7368ec6a 100755 --- a/ci/pipelines/linters.yaml +++ b/ci/pipelines/linters.yaml @@ -13,10 +13,10 @@ pool: name: $(agentPoolName) variables: - ansible_lint_error_threshold: 338 - pylint_score_cli_threshold: 9.41 - pylint_score_tests_threshold: 9.78 - rubocop_linter_threshold: 183 + ansible_lint_error_threshold: 1009 + pylint_score_cli_threshold: 9.52 + pylint_score_tests_threshold: 9.85 + rubocop_linter_threshold: 169 jobs: - job: Run_linters @@ -30,11 +30,11 @@ jobs: - task: Bash@3 displayName: Install Ansible Lint and its dependencies - # Installing Ansible 5.2.0 to be compatible with the epicli image. + # Installing Ansible 9.9.0 to be compatible with the epicli image. inputs: targetType: inline script: | - python3 -m pip install --upgrade ansible==6.2.0 ansible-compat==3.* ansible-lint==6.5.0 ansible-lint-junit==0.16 lxml pip setuptools + python3 -m pip install --upgrade ansible==9.9.0 ansible-lint==24.7.0 ansible-lint-junit==0.17.8 lxml pip setuptools - task: Bash@3 displayName: Run Ansible Lint @@ -79,6 +79,7 @@ jobs: python3 -m pylint ./cli \ --rcfile .pylintrc \ --fail-under=$(pylint_score_cli_threshold) \ + --recursive y \ --output cli_code_results.xml - task: PublishTestResults@2 @@ -96,8 +97,8 @@ jobs: python3 -m pylint ./tests \ --rcfile .pylintrc \ --fail-under=$(pylint_score_tests_threshold) \ - --output test_code_results.xml \ - --disable=F0401 # Disable import-error checking + --recursive y \ + --output test_code_results.xml - task: PublishTestResults@2 displayName: Publish Pylint test results for test code