Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

ci: Add more clippy & dependency checks #3896

Merged
merged 5 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
22 changes: 21 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,27 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: clippy
args: --workspace --all-targets --verbose -- --deny warnings
args: --workspace --all-targets --verbose -- --deny warnings -W clippy::cargo -W clippy::dbg_macro -A clippy::cargo_common_metadata

check-dependencies:
name: Check Dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout PR Branch
uses: actions/checkout@v3
with:
submodules: false
- name: Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "dependencies"
- name: Install toolchain
run: rustup toolchain install nightly
- name: Install udeps
run: cargo install cargo-udeps --locked
- name: Run udeps
run: cargo +nightly udeps


test:
strategy:
Expand Down
24 changes: 22 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,32 @@ jobs:
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --workspace --all-targets --verbose -- --deny warnings
args: --workspace --all-targets --all-features --verbose -- --deny warnings -W clippy::cargo -W clippy::dbg_macro -A clippy::cargo_common_metadata
- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check
args: --workspace --all-targets --release
args: --workspace --all-targets --all-features --release

check-dependencies:
name: Check Dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout PR Branch
uses: actions/checkout@v3
with:
submodules: false
- name: Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "dependencies"
- name: Install toolchain
run: rustup toolchain install nightly
- name: Install udeps
run: cargo install cargo-udeps --locked
- name: Run udeps
run: cargo +nightly udeps


test:
name: Test
Expand Down
119 changes: 63 additions & 56 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
allow-dbg-in-tests = true
14 changes: 7 additions & 7 deletions crates/rome_js_formatter/src/utils/binary_like_expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
//! In the example, this only is the `|| happy`.
//!
//! Thus, the first group is: `[Left(some && thing && elsewhere), Right(|| happy)]`. The formatting formats the left side
//! as is (the call will recurse into the [JsAnyBinaryLikeExpression] formatting again) but formats the operator with the right side.
//! as is (the call will recurse into the [AnyJsBinaryLikeExpression] formatting again) but formats the operator with the right side.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some random doc fixes ;)

//!
//! Now, let's see how the implementation groups the `some && thing && elsewhere`. It first traverses to the left most binary like expression,
//! which is `some && thing`. It then adds this as a `Left` side to the group. From here, the algorithm traverses upwards and adds all right sides
Expand Down Expand Up @@ -167,7 +167,7 @@ impl Format<JsFormatContext> for AnyJsBinaryLikeExpression {

/// Creates a [BinaryLeftOrRightSide::Left] for the first left hand side that:
/// * isn't a [JsBinaryLikeExpression]
/// * is a [JsBinaryLikeExpression] but it should be formatted as its own group (see [JsAnyBinaryLikeExpression::can_flatten]).
/// * is a [JsBinaryLikeExpression] but it should be formatted as its own group (see [AnyJsBinaryLikeExpression::can_flatten]).
///
/// It then traverses upwards from the left most node and creates [BinaryLikeLeftOrRightSide::Right]s for
/// every [JsBinaryLikeExpression] until it reaches the root again.
Expand Down Expand Up @@ -569,7 +569,7 @@ impl NeedsParentheses for AnyJsBinaryLikeExpression {
}
}

/// Implements the rules when a node needs parentheses that are common across all [JsAnyBinaryLikeExpression] nodes.
/// Implements the rules when a node needs parentheses that are common across all [AnyJsBinaryLikeExpression] nodes.
pub(crate) fn needs_binary_like_parentheses(
node: &AnyJsBinaryLikeExpression,
parent: &JsSyntaxNode,
Expand Down Expand Up @@ -642,7 +642,7 @@ pub(crate) fn needs_binary_like_parentheses(
}

declare_node_union! {
/// Union type for any valid left hand side of a [JsAnyBinaryLikeExpression].
/// Union type for any valid left hand side of a [AnyJsBinaryLikeExpression].
pub(crate) AnyJsBinaryLikeLeftExpression = AnyJsExpression | JsPrivateName
}

Expand Down Expand Up @@ -771,8 +771,8 @@ enum VisitEvent {
Exit(AnyJsBinaryLikeExpression),
}

/// Iterator that visits [JsAnyBinaryLikeExpression]s in pre-order.
/// This is similar to [JsSyntaxNode::descendants] but it only traverses into [JsAnyBinaryLikeExpression] and their left side
/// Iterator that visits [AnyJsBinaryLikeExpression]s in pre-order.
/// This is similar to [JsSyntaxNode::descendants] but it only traverses into [AnyJsBinaryLikeExpression] and their left side
/// (the right side is never visited).
///
/// # Examples
Expand Down Expand Up @@ -805,7 +805,7 @@ enum VisitEvent {
///
/// Notice how the iterator doesn't yield events for the terminal identifiers `a`, `b`, `c`, `d`, and `e`,
/// nor for the right hand side expression `d && e`. This is because the visitor only traverses into
/// [JsAnyBinaryLikeExpression]s and of those, only along the left side.
/// [AnyJsBinaryLikeExpression]s and of those, only along the left side.
struct BinaryLikePreorder {
/// The next node to visit or [None] if the iterator passed the start node (is at its end).
next: Option<VisitEvent>,
Expand Down
4 changes: 2 additions & 2 deletions crates/rome_js_syntax/src/expr_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -821,14 +821,14 @@ impl JsCallExpression {
is_optional_chain(self.clone().into())
}

/// Get [JsAnyCallArgument] by it index inside the [JsCallExpression] argument list.
/// Get [AnyJsCallArgument] by it index inside the [JsCallExpression] argument list.
///
/// Each index inside "indices" should be unique.
/// "indices" must be sorted.
///
/// Supports maximum of 16 indices to avoid stack overflow. Eeach argument will consume:
///
/// - 8 bytes for the [Option<JsAnyCallArgument>] result;
/// - 8 bytes for the [Option<AnyJsCallArgument>] result;
/// - 8 bytes for the [usize] argument.
pub fn get_arguments_by_index<const N: usize>(
&self,
Expand Down
2 changes: 1 addition & 1 deletion crates/rome_js_syntax/src/union_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl AnyJsClassMember {
}
}

/// Tests if the member has a [JsLiteralMemberName] of `name`.
/// Tests if the member has a [`JsLiteralMemberName`](rome_js_syntax::JsLiteralMemberName) of `name`.
pub fn has_name(&self, name: &str) -> SyntaxResult<bool> {
match self.name()? {
Some(AnyJsClassMemberName::JsLiteralMemberName(literal)) => {
Expand Down
2 changes: 1 addition & 1 deletion xtask/bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ rome_js_analyze = { path = "../../crates/rome_js_analyze"}

pico-args = { version = "0.5.0", features=["eq-separator"] }
timing = "0.2.3"
criterion = "0.3.5"
criterion = "0.4.0"
regex = "1.5.5"
ureq = "2.4.0"
url = "2.2.2"
Expand Down
Loading