Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
66 changes: 66 additions & 0 deletions .clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# loopctl clippy configuration
# Strict linting for the entire project.
# Run: cargo clippy --all-features -- -D warnings

# Thresholds

# Maximum cognitive complexity per function before warning.
cognitive-complexity-threshold = 30

# Maximum number of struct fields before suggesting a builder.
struct-field-name-threshold = 8

# Type complexity threshold (default is 250).
type-complexity-threshold = 250

# Maximum lines of code per function body before warning.
too-many-lines-threshold = 150

# Maximum number of arguments before warning.
too-many-arguments-threshold = 7

# MSRV from Cargo.toml.
msrv = "1.85.0"

# Warn when passing types larger than this by value (bytes).
trivial-copy-size-limit = 32

# Warn on large stack frames.
stack-size-threshold = 512000

# Warn when a single-char binding name is used more than N times.
single-char-binding-names-threshold = 4

# Style enforcement

disallowed-names = ["foo", "bar", "baz", "quux"]

doc-valid-idents = [
"GraphQL", "WebSocket", "REST", "gRPC",
"OpenAI", "Anthropic", "HuggingFace",
"OAuth", "JWT", "HMAC", "SHA",
"Linux", "macOS", "FreeBSD",
"AccessKit", "CoreFoundation", "Direct2D",
"Direct3D", "DirectWrite", "OpenSSL",
"MinGW", "NaN", "NaNs",
]

# Lint behavior

avoid-breaking-exported-api = false
check-private-items = true
allow-one-hash-in-raw-strings = true

enum-variant-size-threshold = 200
large-error-threshold = 128
pass-by-value-size-limit = 256
vec-box-size-threshold = 128
unnecessary-box-size = 128
literal-representation-threshold = 4
verbose-bit-mask-threshold = 1

max-struct-bools = 3
max-fn-params-bools = 2
max-trait-bounds = 4

standard-macro-braces = []
15 changes: 15 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,18 @@ proptest = "1"
[features]
default = []
testing = []

[lints.clippy]
pedantic = { level = "warn", priority = -1 }
unwrap_used = "deny"
expect_used = "deny"
panic = "deny"
todo = "deny"
unimplemented = "deny"
unreachable = "deny"
arithmetic_side_effects = "deny"
indexing_slicing = "deny"
match_same_arms = "deny"
redundant_clone = "deny"
clone_on_ref_ptr = "deny"
let_underscore_must_use = "deny"
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: check test clippy fmt docs ci
.PHONY: check test clippy fmt docs ci lint

ci: check test clippy fmt docs
ci: fmt check clippy test docs

check:
cargo check --all-features
Expand All @@ -14,5 +14,8 @@ clippy:
fmt:
cargo fmt --all -- --check

lint:
cargo fmt --all

docs:
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features
41 changes: 41 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# loopctl formatting rules
# Derived from the project's existing style (edition 2024, rustfmt 1.8.0).
# Run: cargo fmt --all -- --check

# Line width
max_width = 100

# Indentation
hard_tabs = false
tab_spaces = 4

# Newlines
newline_style = "Unix"

# Functions & calls
fn_params_layout = "Tall"
fn_call_width = 60
attr_fn_like_width = 70
struct_lit_width = 18
struct_variant_width = 35
array_width = 60
chain_width = 60
single_line_if_else_max_width = 50
single_line_let_else_max_width = 50

# Heuristics & expressions
use_small_heuristics = "Default"
short_array_element_width_threshold = 10
remove_nested_parens = true
match_arm_leading_pipes = "Never"
match_block_trailing_comma = false

# Imports
reorder_imports = true
reorder_modules = true

# Miscellaneous
merge_derives = true
use_field_init_shorthand = true
force_explicit_abi = true

Loading
Loading