linters: Add modernise tool check and fix issues (#2012)

* linters: Add modernise tool check and fix issues

* engine: Simplify exch.SetDefaults call and remove localWG

* CI: Revert config versions lint workflow
This commit is contained in:
Adrian Gallagher
2025-08-26 12:45:13 +10:00
committed by GitHub
parent 85403fe801
commit d5b2cf1759
22 changed files with 103 additions and 159 deletions

View File

@@ -13,4 +13,4 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}
- name: Check config versions are continuous
run: go test ./config/versions/ -tags config_versions -run Continuity
run: go test ./config/versions/ -tags config_versions -run Continuity

View File

@@ -1,24 +0,0 @@
name: configs-json-lint
on: [push, pull_request]
jobs:
lint:
name: configs JSON lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Check configs JSON format
run: |
files=("config_example.json" "testdata/configtest.json")
for file in "${files[@]}"; do
processed_file="${file%.*}_processed.${file##*.}"
jq '.exchanges |= sort_by(.name)' --indent 1 $file > $processed_file
if ! diff $file $processed_file; then
echo "jq differences found in $file! Please run 'make lint_configs'"
exit 1
else
rm $processed_file
echo "No differences found in $file 🌞"
fi
done

View File

@@ -6,6 +6,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.25.x
- name: Check for currency.NewPair(BTC, USD) used instead of currency.NewBTCUSD
run: |
grep -r -n --color=always -E "currency.NewPair\(currency.BTC, currency.USDT?\)" * || exit 0
@@ -62,4 +67,24 @@ jobs:
grep -r -n -I --color=always --exclude-dir=.git -P "$PATTERN" . || exit 0
echo "::error::Remove zero-width/format, separator or combining-mark characters"
exit 1
- name: Check configs JSON format
run: |
files=("config_example.json" "testdata/configtest.json")
for file in "${files[@]}"; do
processed_file="${file%.*}_processed.${file##*.}"
jq '.exchanges |= sort_by(.name)' --indent 1 $file > $processed_file
if ! diff $file $processed_file; then
echo "jq differences found in $file! Please run 'make lint_configs'"
exit 1
else
rm $processed_file
echo "No differences found in $file 🌞"
fi
done
- name: Check Go modernise tool issues
run: |
go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -test ./...