Skip to content

Commit 96f05ec

Browse files
authored
Enforce new line at the end of textual files (#5050)
### Changes - Add a script to check and add eol - Add eol where required - Add a CI step to enforce it ### Issues fix #5014
2 parents 35a7650 + e096b22 commit 96f05ec

File tree

17 files changed

+73
-15
lines changed

17 files changed

+73
-15
lines changed

.buildkite/pipeline.yml

+7
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,13 @@ steps:
291291
agents:
292292
system: ${linux}
293293

294+
- label: Check eol is present
295+
key: eol
296+
depends_on: []
297+
command: 'nix develop --command scripts/enforce-eol.sh'
298+
agents:
299+
system: ${linux}
300+
294301
- group: Linux Benchmarks
295302
key: linux-benchmarks
296303
depends_on: linux-nix

configs/cardano/refresh.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ set -euo pipefail
44

55
for dir in preprod mainnet preview private sanchonet; do
66
(cd "$dir" && ./download.sh)
7-
done
7+
done

configs/cardano/sanchonet/download.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ wget https://book.play.dev.cardano.org/environments-pre/sanchonet/topology.json
88
wget https://book.play.dev.cardano.org/environments-pre/sanchonet/byron-genesis.json
99
wget https://book.play.dev.cardano.org/environments-pre/sanchonet/shelley-genesis.json
1010
wget https://book.play.dev.cardano.org/environments-pre/sanchonet/alonzo-genesis.json
11-
wget https://book.play.dev.cardano.org/environments-pre/sanchonet/conway-genesis.json
11+
wget https://book.play.dev.cardano.org/environments-pre/sanchonet/conway-genesis.json

docs/site/src/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ This project provides an HTTP Application Programming Interface (API) and comman
77
It can be used as a component of a frontend such as [Daedalus][], which provides a friendly user interface for wallets. Most users who would like to use Cardano should start with Daedalus.
88

99
[Cardano]: https://www.cardano.org/
10-
[Daedalus]: https://daedaluswallet.io/
10+
[Daedalus]: https://daedaluswallet.io/

docs/site/src/user/common-use-cases/delegation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,4 @@ I can now **sign** and **submit** such a transaction just like in
148148

149149
```admonish note
150150
All rewards will be withdrawn only if you add {"withdrawal":"self"} to the payload. You can achieve this with a single transaction, as shown above.
151-
```
151+
```

docs/site/src/user/security.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ In order to ensure that only trusted users may access the HTTP service, cardano-
66

77
It’s worth mentioning that a trusted user can attack the wallet through the HTTP service in many ways, they can also view sensitive information, delete a wallet’s store, etc. Thus, as soon as an attacker is able to become a trusted user.
88

9-
It’s also worth mentioning that a trusted user that can access the HTTP API is not able to spend funds of the wallet without gaining access to additional information such as the passphrase or the wallet secret key. TLS prevents eavesdropping on the passphrase, and the wallet secret key is encrypted by the passphrase.
9+
It’s also worth mentioning that a trusted user that can access the HTTP API is not able to spend funds of the wallet without gaining access to additional information such as the passphrase or the wallet secret key. TLS prevents eavesdropping on the passphrase, and the wallet secret key is encrypted by the passphrase.

lib/delta-types/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ In general, there may be multiple delta types associated with a single base type
4545

4646
[bobkonf2023]: https://bobkonf.de/2023/apfelmus.html
4747
[2002.05256]: https://arxiv.org/abs/2002.05256
48-
[1811.06069]: https://arxiv.org/abs/1811.06069
48+
[1811.06069]: https://arxiv.org/abs/1811.06069

nix/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ The `./nix/` directory contains various helper functions and utilities.
6060
6161
* [Haskell.nix][]
6262
* Basic example with cross-compilation: https://github.com/input-output-hk/haskell-nix-example
63-
* Setting up the binary cache to avoid recompiling GHC: https://input-output-hk.github.io/haskell.nix/tutorials/getting-started#setting-up-the-binary-cache
63+
* Setting up the binary cache to avoid recompiling GHC: https://input-output-hk.github.io/haskell.nix/tutorials/getting-started#setting-up-the-binary-cache

scripts/buildkite/admin/flake.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@
3535
};
3636
}
3737
);
38-
}
38+
}

scripts/buildkite/main/linux-package.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ git fetch --all
99
git checkout "$RELEASE_CANDIDATE_COMMIT"
1010

1111
rm -rf ./result/*
12-
nix build -L -o result/linux .#ci.artifacts.linux64.release
12+
nix build -L -o result/linux .#ci.artifacts.linux64.release

scripts/buildkite/release/openapi-diff.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ mkdir -p artifacts
2828
# free the bin directory for buildkite to clean up
2929
chmod -R +w "$GOPATH"
3030
rm -rf "$GOPATH"
31-
rm -rf "$swagger_tmp"
31+
rm -rf "$swagger_tmp"

scripts/buildkite/release/push-to-dockerhub.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ artifact() {
5353
fi
5454
}
5555

56-
artifact "cardano-wallet-$NEW_GIT_TAG-docker-image.tgz"
56+
artifact "cardano-wallet-$NEW_GIT_TAG-docker-image.tgz"

scripts/buildkite/release/update-documentation-links.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ git pull --rebase origin "${GH_PAGES_BRANCH}"
1010
cd releases
1111
./make_redirects.sh "${RELEASE_VERSION}"
1212
git remote set-url origin "https://$GITHUB_TOKEN@github.com/cardano-foundation/cardano-wallet.git"
13-
git push origin "${GH_PAGES_BRANCH}"
13+
git push origin "${GH_PAGES_BRANCH}"

scripts/enforce-eol.sh

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
# define command as the script parameter or default to check
6+
command=${1:-check}
7+
8+
# traverse the directories and apply the operation to the files that match the regex
9+
traverse() {
10+
local op=$1
11+
local directory=$2
12+
local regex=$3
13+
find "$directory" -type f -regex "$regex" |
14+
while read -r file; do
15+
$op "$file"
16+
done
17+
}
18+
19+
# check if the file ends with a newline character and, depending on the command, add it
20+
# or bail out with an error message
21+
check() {
22+
local file=$1
23+
if [ -s "$file" ] && [ "$(tail -c 1 "$file")" != "" ]; then
24+
case $command in
25+
add)
26+
echo "Adding newline character to $file"
27+
echo "" >>"$file"
28+
;;
29+
check)
30+
echo "File $file does not end with a newline character."
31+
echo "Fix this by running ./scripts/enforce-eol.sh add"
32+
exit 1
33+
;;
34+
*)
35+
echo "Invalid command: $command"
36+
echo "Usage: enforce-eol.sh [check|add]"
37+
exit 1
38+
;;
39+
esac
40+
fi
41+
}
42+
43+
directories=("lib" "scripts" "docs" "nix" "specifications" "configs")
44+
45+
# json is not included because most of json is golden files. It would be better to
46+
# use the directories filter instead of the regex filter
47+
regex=".*\.\(md\|hs\|sh\|nix\|yaml\|yml\|toml\|cabal\)$"
48+
49+
for directory in "${directories[@]}"; do
50+
traverse check "$directory" "$regex"
51+
done

specifications/Cardano/Wallet/Primitive/Types/DeltaUTxO.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,4 @@ Set DeltaUTxO ≈ (Set KeyDeltaUTxO, Map KeyDeltaUTxO DeltaUTxO)
123123

124124
where the key replaces the polymorphic values, and the `Map` assigns the keys the values again.
125125

126-
Note that this approach does require us to do manual key management — we have to create and destroy `KeyDeltaUTxO` as we add and remove elements from the container.
126+
Note that this approach does require us to do manual key management — we have to create and destroy `KeyDeltaUTxO` as we add and remove elements from the container.

specifications/Cardano/Wallet/Submissions/design.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,4 @@ gantt
128128
Unknown :2021-12-29 , 13d
129129
```
130130

131-
Note: Transactions with `Unknown` status cannot be partitioned by slot, we have to consider them through the entire timeline.
131+
Note: Transactions with `Unknown` status cannot be partitioned by slot, we have to consider them through the entire timeline.

specifications/Cardano/Wallet/delegation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,4 @@ data Operation slot drep pool
146146
= VoteAndDelegate (Maybe drep) (Maybe pool) slot
147147
| Deregister slot
148148
| Rollback slot
149-
```
149+
```

0 commit comments

Comments
 (0)