Merge "import pylint tooling from cinder"
This commit is contained in:
commit
7e9f8a666f
|
@ -0,0 +1,234 @@
|
||||||
|
[MASTER]
|
||||||
|
|
||||||
|
# A comma-separated list of package or module names from where C extensions may
|
||||||
|
# be loaded. Extensions are loading into the active Python interpreter and may
|
||||||
|
# run arbitrary code.
|
||||||
|
extension-pkg-whitelist=
|
||||||
|
|
||||||
|
# Add files or directories to the blacklist. They should be base names, not
|
||||||
|
# paths.
|
||||||
|
ignore=CVS,tests,test
|
||||||
|
|
||||||
|
# Add files or directories matching the regex patterns to the blacklist. The
|
||||||
|
# regex matches against base names, not paths.
|
||||||
|
ignore-patterns=
|
||||||
|
|
||||||
|
# Python code to execute, usually for sys.path manipulation such as
|
||||||
|
# pygtk.require().
|
||||||
|
#init-hook=
|
||||||
|
|
||||||
|
# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
|
||||||
|
# number of processors available to use.
|
||||||
|
jobs=0
|
||||||
|
|
||||||
|
# Control the amount of potential inferred values when inferring a single
|
||||||
|
# object. This can help the performance when dealing with large functions or
|
||||||
|
# complex, nested conditions.
|
||||||
|
limit-inference-results=100
|
||||||
|
|
||||||
|
# List of plugins (as comma separated values of python modules names) to load,
|
||||||
|
# usually to register additional checkers.
|
||||||
|
load-plugins=
|
||||||
|
|
||||||
|
# Pickle collected data for later comparisons.
|
||||||
|
persistent=yes
|
||||||
|
|
||||||
|
# Specify a configuration file.
|
||||||
|
#rcfile=
|
||||||
|
|
||||||
|
# When enabled, pylint would attempt to guess common misconfiguration and emit
|
||||||
|
# user-friendly hints instead of false-positive error messages.
|
||||||
|
suggestion-mode=yes
|
||||||
|
|
||||||
|
# Allow loading of arbitrary C extensions. Extensions are imported into the
|
||||||
|
# active Python interpreter and may run arbitrary code.
|
||||||
|
unsafe-load-any-extension=no
|
||||||
|
|
||||||
|
|
||||||
|
[MESSAGES CONTROL]
|
||||||
|
|
||||||
|
# Only show warnings with the listed confidence levels. Leave empty to show
|
||||||
|
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED.
|
||||||
|
confidence=
|
||||||
|
|
||||||
|
# Disable the message, report, category or checker with the given id(s). You
|
||||||
|
# can either give multiple identifiers separated by comma (,) or put this
|
||||||
|
# option multiple times (only on the command line, not in the configuration
|
||||||
|
# file where it should appear only once). You can also use "--disable=all" to
|
||||||
|
# disable everything first and then reenable specific checks. For example, if
|
||||||
|
# you want to run only the similarities checker, you can use "--disable=all
|
||||||
|
# --enable=similarities". If you want to run only the classes checker, but have
|
||||||
|
# no Warning level messages displayed, use "--disable=all --enable=classes
|
||||||
|
# --disable=W".
|
||||||
|
disable=
|
||||||
|
# "F" Fatal errors that prevent further processing
|
||||||
|
import-error,
|
||||||
|
# "I" Informational noise
|
||||||
|
locally-disabled,
|
||||||
|
c-extension-no-member,
|
||||||
|
# "E" Error for important programming issues (likely bugs)
|
||||||
|
access-member-before-definition,
|
||||||
|
bad-super-call,
|
||||||
|
no-member,
|
||||||
|
no-method-argument,
|
||||||
|
no-name-in-module,
|
||||||
|
no-self-argument,
|
||||||
|
no-value-for-parameter,
|
||||||
|
unsubscriptable-object,
|
||||||
|
method-hidden,
|
||||||
|
not-callable,
|
||||||
|
keyword-arg-before-vararg,
|
||||||
|
too-many-function-args,
|
||||||
|
unsupported-assignment-operation,
|
||||||
|
not-an-iterable,
|
||||||
|
unsupported-membership-test,
|
||||||
|
unsupported-assignment-operation,
|
||||||
|
raising-bad-type,
|
||||||
|
bad-option-value,
|
||||||
|
unexpected-keyword-arg,
|
||||||
|
assignment-from-none,
|
||||||
|
assignment-from-no-return,
|
||||||
|
# "W" Warnings for stylistic problems or minor programming issues
|
||||||
|
exec-used,
|
||||||
|
pointless-statement,
|
||||||
|
unnecessary-lambda,
|
||||||
|
abstract-method,
|
||||||
|
arguments-differ,
|
||||||
|
attribute-defined-outside-init,
|
||||||
|
bad-builtin,
|
||||||
|
bad-indentation,
|
||||||
|
broad-except,
|
||||||
|
deprecated-lambda,
|
||||||
|
expression-not-assigned,
|
||||||
|
fixme,
|
||||||
|
global-statement,
|
||||||
|
global-variable-not-assigned,
|
||||||
|
no-init,
|
||||||
|
non-parent-init-called,
|
||||||
|
protected-access,
|
||||||
|
redefined-builtin,
|
||||||
|
redefined-outer-name,
|
||||||
|
reimported,
|
||||||
|
signature-differs,
|
||||||
|
star-args,
|
||||||
|
super-init-not-called,
|
||||||
|
unpacking-non-sequence,
|
||||||
|
unused-argument,
|
||||||
|
unused-import,
|
||||||
|
undefined-loop-variable,
|
||||||
|
bad-staticmethod-argument,
|
||||||
|
deprecated-method,
|
||||||
|
useless-else-on-loop,
|
||||||
|
lost-exception,
|
||||||
|
pointless-string-statement,
|
||||||
|
useless-super-delegation,
|
||||||
|
deprecated-method,
|
||||||
|
dangerous-default-value,
|
||||||
|
wildcard-import,
|
||||||
|
bad-staticmethod-argument,
|
||||||
|
eval-used,
|
||||||
|
blacklisted-name,
|
||||||
|
pointless-statement,
|
||||||
|
try-except-raise,
|
||||||
|
# "C" Coding convention violations
|
||||||
|
bad-continuation,
|
||||||
|
invalid-name,
|
||||||
|
missing-docstring,
|
||||||
|
old-style-class,
|
||||||
|
superfluous-parens,
|
||||||
|
wrong-import-position,
|
||||||
|
wrong-import-order,
|
||||||
|
ungrouped-imports,
|
||||||
|
unused-variable,
|
||||||
|
len-as-condition,
|
||||||
|
cell-var-from-loop,
|
||||||
|
singleton-comparison,
|
||||||
|
misplaced-comparison-constant,
|
||||||
|
unidiomatic-typecheck,
|
||||||
|
consider-using-enumerate,
|
||||||
|
bad-whitespace,
|
||||||
|
line-too-long,
|
||||||
|
useless-super-delegation,
|
||||||
|
pointless-string-statement,
|
||||||
|
unsupported-membership-test,
|
||||||
|
bad-classmethod-argument,
|
||||||
|
bad-mcs-classmethod-argument,
|
||||||
|
# "R" Refactor recommendations
|
||||||
|
abstract-class-little-used,
|
||||||
|
abstract-class-not-used,
|
||||||
|
duplicate-code,
|
||||||
|
interface-not-implemented,
|
||||||
|
no-self-use,
|
||||||
|
too-few-public-methods,
|
||||||
|
too-many-ancestors,
|
||||||
|
too-many-arguments,
|
||||||
|
too-many-branches,
|
||||||
|
too-many-instance-attributes,
|
||||||
|
too-many-lines,
|
||||||
|
too-many-locals,
|
||||||
|
too-many-public-methods,
|
||||||
|
too-many-return-statements,
|
||||||
|
too-many-statements,
|
||||||
|
too-many-nested-blocks,
|
||||||
|
no-else-return,
|
||||||
|
inconsistent-return-statements,
|
||||||
|
simplifiable-if-statement,
|
||||||
|
too-many-boolean-expressions,
|
||||||
|
cyclic-import,
|
||||||
|
redefined-argument-from-local,
|
||||||
|
consider-using-ternary,
|
||||||
|
literal-comparison,
|
||||||
|
too-many-boolean-expressions,
|
||||||
|
useless-object-inheritance,
|
||||||
|
trailing-comma-tuple,
|
||||||
|
useless-object-inheritance,
|
||||||
|
consider-using-set-comprehension,
|
||||||
|
consider-using-in,
|
||||||
|
useless-return,
|
||||||
|
chained-comparison
|
||||||
|
|
||||||
|
[REPORTS]
|
||||||
|
# Tells whether to display a full report or only the messages.
|
||||||
|
reports=no
|
||||||
|
|
||||||
|
[BASIC]
|
||||||
|
# Variable names can be 1 to 31 characters long, with lowercase and underscores
|
||||||
|
variable-rgx=[a-z_][a-z0-9_]{0,30}$
|
||||||
|
|
||||||
|
# Argument names can be 2 to 31 characters long, with lowercase and underscores
|
||||||
|
argument-rgx=[a-z_][a-z0-9_]{1,30}$
|
||||||
|
|
||||||
|
# Method names should be at least 3 characters long
|
||||||
|
# and be lowercased with underscores
|
||||||
|
method-rgx=([a-z_][a-z0-9_]{2,}|setUp|tearDown)$
|
||||||
|
|
||||||
|
# Module names matching neutron-* are ok (files in bin/)
|
||||||
|
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+)|(neutron-[a-z0-9_-]+))$
|
||||||
|
|
||||||
|
# Don't require docstrings on tests.
|
||||||
|
no-docstring-rgx=((__.*__)|([tT]est.*)|setUp|tearDown)$
|
||||||
|
|
||||||
|
mixin-class-rgx=(^(ManageResource)$|.*[Mm]ixin)
|
||||||
|
|
||||||
|
|
||||||
|
[FORMAT]
|
||||||
|
# Maximum number of characters on a single line.
|
||||||
|
max-line-length=79
|
||||||
|
|
||||||
|
|
||||||
|
[VARIABLES]
|
||||||
|
# List of additional names supposed to be defined in builtins. Remember that
|
||||||
|
# you should avoid to define new builtins when possible.
|
||||||
|
additional-builtins=_
|
||||||
|
|
||||||
|
[TYPECHECK]
|
||||||
|
# List of module names for which member attributes should not be checked
|
||||||
|
ignored-modules=six.moves,_MovedItems,alembic.context,alembic.op,
|
||||||
|
alembic.config,pyxcli,storpool,oslo_privsep.capabilities
|
||||||
|
signature-mutators=unittest.mock.patch,unittest.mock.patch.object,sqlalchemy.util._preloaded.dependencies
|
||||||
|
|
||||||
|
# This is for cinder.objects.*, and requests.packages.*, but due to
|
||||||
|
# https://github.com/PyCQA/pylint/issues/2498
|
||||||
|
# it doesn't seem that generated-members can be specified correctly.
|
||||||
|
# Clean this up later when pylint works correctly.
|
||||||
|
generated-members=objects,requests
|
|
@ -0,0 +1,55 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $0 [OPTION]..."
|
||||||
|
echo "Run Cinder's coding check(s)"
|
||||||
|
echo ""
|
||||||
|
echo " -Y, --pylint [<basecommit>] Run pylint check on the entire os-brick module or just files changed in basecommit (e.g. HEAD~1)"
|
||||||
|
echo " -h, --help Print this usage message"
|
||||||
|
echo
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
process_options() {
|
||||||
|
i=1
|
||||||
|
while [ $i -le $# ]; do
|
||||||
|
eval opt=\$$i
|
||||||
|
case $opt in
|
||||||
|
-h|--help) usage;;
|
||||||
|
-Y|--pylint) pylint=1;;
|
||||||
|
*) scriptargs="$scriptargs $opt"
|
||||||
|
esac
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
run_pylint() {
|
||||||
|
local target="${scriptargs:-HEAD~1}"
|
||||||
|
|
||||||
|
if [[ "$target" = *"all"* ]]; then
|
||||||
|
files="os_brick"
|
||||||
|
else
|
||||||
|
files=$(git diff --name-only --diff-filter=ACMRU $target -- "*.py")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${files}" ]; then
|
||||||
|
echo "Running pylint against:"
|
||||||
|
printf "\t%s\n" "${files[@]}"
|
||||||
|
pylint --rcfile=.pylintrc --output-format=colorized ${files} -E -j 0
|
||||||
|
else
|
||||||
|
echo "No python changes in this commit, pylint check not required."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptargs=
|
||||||
|
pylint=1
|
||||||
|
|
||||||
|
process_options $@
|
||||||
|
|
||||||
|
if [ $pylint -eq 1 ]; then
|
||||||
|
run_pylint
|
||||||
|
exit 0
|
||||||
|
fi
|
7
tox.ini
7
tox.ini
|
@ -64,11 +64,14 @@ deps = -r{toxinidir}/test-requirements.txt
|
||||||
commands: bandit -r os_brick -x os_brick/tests -n5 -sB101
|
commands: bandit -r os_brick -x os_brick/tests -n5 -sB101
|
||||||
|
|
||||||
[testenv:pylint]
|
[testenv:pylint]
|
||||||
|
allowlist_externals =
|
||||||
|
{toxinidir}/tools/coding-checks.sh
|
||||||
deps =
|
deps =
|
||||||
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master}
|
||||||
-r{toxinidir}/requirements.txt
|
-r{toxinidir}/requirements.txt
|
||||||
pylint==0.26.0
|
pylint==2.17.3
|
||||||
commands = bash tools/lintstack.sh
|
commands =
|
||||||
|
{toxinidir}/tools/coding-checks.sh --pylint {posargs:all}
|
||||||
|
|
||||||
[testenv:venv]
|
[testenv:venv]
|
||||||
commands = {posargs}
|
commands = {posargs}
|
||||||
|
|
Loading…
Reference in New Issue