Skip to content

Commit bea4d1b

Browse files
committed
chore: add clippy CI tests
run cargo clippy for all targets
1 parent 920cfdc commit bea4d1b

File tree

6 files changed

+91
-0
lines changed

6 files changed

+91
-0
lines changed

Cargo.toml

+22
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,25 @@ members = [
142142
"ctest-test",
143143
"libc-test",
144144
]
145+
146+
#
147+
# TODO: These should be renamed as `[workspace.lints.*]` once MSRV is abve 1.64
148+
# This way all crates can use it with `[lints] workspace=true` section
149+
#
150+
151+
[lints.rust]
152+
# TODO: make ident usage consistent in each file
153+
unused_qualifications = "allow"
154+
155+
[lints.clippy]
156+
# TODO: all these are default lints and should probably be fixed
157+
identity_op = "allow"
158+
if_same_then_else = "allow"
159+
missing_safety_doc = "allow"
160+
non_minimal_cfg = "allow"
161+
precedence = "allow"
162+
redundant_field_names = "allow"
163+
redundant_static_lifetimes = "allow"
164+
unnecessary_cast = "allow"
165+
unused_unit = "allow"
166+
zero_ptr = "allow"

ci/style.sh

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ set -eux
44

55
[ -n "${CI:-}" ] && check="--check"
66

7+
# TODO: for some reason using `--workspace` validates a lot of generated code in ./target/** dir
8+
cargo clippy -p [email protected] -p ctest --all-targets -- -D warnings
9+
710
cargo test --manifest-path libc-test/Cargo.toml --test style -- --nocapture
811

912
command -v rustfmt

ci/verify-build.sh

+7
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,13 @@ test_target() {
4444
# The basic command that is run each time
4545
cmd="cargo +$rust build --target $target"
4646

47+
# The basic clippy command
48+
clippy_cmd="cargo +$rust clippy --all-targets --target $target"
49+
4750
if [ "${no_dist}" != "0" ]; then
4851
# If we can't download a `core`, we need to build it
4952
cmd="$cmd -Zbuild-std=core,alloc"
53+
clippy_cmd="$clippy_cmd -Zbuild-std=core,alloc"
5054

5155
# FIXME: With `build-std` feature, `compiler_builtins` emits a lof of lint warnings.
5256
RUSTFLAGS="${RUSTFLAGS:-} -Aimproper_ctypes_definitions"
@@ -67,6 +71,9 @@ test_target() {
6771
done
6872
fi
6973

74+
# Run cargo clippy first
75+
$clippy_cmd
76+
7077
# Test with expected combinations of features
7178
$cmd
7279
$cmd --features extra_traits

ctest-test/Cargo.toml

+14
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,17 @@ test = false
2828
[[bin]]
2929
name = "t2_cxx"
3030
test = false
31+
32+
#
33+
# TODO: These should be moved to the root Cargo.toml as `[workspace.lints.*]` once MSRV is abve 1.64
34+
# replace it with `[lints] workspace=true`
35+
#
36+
37+
[lints.rust]
38+
# TODO: make ident usage consistent in each file
39+
unused_qualifications = "allow"
40+
41+
[lints.clippy]
42+
# TODO: fix these, and enable pedantic lints with needed exceptions
43+
match_like_matches_macro = "allow"
44+
eq_op = "allow"

ctest/Cargo.toml

+22
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,25 @@ garando_syntax = "0.1"
1313
cc = "1.0.1"
1414
rustc_version = "0.4"
1515
indoc = "2.0.6"
16+
17+
#
18+
# TODO: These should be moved to the root Cargo.toml as `[workspace.lints.*]` once MSRV is abve 1.64
19+
# replace it with `[lints] workspace=true`
20+
#
21+
22+
[lints.rust]
23+
# TODO: make ident usage consistent in each file
24+
unused_qualifications = "allow"
25+
26+
[lints.clippy]
27+
# TODO: fix these, and enable pedantic lints with needed exceptions
28+
doc_lazy_continuation = "allow"
29+
if_same_then_else = "allow"
30+
needless_borrow = "allow"
31+
needless_borrowed_reference = "allow"
32+
needless_borrows_for_generic_args = "allow"
33+
needless_lifetimes = "allow"
34+
only_used_in_recursion = "allow"
35+
option_as_ref_deref = "allow"
36+
type_complexity = "allow"
37+
useless_format = "allow"

libc-test/Cargo.toml

+23
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,26 @@ harness = true
102102
name = "style_tests"
103103
path = "test/style_tests.rs"
104104
harness = true
105+
106+
#
107+
# TODO: These should be moved to the root Cargo.toml as `[workspace.lints.*]` once MSRV is abve 1.64
108+
# replace it with `[lints] workspace=true`
109+
#
110+
111+
[lints.rust]
112+
# TODO: make ident usage consistent in each file
113+
unused_qualifications = "allow"
114+
115+
[lints.clippy]
116+
# TODO: fix these, and enable pedantic lints with needed exceptions
117+
needless_return = "allow"
118+
comparison_to_empty = "allow"
119+
unused_io_amount = "allow"
120+
write_with_newline = "allow"
121+
needless_borrows_for_generic_args = "allow"
122+
only_used_in_recursion = "allow"
123+
match_like_matches_macro = "allow"
124+
useless_format = "allow"
125+
wildcard_in_or_patterns = "allow"
126+
nonminimal_bool = "allow"
127+
match_single_binding = "allow"

0 commit comments

Comments
 (0)