#!/bin/bash

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# Usage: docker/run_lint.sh [--fix]
#
# Runs linting and code fixing.
#
# This should be called from inside a container.

set -e

BLACKARGS=("--line-length=88" "--target-version=py36" docker socorro webapp-django scripts)

if [[ $1 == "--fix" ]]; then
    echo ">>> black fix"
    black "${BLACKARGS[@]}"

else
    echo ">>> flake8 ($(python --version))"
    cd /app
    flake8

    echo ">>> black"
    black --check "${BLACKARGS[@]}"

    echo ">>> eslint (js)"
    cd /app/webapp-django
    /webapp-frontend-deps/node_modules/.bin/eslint .
fi

#!/bin/bash

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# Usage: docker/run_lint.sh [--fix]
#
# Runs linting and code fixing.
#
# This should be called from inside a container.

set -e

BLACKARGS=("--line-length=88" "--target-version=py36" docker socorro webapp-django scripts)

if [[ $1 == "--fix" ]]; then
    echo ">>> black fix"
    black "${BLACKARGS[@]}"

else
    echo ">>> flake8 ($(python --version))"
    cd /app
    flake8

    echo ">>> black"
    black --check "${BLACKARGS[@]}"

    echo ">>> eslint (js)"
    cd /app/webapp-django
    /webapp-frontend-deps/node_modules/.bin/eslint .

    echo ">>> pip check"
    cd /app
    pip check --disable-pip-version-check
fi

Add pip check to linters
Add pip check to linters

pip check reports if there is a mismatch between requirements and the
installed packages. This is sometimes missed by auto-update tools.
