Skip to content

Commit

Permalink
Run clippy for wasm, with own clippy.toml config file
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Mar 20, 2023
1 parent 86d0f10 commit 6207499
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 4 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,7 @@ jobs:
save-if: ${{ github.event_name == 'push'}}

- name: Check re_viewer wasm32
uses: actions-rs/cargo@v1
with:
command: check
args: --locked --all-features --lib --target wasm32-unknown-unknown --target-dir target_wasm -p re_viewer
run: ./scripts/clippy_wasm.sh

- name: Check re_renderer examples wasm32
uses: actions-rs/cargo@v1
Expand Down
30 changes: 30 additions & 0 deletions clippy_wasm.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This is used by `scripts/clippy_wasm.sh` so we can forbid some methods that are not available in wasm.
#
# We cannot forbid all these methods in the main `clippy.toml` because of
# https://github.com/rust-lang/rust-clippy/issues/10406

msrv = "1.67"

# https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods
disallowed-methods = [
"std::time::Instant::now", # use `instant` crate instead for wasm/web compatibility
"std::time::Duration::elapsed", # use `instant` crate instead for wasm/web compatibility
"std::time::SystemTime::now", # use `instant` or `time` crates instead for wasm/web compatibility
]

# Allow-list of words for markdown in dosctrings https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
doc-valid-idents = [
"GitHub",
"GLB",
"GLTF",
"iOS",
"macOS",
"NaN",
"OBJ",
"PyPI",
"sRGB",
"sRGBA",
"WebGL",
"WebSockets",
"..",
]
20 changes: 20 additions & 0 deletions scripts/clippy_wasm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# This scripts run clippy on the wasm32-unknown-unknown target,
# using a special clippy_wasm.toml config file which forbids a few more things.

set -eu
script_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$script_path/.."
set -x

mv clippy.toml clippy.toml.bak
cp clippy_wasm.toml clippy.toml

function cleanup()
{
mv clippy.toml.bak clippy.toml
}

trap cleanup EXIT

cargo cranky --all-features --target wasm32-unknown-unknown --target-dir target_wasm -p re_viewer -- --deny warnings

0 comments on commit 6207499

Please sign in to comment.