mirror of
https://github.com/ben-grande/qusal.git
synced 2024-10-01 02:35:49 -04:00
feat: lint python files
This commit is contained in:
parent
80482bfec7
commit
d457302fc3
@ -14,8 +14,8 @@ repos:
|
||||
pass_filenames: true
|
||||
description: Prohibit Unicode
|
||||
|
||||
- id: reuse
|
||||
name: reuse
|
||||
- id: reuse-lint
|
||||
name: reuse-lint
|
||||
entry: reuse
|
||||
args: [lint]
|
||||
language: python
|
||||
@ -29,6 +29,13 @@ repos:
|
||||
pass_filenames: true
|
||||
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
|
||||
name: salt-lint
|
||||
entry: scripts/salt-lint.sh
|
||||
@ -36,22 +43,13 @@ repos:
|
||||
pass_filenames: true
|
||||
description: Lint Salt files
|
||||
|
||||
- id: shellcheck
|
||||
name: shellcheck
|
||||
- id: shell-lint
|
||||
name: shell-lint
|
||||
entry: scripts/shell-lint.sh
|
||||
language: script
|
||||
pass_filenames: true
|
||||
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
|
||||
name: qubesbuilder-gen
|
||||
entry: scripts/qubesbuilder-gen.sh
|
||||
@ -68,3 +66,12 @@ repos:
|
||||
# args: [test]
|
||||
# # pass_filenames: true
|
||||
# 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:
|
||||
|
||||
* gitlint
|
||||
* markdownlint (ruby-mdl)
|
||||
* pre-commit
|
||||
* gitlint
|
||||
* pylint
|
||||
* reuse
|
||||
* ruby-mdl (markdownlint)
|
||||
* salt-lint
|
||||
* shellcheck
|
||||
|
||||
|
@ -6,15 +6,11 @@
|
||||
|
||||
"""list-extra-tag - List qubes tagged for cacher incorrectly"""
|
||||
|
||||
import qubesadmin
|
||||
import qubesadmin.vm
|
||||
import qubesadmin # pylint: disable=import-error
|
||||
import qubesadmin.vm # pylint: disable=import-error
|
||||
|
||||
def main():
|
||||
"""main"""
|
||||
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']
|
||||
def main(): # pylint: disable=missing-function-docstring
|
||||
wanted_domains = ['debian', 'fedora', 'arch', 'ubuntu', 'kicksecure']
|
||||
domains = [
|
||||
vm.name
|
||||
for vm in qubesadmin.Qubes().domains
|
||||
@ -22,7 +18,7 @@ def main():
|
||||
and vm.features.check_with_template("os-distribution-like")
|
||||
not in wanted_domains
|
||||
and vm.features.check_with_template("os-distribution")
|
||||
not in wanted_domains_extra
|
||||
not in wanted_domains
|
||||
]
|
||||
print("\n".join(domains))
|
||||
|
||||
|
@ -6,22 +6,18 @@
|
||||
|
||||
"""list-extra-tag - List qubes that can be tagged for cacher"""
|
||||
|
||||
import qubesadmin
|
||||
import qubesadmin.vm
|
||||
import qubesadmin # pylint: disable=import-error
|
||||
import qubesadmin.vm # pylint: disable=import-error
|
||||
|
||||
def main():
|
||||
"""main"""
|
||||
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']
|
||||
def main(): # pylint: disable=missing-function-docstring
|
||||
wanted_domains = ['debian', 'fedora', 'arch', 'ubuntu', 'kicksecure']
|
||||
domains = [
|
||||
vm.name
|
||||
for vm in qubesadmin.Qubes().domains
|
||||
if vm.klass == "TemplateVM"
|
||||
and "whonix-updatevm" not in vm.tags
|
||||
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))
|
||||
|
||||
|
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…
Reference in New Issue
Block a user