Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress clippy::too_many_arguments warnings in the generated code #487

Merged
merged 1 commit into from
May 26, 2023
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
version 2.0.9 and later.
([#485](https://github.com/asomers/mockall/pull/485))

- Suppress `clippy::too_many_arguments` warnings in the generated code. This
is most useful when mocking static functions with exactly 7 arguments.
([#487](https://github.com/asomers/mockall/pull/487))

### Removed

- Removed syntax deprecated since 0.9.0: using `#[automock]` directly on an
Expand Down
4 changes: 4 additions & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# I use a lot of dumb names in the tests
disallowed-names = []

# Default is 7. Lock it there, so a change to the default value doesn't break
# the automock_seven_args test.
too-many-arguments-threshold = 7
22 changes: 22 additions & 0 deletions mockall/tests/automock_seven_args.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// vim: tw=80
//! When mocking static functions just at the threshold of Clippy's type
//! complexity limit, no warnings should be emitted regarding the generated
//! code.
#![deny(warnings)]

use mockall::automock;

#[automock]
trait ManyArgs {
fn foo(_a0: u8, _a1: u8, _a2: u8, _a3: u8, _a4: u8, _a5: u8, _a6: u8);
}

#[test]
fn static_method_returning() {
let ctx = MockManyArgs::foo_context();
ctx.expect()
.returning(|_, _, _, _, _, _, _| ());
MockManyArgs::foo(0, 0, 0, 0, 0, 0, 0);
}


1 change: 1 addition & 0 deletions mockall_derive/src/mock_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@ impl MockFunction {
quote!(
#(#attrs)*
#[allow(missing_docs)]
#[allow(clippy::too_many_arguments)]
pub mod #inner_mod_ident {
use super::*;
use ::mockall::CaseTreeExt;
Expand Down