2017-10-10 05:02:39 -05:00
|
|
|
#! /bin/bash
|
|
|
|
|
|
|
|
# Runs the linters against dendrite
|
|
|
|
|
|
|
|
# The linters can take a lot of resources and are slow, so they can be
|
|
|
|
# configured using two environment variables:
|
|
|
|
#
|
|
|
|
# - `DENDRITE_LINT_CONCURRENCY` - number of concurrent linters to run,
|
|
|
|
# gometalinter defaults this to 8
|
|
|
|
# - `DENDRITE_LINT_DISABLE_GC` - if set then the the go gc will be disabled
|
|
|
|
# when running the linters, speeding them up but using much more memory.
|
|
|
|
|
|
|
|
|
2017-12-12 04:25:38 -06:00
|
|
|
set -eux
|
|
|
|
|
|
|
|
cd `dirname $0`/..
|
2017-10-10 05:02:39 -05:00
|
|
|
|
2019-05-21 15:56:55 -05:00
|
|
|
# gometalinter doesn't seem to work without this.
|
|
|
|
# We should move from gometalinter asap as per https://github.com/matrix-org/dendrite/issues/697 so this is a temporary
|
|
|
|
# fix.
|
|
|
|
export GO111MODULE=off
|
2017-10-10 05:02:39 -05:00
|
|
|
|
|
|
|
args=""
|
|
|
|
if [ ${1:-""} = "fast" ]
|
|
|
|
then args="--config=linter-fast.json"
|
|
|
|
else args="--config=linter.json"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "${DENDRITE_LINT_CONCURRENCY:-}" ]
|
|
|
|
then args="$args --concurrency=$DENDRITE_LINT_CONCURRENCY"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "${DENDRITE_LINT_DISABLE_GC:-}" ]
|
|
|
|
then args="$args --enable-gc"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Installing lint search engine..."
|
2019-05-21 15:56:55 -05:00
|
|
|
go get github.com/alecthomas/gometalinter/
|
|
|
|
|
2017-10-10 05:02:39 -05:00
|
|
|
gometalinter --config=linter.json ./... --install
|
|
|
|
|
|
|
|
echo "Looking for lint..."
|
|
|
|
gometalinter ./... $args
|
|
|
|
|
|
|
|
echo "Double checking spelling..."
|
|
|
|
misspell -error src *.md
|