Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lint using Haskell style scanner (scan)
- Loading branch information
Showing
40 changed files
with
1,015 additions
and
813 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
function abspath { | ||
cd "$1" | ||
pwd | ||
} | ||
|
||
# Automatically install this script as a pre-commit hook | ||
if [[ -d .git/ && ! -f .git/hooks/pre-commit ]]; then | ||
mkdir -p .git/hooks/ | ||
cat <<EOF > .git/hooks/pre-commit | ||
#!/usr/bin/env bash | ||
set -e | ||
$(abspath "$(dirname "$0")")/lint.sh | ||
EOF | ||
chmod +x .git/hooks/pre-commit | ||
fi | ||
|
||
if [[ "$(which stack)" != "" ]] && stack --help | head -n1 | grep -qi haskell | ||
then | ||
stack test hlint | ||
if [[ "$(stack exec scan -- -v)" = "" ]]; then | ||
stack install scan | ||
fi | ||
scan=(stack exec scan --) | ||
else | ||
cabal test hlint | ||
cabal install scan | ||
scan=(scan) | ||
fi | ||
|
||
# Haskell style scanner doesn't provide proper exit code --- | ||
# it always exists with zero even if it found errors. | ||
scanout="$(mktemp)" | ||
find src test -name '*.hs' -print0 | \ | ||
xargs -0 "${scan[@]}" -j false -c false > "$scanout" | ||
cat "$scanout" | ||
if [[ "$(cat "$scanout")" != "" ]]; then | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.