Skip to content

Commit

Permalink
Remove cranky and replace with lint section in Cargo.toml (rerun-io#6045
Browse files Browse the repository at this point in the history
)

### What

* Fixes rerun-io#6032

Everything that cranky did can now be done with the lints section in the
Cargo.toml.
Turns out this now also detects some lints that were moved or removed.
What's less clear is why this tripped now over new things that weren't
flagged before, but I'll not complain about that! 😄

Review commit by commit recommended.

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6045?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6045?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!

- [PR Build Summary](https://build.rerun.io/pr/6045)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
  • Loading branch information
Wumpf authored Apr 22, 2024
1 parent a680086 commit 6afa22e
Show file tree
Hide file tree
Showing 326 changed files with 691 additions and 258 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/contrib_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ env:
# https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
RUSTFLAGS: --cfg=web_sys_unstable_apis --deny warnings

# See https://github.com/ericseppanen/cargo-cranky/issues/8
RUSTDOCFLAGS: --deny warnings --deny rustdoc::missing_crate_level_docs
RUSTDOCFLAGS: --deny warnings

# Disable the GHA backend (Github's 10GB storage) since we use our own GCS backend.
# See: https://github.com/marketplace/actions/sccache-action
Expand Down Expand Up @@ -91,7 +90,7 @@ jobs:
run: pixi run codegen --force --check

rs-lints:
name: Rust lints (fmt, check, cranky, tests, doc)
name: Rust lints (fmt, check, clippy, tests, doc)
runs-on: ubuntu-latest-16-cores
steps:
- uses: actions/checkout@v4
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/contrib_rerun_py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ env:
# RUSTFLAGS: --cfg=web_sys_unstable_apis --deny warnings
RUSTFLAGS: --cfg=web_sys_unstable_apis

# See https://github.com/ericseppanen/cargo-cranky/issues/8
RUSTDOCFLAGS: --deny warnings --deny rustdoc::missing_crate_level_docs
RUSTDOCFLAGS: --deny warnings

# Disable the GHA backend (Github's 10GB storage) since we use our own GCS backend.
# See: https://github.com/marketplace/actions/sccache-action
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/reusable_bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ env:
# https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
RUSTFLAGS: --cfg=web_sys_unstable_apis --deny warnings

# See https://github.com/ericseppanen/cargo-cranky/issues/8
RUSTDOCFLAGS: --deny warnings --deny rustdoc::missing_crate_level_docs
RUSTDOCFLAGS: --deny warnings

# Disable the GHA backend (Github's 10GB storage) since we use our own GCS backend.
# See: https://github.com/marketplace/actions/sccache-action
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/reusable_build_and_upload_rerun_c.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ env:
# https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
RUSTFLAGS: --cfg=web_sys_unstable_apis --deny warnings

# See https://github.com/ericseppanen/cargo-cranky/issues/8
RUSTDOCFLAGS: --deny warnings --deny rustdoc::missing_crate_level_docs
RUSTDOCFLAGS: --deny warnings

# Disable the GHA backend (Github's 10GB storage) since we use our own GCS backend.
# See: https://github.com/marketplace/actions/sccache-action
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/reusable_build_and_upload_rerun_cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ env:
# https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
RUSTFLAGS: --cfg=web_sys_unstable_apis --deny warnings

# See https://github.com/ericseppanen/cargo-cranky/issues/8
RUSTDOCFLAGS: --deny warnings --deny rustdoc::missing_crate_level_docs
RUSTDOCFLAGS: --deny warnings

# Disable the GHA backend (Github's 10GB storage) since we use our own GCS backend.
# See: https://github.com/marketplace/actions/sccache-action
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/reusable_build_and_upload_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ env:
# RUSTFLAGS: --cfg=web_sys_unstable_apis --deny warnings
RUSTFLAGS: --cfg=web_sys_unstable_apis

# See https://github.com/ericseppanen/cargo-cranky/issues/8
RUSTDOCFLAGS: --deny warnings --deny rustdoc::missing_crate_level_docs
RUSTDOCFLAGS: --deny warnings

# Disable the GHA backend (Github's 10GB storage) since we use our own GCS backend.
# See: https://github.com/marketplace/actions/sccache-action
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/reusable_build_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ env:
# https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
RUSTFLAGS: --cfg=web_sys_unstable_apis --deny warnings

# See https://github.com/ericseppanen/cargo-cranky/issues/8
RUSTDOCFLAGS: --deny warnings --deny rustdoc::missing_crate_level_docs
RUSTDOCFLAGS: --deny warnings

# Disable the GHA backend (Github's 10GB storage) since we use our own GCS backend.
# See: https://github.com/marketplace/actions/sccache-action
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/reusable_build_js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ env:
# https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
RUSTFLAGS: --cfg=web_sys_unstable_apis --deny warnings

# See https://github.com/ericseppanen/cargo-cranky/issues/8
RUSTDOCFLAGS: --deny warnings --deny rustdoc::missing_crate_level_docs
RUSTDOCFLAGS: --deny warnings

# Disable the GHA backend (Github's 10GB storage) since we use our own GCS backend.
# See: https://github.com/marketplace/actions/sccache-action
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/reusable_build_web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ env:
# https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
RUSTFLAGS: --cfg=web_sys_unstable_apis --deny warnings

# See https://github.com/ericseppanen/cargo-cranky/issues/8
RUSTDOCFLAGS: --deny warnings --deny rustdoc::missing_crate_level_docs
RUSTDOCFLAGS: --deny warnings

# Disable the GHA backend (Github's 10GB storage) since we use our own GCS backend.
# See: https://github.com/marketplace/actions/sccache-action
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/reusable_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ env:
# https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
RUSTFLAGS: --cfg=web_sys_unstable_apis --deny warnings

# See https://github.com/ericseppanen/cargo-cranky/issues/8
RUSTDOCFLAGS: --deny warnings --deny rustdoc::missing_crate_level_docs
RUSTDOCFLAGS: --deny warnings

# Disable the GHA backend (Github's 10GB storage) since we use our own GCS backend.
# See: https://github.com/marketplace/actions/sccache-action
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/reusable_checks_rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ env:
# https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
RUSTFLAGS: --cfg=web_sys_unstable_apis --deny warnings

# See https://github.com/ericseppanen/cargo-cranky/issues/8
RUSTDOCFLAGS: --deny warnings --deny rustdoc::missing_crate_level_docs
RUSTDOCFLAGS: --deny warnings

# Disable the GHA backend (Github's 10GB storage) since we use our own GCS backend.
# See: https://github.com/marketplace/actions/sccache-action
Expand All @@ -47,7 +46,7 @@ jobs:
# ---------------------------------------------------------------------------

rs-lints:
name: Rust lints (fmt, check, cranky, tests, doc)
name: Rust lints (fmt, check, clippy, tests, doc)
runs-on: ubuntu-latest-16-cores
steps:
- uses: actions/checkout@v4
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/reusable_deploy_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ env:
# https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html
RUSTFLAGS: --cfg=web_sys_unstable_apis --deny warnings

# See https://github.com/ericseppanen/cargo-cranky/issues/8
RUSTDOCFLAGS: --deny warnings --deny rustdoc::missing_crate_level_docs
RUSTDOCFLAGS: --deny warnings

# Disable the GHA backend (Github's 10GB storage) since we use our own GCS backend.
# See: https://github.com/marketplace/actions/sccache-action
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/reusable_test_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ env:
# RUSTFLAGS: --cfg=web_sys_unstable_apis --deny warnings
RUSTFLAGS: --cfg=web_sys_unstable_apis

# See https://github.com/ericseppanen/cargo-cranky/issues/8
RUSTDOCFLAGS: --deny warnings --deny rustdoc::missing_crate_level_docs
RUSTDOCFLAGS: --deny warnings

# Disable the GHA backend (Github's 10GB storage) since we use our own GCS backend.
# See: https://github.com/marketplace/actions/sccache-action
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
// see https://github.com/rerun-io/rerun/pull/519 for rationale
"rust-analyzer.check.overrideCommand": [
"cargo",
"cranky",
"clippy",
"--target-dir=target_ra",
"--workspace",
"--message-format=json",
Expand Down
8 changes: 0 additions & 8 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ If you are using an Apple-silicon Mac (M1, M2), make sure `rustc -vV` outputs `h
rustup set default-host aarch64-apple-darwin && rustup install 1.76.0
```

Additionally, we use [cargo-cranky](https://github.com/ericseppanen/cargo-cranky) for defining which Clippy lints are active and [cargo-deny](https://github.com/EmbarkStudios/cargo-deny) for linting crate versions.
You don't need to install these for building, but it's highly recommended when contributing changes to
Rust code.
```sh
cargo install cargo-cranky
cargo install --locked cargo-deny
```

## Building and running the viewer

Use this command for building and running the viewer:
Expand Down
4 changes: 1 addition & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ cargo run -p rerun -- --help
We use the [`pixi`](https://prefix.dev/) for managing dev-tool versioning, download and task running. To see available tasks, use `pixi task list`.
# TODO(andreas): This doesn't list tasks from the different environments. Asked [here](https://discord.com/channels/1082332781146800168/1227563080934756475/1227563080934756475) if there's a way to do that.

We use [cargo cranky](https://github.com/ericseppanen/cargo-cranky) and specify our clippy lints in [`Cranky.toml`](Cranky.toml). Usage: `cargo cranky`.

We use [cargo deny](https://github.com/EmbarkStudios/cargo-deny) to check our dependency tree for copy-left licenses, duplicate dependencies and [rustsec advisories](https://rustsec.org/advisories). You can configure it in `deny.toml`. Usage: `cargo deny check`.

Configure your editor to run `cargo fmt` on save. Also configure it to strip trailing whitespace, and to end each file with a newline. Settings for VSCode can be found in the `.vscode` folder and should be applied automatically. If you are using another editor, consider adding good setting to this repository!
Expand All @@ -143,7 +141,7 @@ git config core.hooksPath hooks
```

### Optional
You can use [bacon](https://github.com/Canop/bacon) to automatically check your code on each save. For instance, running just `bacon` will re-run `cargo cranky` each time you change a rust file. See [`bacon.toml`](bacon.toml) for more.
You can use [bacon](https://github.com/Canop/bacon) to automatically check your code on each save. For instance, running just `bacon` will re-run `cargo clippy` each time you change a rust file. See [`bacon.toml`](bacon.toml) for more.

You can set up [`sccache`](https://github.com/mozilla/sccache) to speed up re-compilation (e.g. when switching branches). You can control the size of the cache with `export SCCACHE_CACHE_SIZE="256G"`.

Expand Down
170 changes: 170 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,176 @@ panic = "abort" # This leads to better optimizations and smaller binaries (and i
[profile.bench]
debug = true


[workspace.lints.rust]
unsafe_code = "deny"

elided_lifetimes_in_paths = "warn"
future_incompatible = "warn"
nonstandard_style = "warn"
rust_2018_idioms = "warn"
rust_2021_prelude_collisions = "warn"
semicolon_in_expressions_from_macros = "warn"
trivial_numeric_casts = "warn"
unsafe_op_in_unsafe_fn = "warn" # `unsafe_op_in_unsafe_fn` may become the default in future Rust versions: https://github.com/rust-lang/rust/issues/71668
unused_extern_crates = "warn"
unused_import_braces = "warn"
unused_lifetimes = "warn"

trivial_casts = "allow"
unused_qualifications = "allow"

[workspace.lints.rustdoc]
all = "warn"
missing_crate_level_docs = "warn"

# See also clippy.toml
[workspace.lints.clippy]
as_ptr_cast_mut = "warn"
await_holding_lock = "warn"
bool_to_int_with_if = "warn"
char_lit_as_u8 = "warn"
checked_conversions = "warn"
clear_with_drain = "warn"
cloned_instead_of_copied = "warn"
dbg_macro = "warn"
debug_assert_with_mut_call = "warn"
derive_partial_eq_without_eq = "warn"
disallowed_macros = "warn" # See clippy.toml
disallowed_methods = "warn" # See clippy.toml
disallowed_names = "warn" # See clippy.toml
disallowed_script_idents = "warn" # See clippy.toml
disallowed_types = "warn" # See clippy.toml
doc_link_with_quotes = "warn"
doc_markdown = "warn"
empty_enum = "warn"
enum_glob_use = "warn"
equatable_if_let = "warn"
exit = "warn"
expl_impl_clone_on_copy = "warn"
explicit_deref_methods = "warn"
explicit_into_iter_loop = "warn"
explicit_iter_loop = "warn"
fallible_impl_from = "warn"
filter_map_next = "warn"
flat_map_option = "warn"
float_cmp_const = "warn"
fn_params_excessive_bools = "warn"
fn_to_numeric_cast_any = "warn"
from_iter_instead_of_collect = "warn"
get_unwrap = "warn"
if_let_mutex = "warn"
implicit_clone = "warn"
imprecise_flops = "warn"
index_refutable_slice = "warn"
inefficient_to_string = "warn"
infinite_loop = "warn"
into_iter_without_iter = "warn"
invalid_upcast_comparisons = "warn"
iter_not_returning_iterator = "warn"
iter_on_empty_collections = "warn"
iter_on_single_items = "warn"
iter_without_into_iter = "warn"
large_digit_groups = "warn"
large_include_file = "warn"
large_stack_arrays = "warn"
large_stack_frames = "warn"
large_types_passed_by_value = "warn"
let_unit_value = "warn"
linkedlist = "warn"
lossy_float_literal = "warn"
macro_use_imports = "warn"
manual_assert = "warn"
manual_clamp = "warn"
manual_instant_elapsed = "warn"
manual_let_else = "warn"
manual_ok_or = "warn"
manual_string_new = "warn"
map_err_ignore = "warn"
map_flatten = "warn"
map_unwrap_or = "warn"
match_on_vec_items = "warn"
match_same_arms = "warn"
match_wild_err_arm = "warn"
match_wildcard_for_single_variants = "warn"
mem_forget = "warn"
mismatched_target_os = "warn"
mismatching_type_param_order = "warn"
missing_enforced_import_renames = "warn"
missing_safety_doc = "warn"
mut_mut = "warn"
mutex_integer = "warn"
needless_borrow = "warn"
needless_continue = "warn"
needless_for_each = "warn"
needless_pass_by_ref_mut = "warn"
needless_pass_by_value = "warn"
negative_feature_names = "warn"
nonstandard_macro_braces = "warn"
option_option = "warn"
path_buf_push_overwrite = "warn"
ptr_as_ptr = "warn"
ptr_cast_constness = "warn"
pub_without_shorthand = "warn"
rc_mutex = "warn"
readonly_write_lock = "warn"
redundant_type_annotations = "warn"
ref_option_ref = "warn"
rest_pat_in_fully_bound_structs = "warn"
same_functions_in_if_condition = "warn"
semicolon_if_nothing_returned = "warn"
should_panic_without_expect = "warn"
significant_drop_tightening = "warn"
single_match_else = "warn"
str_to_string = "warn"
string_add_assign = "warn"
string_add = "warn"
string_lit_as_bytes = "warn"
string_lit_chars_any = "warn"
string_to_string = "warn"
suspicious_command_arg_space = "warn"
suspicious_xor_used_as_pow = "warn"
todo = "warn"
too_many_lines = "warn"
trailing_empty_array = "warn"
trait_duplication_in_bounds = "warn"
tuple_array_conversions = "warn"
unchecked_duration_subtraction = "warn"
undocumented_unsafe_blocks = "warn"
unimplemented = "warn"
uninhabited_references = "warn"
uninlined_format_args = "warn"
unnecessary_box_returns = "warn"
unnecessary_safety_doc = "warn"
unnecessary_struct_initialization = "warn"
unnecessary_wraps = "warn"
unnested_or_patterns = "warn"
unused_peekable = "warn"
unused_rounding = "warn"
unused_self = "warn"
useless_transmute = "warn"
verbose_file_reads = "warn"
wildcard_dependencies = "warn"
wildcard_imports = "warn"
zero_sized_map_values = "warn"
# Disabled waiting on https://github.com/rust-lang/rust-clippy/issues/9602
#self_named_module_files = "warn"

manual_range_contains = "allow" # this one is just worse imho
ref_patterns = "allow" # It's nice to avoid ref pattern, but there are some situations that are hard (impossible?) to express without.

# TODO(emilk): enable more of these lints:
iter_over_hash_type = "allow"
let_underscore_untyped = "allow"
missing_assert_message = "allow"
missing_errors_doc = "allow"

# TODO(#3408): Forbid `.unwrap()`
# This would be nice to enable, but we have way too many unwraps right now 😭
# Enabling this lint in 2023-04-27 yielded 556 hits.
# Enabling this lint in 2023-09-23 yielded 352 hits
unwrap_used = "allow"

[patch.crates-io]
# Try to avoid patching crates! It prevents us from publishing the crates on crates.io.
# If you do patch always prefer to patch to a commit on the trunk of the upstream repo.
Expand Down
Loading

0 comments on commit 6afa22e

Please sign in to comment.