mirror of
https://github.com/ben-grande/qusal.git
synced 2025-07-26 07:55:31 -04:00
feat: lint python files
This commit is contained in:
parent
80482bfec7
commit
d457302fc3
5 changed files with 75 additions and 33 deletions
|
@ -14,8 +14,8 @@ repos:
|
||||||
pass_filenames: true
|
pass_filenames: true
|
||||||
description: Prohibit Unicode
|
description: Prohibit Unicode
|
||||||
|
|
||||||
- id: reuse
|
- id: reuse-lint
|
||||||
name: reuse
|
name: reuse-lint
|
||||||
entry: reuse
|
entry: reuse
|
||||||
args: [lint]
|
args: [lint]
|
||||||
language: python
|
language: python
|
||||||
|
@ -29,6 +29,13 @@ repos:
|
||||||
pass_filenames: true
|
pass_filenames: true
|
||||||
description: Lint markdown files
|
description: Lint markdown files
|
||||||
|
|
||||||
|
- id: python-lint
|
||||||
|
name: python-lint
|
||||||
|
entry: scripts/python-lint.sh
|
||||||
|
language: script
|
||||||
|
pass_filenames: true
|
||||||
|
description: Lint python files
|
||||||
|
|
||||||
- id: salt-lint
|
- id: salt-lint
|
||||||
name: salt-lint
|
name: salt-lint
|
||||||
entry: scripts/salt-lint.sh
|
entry: scripts/salt-lint.sh
|
||||||
|
@ -36,22 +43,13 @@ repos:
|
||||||
pass_filenames: true
|
pass_filenames: true
|
||||||
description: Lint Salt files
|
description: Lint Salt files
|
||||||
|
|
||||||
- id: shellcheck
|
- id: shell-lint
|
||||||
name: shellcheck
|
name: shell-lint
|
||||||
entry: scripts/shell-lint.sh
|
entry: scripts/shell-lint.sh
|
||||||
language: script
|
language: script
|
||||||
pass_filenames: true
|
pass_filenames: true
|
||||||
description: Lint Shellscripts
|
description: Lint Shellscripts
|
||||||
|
|
||||||
- id: gitlint
|
|
||||||
name: gitlint
|
|
||||||
language: python
|
|
||||||
entry: gitlint
|
|
||||||
args: [--staged, --msg-filename]
|
|
||||||
stages: [commit-msg]
|
|
||||||
pass_filenames: true
|
|
||||||
description: Lint Git commits
|
|
||||||
|
|
||||||
- id: qubesbuilder-gen
|
- id: qubesbuilder-gen
|
||||||
name: qubesbuilder-gen
|
name: qubesbuilder-gen
|
||||||
entry: scripts/qubesbuilder-gen.sh
|
entry: scripts/qubesbuilder-gen.sh
|
||||||
|
@ -68,3 +66,12 @@ repos:
|
||||||
# args: [test]
|
# args: [test]
|
||||||
# # pass_filenames: true
|
# # pass_filenames: true
|
||||||
# description: Check if RPM SPEC files are up to date
|
# description: Check if RPM SPEC files are up to date
|
||||||
|
|
||||||
|
- id: git-lint
|
||||||
|
name: git-lint
|
||||||
|
language: python
|
||||||
|
entry: gitlint
|
||||||
|
args: [--staged, --msg-filename]
|
||||||
|
stages: [commit-msg]
|
||||||
|
pass_filenames: true
|
||||||
|
description: Lint Git commits
|
||||||
|
|
|
@ -61,10 +61,11 @@ For writing:
|
||||||
|
|
||||||
For linting:
|
For linting:
|
||||||
|
|
||||||
* gitlint
|
|
||||||
* markdownlint (ruby-mdl)
|
|
||||||
* pre-commit
|
* pre-commit
|
||||||
|
* gitlint
|
||||||
|
* pylint
|
||||||
* reuse
|
* reuse
|
||||||
|
* ruby-mdl (markdownlint)
|
||||||
* salt-lint
|
* salt-lint
|
||||||
* shellcheck
|
* shellcheck
|
||||||
|
|
||||||
|
|
|
@ -6,15 +6,11 @@
|
||||||
|
|
||||||
"""list-extra-tag - List qubes tagged for cacher incorrectly"""
|
"""list-extra-tag - List qubes tagged for cacher incorrectly"""
|
||||||
|
|
||||||
import qubesadmin
|
import qubesadmin # pylint: disable=import-error
|
||||||
import qubesadmin.vm
|
import qubesadmin.vm # pylint: disable=import-error
|
||||||
|
|
||||||
def main():
|
def main(): # pylint: disable=missing-function-docstring
|
||||||
"""main"""
|
wanted_domains = ['debian', 'fedora', 'arch', 'ubuntu', 'kicksecure']
|
||||||
wanted_domains = ['debian', 'fedora', 'arch']
|
|
||||||
## TODO: remove after https://github.com/QubesOS/qubes-core-agent-linux/pull/504
|
|
||||||
wanted_domains_extra = wanted_domains + ['kali', 'kicksecure', 'parrot',
|
|
||||||
'ubuntu', 'linuxmint', 'blackarch']
|
|
||||||
domains = [
|
domains = [
|
||||||
vm.name
|
vm.name
|
||||||
for vm in qubesadmin.Qubes().domains
|
for vm in qubesadmin.Qubes().domains
|
||||||
|
@ -22,7 +18,7 @@ def main():
|
||||||
and vm.features.check_with_template("os-distribution-like")
|
and vm.features.check_with_template("os-distribution-like")
|
||||||
not in wanted_domains
|
not in wanted_domains
|
||||||
and vm.features.check_with_template("os-distribution")
|
and vm.features.check_with_template("os-distribution")
|
||||||
not in wanted_domains_extra
|
not in wanted_domains
|
||||||
]
|
]
|
||||||
print("\n".join(domains))
|
print("\n".join(domains))
|
||||||
|
|
||||||
|
|
|
@ -6,22 +6,18 @@
|
||||||
|
|
||||||
"""list-extra-tag - List qubes that can be tagged for cacher"""
|
"""list-extra-tag - List qubes that can be tagged for cacher"""
|
||||||
|
|
||||||
import qubesadmin
|
import qubesadmin # pylint: disable=import-error
|
||||||
import qubesadmin.vm
|
import qubesadmin.vm # pylint: disable=import-error
|
||||||
|
|
||||||
def main():
|
def main(): # pylint: disable=missing-function-docstring
|
||||||
"""main"""
|
wanted_domains = ['debian', 'fedora', 'arch', 'ubuntu', 'kicksecure']
|
||||||
wanted_domains = ['debian', 'fedora', 'arch']
|
|
||||||
## TODO: remove after https://github.com/QubesOS/qubes-core-agent-linux/pull/504
|
|
||||||
wanted_domains_extra = wanted_domains + ['kali', 'kicksecure', 'parrot',
|
|
||||||
'ubuntu', 'linuxmint', 'blackarch']
|
|
||||||
domains = [
|
domains = [
|
||||||
vm.name
|
vm.name
|
||||||
for vm in qubesadmin.Qubes().domains
|
for vm in qubesadmin.Qubes().domains
|
||||||
if vm.klass == "TemplateVM"
|
if vm.klass == "TemplateVM"
|
||||||
and "whonix-updatevm" not in vm.tags
|
and "whonix-updatevm" not in vm.tags
|
||||||
and (vm.features.get("os-distribution-like") in wanted_domains
|
and (vm.features.get("os-distribution-like") in wanted_domains
|
||||||
or vm.features.get("os-distribution") in wanted_domains_extra)
|
or vm.features.get("os-distribution") in wanted_domains)
|
||||||
]
|
]
|
||||||
print("\n".join(domains))
|
print("\n".join(domains))
|
||||||
|
|
||||||
|
|
42
scripts/python-lint.sh
Executable file
42
scripts/python-lint.sh
Executable file
|
@ -0,0 +1,42 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
## SPDX-FileCopyrightText: 2024 Benjamin Grande M. S. <ben.grande.b@gmail.com>
|
||||||
|
##
|
||||||
|
## SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
command -v git >/dev/null ||
|
||||||
|
{ printf "Missing program: git\n" >&2; exit 1; }
|
||||||
|
cd "$(git rev-parse --show-toplevel)" || exit 1
|
||||||
|
./scripts/requires-program.sh pylint
|
||||||
|
|
||||||
|
find_tool="find"
|
||||||
|
if command -v fd; then
|
||||||
|
find_tool="fd"
|
||||||
|
elif command -v fdfind >/dev/null; then
|
||||||
|
find_tool="fdfind"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -n "${1-}"; then
|
||||||
|
files=""
|
||||||
|
for f in "$@"; do
|
||||||
|
test -f "$f" || continue
|
||||||
|
extension="${f##*.}"
|
||||||
|
case "$extension" in
|
||||||
|
py) files="$files $f";;
|
||||||
|
*) continue
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
test -n "$files" || exit 0
|
||||||
|
exec pylint ${files}
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "${find_tool}" in
|
||||||
|
fd|fdfind) files="$(${find_tool} . -H -t f -e py)";;
|
||||||
|
find) files="$(find . -type f -name "*.py")";;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exec pylint ${files}
|
Loading…
Add table
Add a link
Reference in a new issue