From 5d3ba6bcebb699b547338b3fb7ad2e6d2721be27 Mon Sep 17 00:00:00 2001 From: Andrew Danger Lyon Date: Sat, 9 Mar 2024 19:47:23 -0800 Subject: [PATCH] build: lint+fmt updates --- Makefile | 64 ++++++++++++++++++++++++++++++---------------------- rustfmt.toml | 28 +++++++++++++++++++++++ 2 files changed, 65 insertions(+), 27 deletions(-) create mode 100644 rustfmt.toml diff --git a/Makefile b/Makefile index 62adb38..0660d21 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all clean release doc build run test test-panic test-st macros osx windows target/windows/stamp-cli.exe target/osx/stamp-cli +.PHONY: all clean lint fmt release doc build run test test-panic test-st macros osx windows target/windows/stamp-cli.exe target/osx/stamp-cli # non-versioned include VARS ?= vars.mk @@ -11,12 +11,47 @@ all: build run: build cargo run $(CARGO_BUILD_ARGS) -build: +build: fmt cargo build $(CARGO_BUILD_ARGS) +fmt: + cargo fmt + release: override CARGO_BUILD_ARGS += --release release: build +doc: + cargo doc $(CARGO_BUILD_ARGS) + +test: fmt + cargo test $(TEST) $(CARGO_BUILD_ARGS) -- --nocapture + +test-release: override CARGO_BUILD_ARGS += --release +test-release: test + +test-panic: override FEATURES += panic-on-error +test-panic: fmt + RUST_BACKTRACE=1 \ + cargo test \ + $(TEST) \ + $(CARGO_BUILD_ARGS) -- \ + --nocapture + +test-st: fmt + cargo test $(TEST) $(CARGO_BUILD_ARGS) -- --nocapture --test-threads 1 + +lint: + cargo clippy $(CARGO_BUILD_ARGS) -- \ + -A clippy::comparison_chain \ + -A clippy::module_inception \ + -A clippy::redundant_closure \ + -A clippy::redundant_pattern_matching \ + -A clippy::search_is_some + +clean: + rm -rf target/ + cargo clean + target/windows/stamp-cli.exe: @mkdir -p $(@D) ssh \ @@ -36,28 +71,3 @@ target/osx/stamp-cli: osx: target/osx/stamp-cli windows: target/windows/stamp-cli.exe -doc: - cargo doc - -test-release: override CARGO_BUILD_ARGS += --release -test-release: - cargo test $(TEST) $(CARGO_BUILD_ARGS) -- --nocapture - -test: - cargo test $(TEST) $(CARGO_BUILD_ARGS) -- --nocapture - -test-panic: override FEATURES += panic-on-error -test-panic: - RUST_BACKTRACE=1 \ - cargo test \ - $(TEST) \ - $(CARGO_BUILD_ARGS) -- \ - --nocapture - -test-st: - cargo test $(TEST) $(CARGO_BUILD_ARGS) -- --nocapture --test-threads 1 - -clean: - rm -rf target/ - cargo clean - diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..daa0f46 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,28 @@ +#brace_style = "SameLineWhere" +#condense_wildcard_suffixes = true +#control_brace_style = "AlwaysSameLine" +#enum_discrim_align_threshold = 0 +fn_call_width = 100 +fn_params_layout = "Tall" +#format_macro_matchers = true +#group_imports = "Preserve" +hard_tabs = false +#imports_granularity = "Preserve" +#imports_layout = "Mixed" +#indent_style = "Block" +match_block_trailing_comma = false +max_width = 140 +merge_derives = true +reorder_imports = true +reorder_modules = true +#space_after_colon = true +#space_before_colon = false +#spaces_around_ranges = false +#struct_field_align_threshold = 0 +#struct_lit_single_line = true +tab_spaces = 4 +#trailing_comma = "Vertical" +#trailing_semicolon = true +#type_punctuation_density = "Wide" +use_try_shorthand = true +#where_single_line = false