Skip to content
Snippets Groups Projects
Commit 295379b6 authored by Jan Maximilian Michal's avatar Jan Maximilian Michal
Browse files

Merge branch 'pre-commit' into 'refactor'

Pre commit

See merge request !14
parents aade6c6e 7147fbe8
No related branches found
No related tags found
2 merge requests!15Refactor,!14Pre commit
Pipeline #
This commit is part of merge request !15. Comments created here will be created in the context of that merge request.
repos:
- repo: local
hooks:
- id: prospector
name: prospector
entry: ./pre-commit-scripts/prospector.sh
language: script
types: [python]
[MASTER]
# Add files or directories to the blacklist. They should be base names, not
# paths.
ignore=CVS, migrations, static, env, docs, manage.py
# 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.
jobs=4
# Pickle collected data for later comparisons.
persistent=yes
# 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
# List of plugins (as comma separated values of python modules names) to load,
# usually to register additional checkers.
load-plugins=pylint_django
[MESSAGES CONTROL]
# 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=print-statement,
parameter-unpacking,
unpacking-in-except,
old-raise-syntax,
backtick,
long-suffix,
old-ne-operator,
old-octal-literal,
import-star-module-level,
non-ascii-bytes-literal,
raw-checker-failed,
bad-inline-option,
locally-disabled,
locally-enabled,
file-ignored,
suppressed-message,
useless-suppression,
deprecated-pragma,
apply-builtin,
basestring-builtin,
buffer-builtin,
cmp-builtin,
coerce-builtin,
execfile-builtin,
file-builtin,
long-builtin,
raw_input-builtin,
reduce-builtin,
standarderror-builtin,
unicode-builtin,
xrange-builtin,
coerce-method,
delslice-method,
getslice-method,
setslice-method,
no-absolute-import,
old-division,
dict-iter-method,
dict-view-method,
next-method-called,
metaclass-assignment,
indexing-exception,
raising-string,
reload-builtin,
oct-method,
hex-method,
nonzero-method,
cmp-method,
input-builtin,
round-builtin,
intern-builtin,
unichr-builtin,
map-builtin-not-iterating,
zip-builtin-not-iterating,
range-builtin-not-iterating,
filter-builtin-not-iterating,
using-cmp-argument,
eq-without-hash,
div-method,
idiv-method,
rdiv-method,
exception-message-attribute,
invalid-str-codec,
sys-max-int,
bad-python3-import,
deprecated-string-function,
deprecated-str-translate-call,
deprecated-itertools-function,
deprecated-types-field,
next-method-defined,
dict-items-not-iterating,
dict-keys-not-iterating,
dict-values-not-iterating
[REPORTS]
# Tells whether to display a full report or only the messages
reports=yes
# Activate the evaluation score.
score=yes
[REFACTORING]
# Maximum number of nested blocks for function / method body
max-nested-blocks=5
[LOGGING]
# Logging modules to check that the string format arguments are in logging
# function parameter format
logging-modules=logging
[FORMAT]
# Maximum number of characters on a single line.
max-line-length=100
......@@ -9,6 +9,7 @@ from core.serializers import (FeedbackSerializer, StudentSerializer,
log = logging.getLogger(__name__)
class StudentApiView(RetrieveAPIView):
permission_classes = (IsStudent,)
......
......@@ -16,7 +16,6 @@ os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'grady.settings')
django.setup()
def parseme():
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest="command")
......@@ -84,7 +83,7 @@ def parseme():
return parser.parse_args()
def handle_passwordlist(output=sys.stdout, instance="", **kwargs):
def handle_passwordlist(output=sys.stdout, instance=""):
with open('/usr/share/dict/words') as words:
choose_from = list({word.strip().lower()
for word in words if 5 < len(word) < 8})
......@@ -102,7 +101,7 @@ def handle_passwordlist(output=sys.stdout, instance="", **kwargs):
student.user.username, password, instance])
def handle_enableusers(switch, exclude, include, **kwargs):
def handle_enableusers(switch, exclude, include):
if include:
for user in User.objects.filter(username__in=include):
......@@ -114,7 +113,7 @@ def handle_enableusers(switch, exclude, include, **kwargs):
user.save()
def handle_replaceusernames(matno2username_dict, **kwargs):
def handle_replaceusernames(matno2username_dict):
matno2username = json.JSONDecoder().decode(matno2username_dict.read())
for student in Student.objects.all():
if student.matrikel_no in matno2username:
......@@ -123,12 +122,12 @@ def handle_replaceusernames(matno2username_dict, **kwargs):
student.user.save()
def handle_extractsubmissions(output, **kwargs):
def handle_extractsubmissions():
for submission in Submission.objects.filter(feedback__isnull=False).order_by('type'):
print(submission.feedback.score, repr(submission.text), file=open(str(submission.type).replace(' ', '_'), 'a'))
def handle_importer(**kwargs):
def handle_importer():
util.importer.start()
def main():
......
......@@ -9,3 +9,4 @@ xlrd~=1.0.0
pytest-cov~=2.5.1
prospector~=0.12.7
django-cors-headers~=2.1.0
pre-commit~=1.4.1
\ No newline at end of file
#!/bin/bash
cd backend
unset GIT_DIR
diff_files="$(git diff --cached --name-only --relative --diff-filter=AM)"
if [ -n "$diff_files" ]; then
prospector --uses django $diff_files
else
exit 0
fi
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment