checks: Use stricter rustfmt rules
This commit is contained in:
parent
f1e2efd865
commit
3abd9fde87
3 changed files with 16 additions and 8 deletions
|
@ -35,7 +35,7 @@ flatpak:
|
||||||
# Configure and run code checks
|
# Configure and run code checks
|
||||||
# Exits and fails if an error is encountered
|
# Exits and fails if an error is encountered
|
||||||
checks:
|
checks:
|
||||||
image: "rust:slim"
|
image: "rustlang/rust:nightly-slim"
|
||||||
stage: check
|
stage: check
|
||||||
script:
|
script:
|
||||||
- scripts/checks.sh --verbose --force-install
|
- scripts/checks.sh --verbose --force-install
|
||||||
|
|
8
.rustfmt.toml
Normal file
8
.rustfmt.toml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
condense_wildcard_suffixes = true
|
||||||
|
format_code_in_doc_comments = true
|
||||||
|
group_imports = "StdExternalCrate"
|
||||||
|
imports_granularity = "Crate"
|
||||||
|
newline_style = "Unix"
|
||||||
|
normalize_comments = true
|
||||||
|
normalize_doc_attributes = true
|
||||||
|
wrap_comments = true
|
|
@ -87,7 +87,7 @@ check_rustup() {
|
||||||
if ! which rustup &> /dev/null; then
|
if ! which rustup &> /dev/null; then
|
||||||
if [[ "$1" == '-i' ]]; then
|
if [[ "$1" == '-i' ]]; then
|
||||||
echo -e "$Installing rustup…"
|
echo -e "$Installing rustup…"
|
||||||
curl https://sh.rustup.rs -sSf | sh -s -- -y
|
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly
|
||||||
export PATH=$PATH:$HOME/.cargo/bin
|
export PATH=$PATH:$HOME/.cargo/bin
|
||||||
if ! which rustup &> /dev/null; then
|
if ! which rustup &> /dev/null; then
|
||||||
echo -e "$Failed to install rustup"
|
echo -e "$Failed to install rustup"
|
||||||
|
@ -145,7 +145,7 @@ check_cargo() {
|
||||||
|
|
||||||
if [[ $verbose -eq 1 ]]; then
|
if [[ $verbose -eq 1 ]]; then
|
||||||
echo ""
|
echo ""
|
||||||
rustc -Vv && cargo -Vv
|
rustc -Vv && cargo +nightly -Vv
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,8 +154,8 @@ install_rustfmt() {
|
||||||
check_rustup -i
|
check_rustup -i
|
||||||
|
|
||||||
echo -e "$Installing rustfmt…"
|
echo -e "$Installing rustfmt…"
|
||||||
rustup component add rustfmt
|
rustup component add --toolchain nightly rustfmt
|
||||||
if ! cargo fmt --version >/dev/null 2>&1; then
|
if ! cargo +nightly fmt --version >/dev/null 2>&1; then
|
||||||
echo -e "$Failed to install rustfmt"
|
echo -e "$Failed to install rustfmt"
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
@ -163,7 +163,7 @@ install_rustfmt() {
|
||||||
|
|
||||||
# Run rustfmt to enforce code style.
|
# Run rustfmt to enforce code style.
|
||||||
run_rustfmt() {
|
run_rustfmt() {
|
||||||
if ! cargo fmt --version >/dev/null 2>&1; then
|
if ! cargo +nightly fmt --version >/dev/null 2>&1; then
|
||||||
if [[ $force_install -eq 1 ]]; then
|
if [[ $force_install -eq 1 ]]; then
|
||||||
install_rustfmt
|
install_rustfmt
|
||||||
elif [ ! -t 1 ]; then
|
elif [ ! -t 1 ]; then
|
||||||
|
@ -197,11 +197,11 @@ run_rustfmt() {
|
||||||
|
|
||||||
if [[ $verbose -eq 1 ]]; then
|
if [[ $verbose -eq 1 ]]; then
|
||||||
echo ""
|
echo ""
|
||||||
cargo fmt --version
|
cargo +nightly fmt --version
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! cargo fmt --all -- --check; then
|
if ! cargo +nightly fmt --all -- --check; then
|
||||||
echo -e " Checking code style result: $fail"
|
echo -e " Checking code style result: $fail"
|
||||||
echo "Please fix the above issues, either manually or by running: cargo fmt --all"
|
echo "Please fix the above issues, either manually or by running: cargo fmt --all"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in a new issue