Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ lint-all: formatc hlint-check-all check-local-nix-derivations treefmt
hlint-check-all:
./tools/hlint.sh -f all -m check

.PHONY: hlint-inplace-all
hlint-inplace-all:
./tools/hlint.sh -f all -m inplace

.PHONY: hlint-check-pr
hlint-check-pr:
./tools/hlint.sh -f pr -m check
Expand All @@ -122,11 +126,6 @@ hlint-check-pr:
hlint-inplace-pr:
./tools/hlint.sh -f pr -m inplace


.PHONY: hlint-inplace-all
hlint-inplace-all:
./tools/hlint.sh -f all -m inplace

.PHONY: hlint-check
hlint-check:
./tools/hlint.sh -f changeset -m check
Expand Down
1 change: 1 addition & 0 deletions nix/wire-server.nix
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ let
pkgs.helm
pkgs.helmfile
pkgs.hlint
( hlib.justStaticExecutables pkgs.haskellPackages.apply-refact )
pkgs.jq
pkgs.kubectl
pkgs.nixpkgs-fmt
Expand Down
15 changes: 7 additions & 8 deletions tools/hlint.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#!/usr/bin/env bash


usage() { echo "Usage: $0 -f [all, changeset] -m [check, inplace]" 1>&2; exit 1; }
usage() { echo "Usage: $0 -f [all, changeset, pr] -m [check, inplace]" 1>&2; exit 1; }

files=''
check=true

while getopts ':f:m:k' opt
do
case $opt in
f) f=${OPTARG}
if [ "$f" = "all" ]; then
echo "Checking every file…"
files=$(git ls-files | grep \.hs\$)
elif [ "$f" = "pr" ]; then
files=$(git diff --name-only origin/develop... | grep \.hs\$)
elif [ "$f" = "changeset" ]; then
Expand All @@ -22,9 +21,9 @@ while getopts ':f:m:k' opt
;;
m) m=${OPTARG}
if [ "$m" = "inplace" ]; then
check=false
:
elif [ "$m" = "check" ]; then
check=true
:
else
usage
fi
Expand All @@ -43,15 +42,15 @@ if [ "${k}" ]; then
set -euo pipefail
fi

if [ "$f" = "all" ]; then
hlint -g -v
if [ "$f" = "all" ] && [ "$m" = "check" ]; then
hlint -g
else
count=$(echo "$files" | grep -c -v -e '^[[:space:]]*$')
echo "Analysing $count file(s)…"
for f in $files
do
echo "$f"
if [ $check = true ]; then
if [ "$m" = "check" ]; then
hlint --no-summary "$f"
else
hlint --refactor --refactor-options="--inplace" "$f"
Expand Down