From 7147fbe8c0f4f8f6744515f3527af078d288a54d Mon Sep 17 00:00:00 2001
From: "robinwilliam.hundt" <robinwilliam.hundt@stud.uni-goettingen.de>
Date: Wed, 15 Nov 2017 14:01:15 +0100
Subject: [PATCH] Finally working prospector pre-commit check!!!!

To enable the pre-commit checks first run pip -Ur requierements.txt to install pre-commit. Next run pre-commit install to install the hook in your .git/hooks folder. Running pre-commit will now run prospector on all new or modified files in the backend/ directory (see pre-commit-scripts/prospector.sh for the arguments that are used). If you get an error saying prospector not found or smth. make sure you have the venvv activated or prospector installed globally.
---
 .pre-commit-config.yaml          |   6 +-
 backend/.pylintrc                | 143 -------------------------------
 pre-commit-scripts/prospector.sh |  11 +++
 prospector.sh                    |   4 -
 4 files changed, 14 insertions(+), 150 deletions(-)
 delete mode 100644 backend/.pylintrc
 create mode 100755 pre-commit-scripts/prospector.sh
 delete mode 100755 prospector.sh

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 8635fd94..b2f4c009 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -3,6 +3,6 @@ repos:
     hooks:
     -   id: prospector
         name: prospector
-        entry: ./prospector.sh
-        language: python
-        files: \.py$
+        entry: ./pre-commit-scripts/prospector.sh
+        language: script
+        types: [python]
diff --git a/backend/.pylintrc b/backend/.pylintrc
deleted file mode 100644
index dc0fdb2d..00000000
--- a/backend/.pylintrc
+++ /dev/null
@@ -1,143 +0,0 @@
-[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
diff --git a/pre-commit-scripts/prospector.sh b/pre-commit-scripts/prospector.sh
new file mode 100755
index 00000000..dd41b303
--- /dev/null
+++ b/pre-commit-scripts/prospector.sh
@@ -0,0 +1,11 @@
+#!/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
diff --git a/prospector.sh b/prospector.sh
deleted file mode 100755
index 4cf68263..00000000
--- a/prospector.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/bash
-
-cd backend
-prospector --uses django
\ No newline at end of file
-- 
GitLab