Skip to content

Commit

Permalink
Simplify running pylint
Browse files Browse the repository at this point in the history
This commit does several things:

- Setup and run pylint directly rather than running
  through a script. This allows the user to see what is happening
  while the user is running through pylint.
- Allow the user to either run pylint on a particular changeset,
  or the entire cinder tree.
- Allow the user to run on a particular changeset. Using like
  HEAD~1, etc.
- Since the pylint gate check I disabled the tests that were
  reported by pylint. The thought here would be go through
  the failures and correct them.
- Update pylint to 2.1.1.
- Removed old pylintrc.

Change-Id: I708c93843d991e8c0ac114b0b2d6ede373b96d0a
Signed-off-by: Chuck Short <[email protected]>
  • Loading branch information
Chuck Short committed Sep 6, 2018
1 parent ccb3ff9 commit adcfb4f
Show file tree
Hide file tree
Showing 6 changed files with 290 additions and 378 deletions.
231 changes: 231 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
[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=1

# 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,
misplaced-bare-raise,
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,
unnecessary-pass,
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,
unneeded-not,
singleton-comparison,
misplaced-comparison-constant,
unidiomatic-typecheck,
consider-using-enumerate,
bad-whitespace,
consider-iterating-dictionary,
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,
consider-merging-isinstance,
consider-merging-isinstance,
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)$


[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

41 changes: 0 additions & 41 deletions pylintrc

This file was deleted.

56 changes: 56 additions & 0 deletions tools/coding-checks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/sh

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 cinder 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="cinder"
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 `python -c 'import multiprocessing as mp; print(mp.cpu_count())'`
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
Loading

0 comments on commit adcfb4f

Please sign in to comment.