Skip to content

Commit

Permalink
Merge pull request #487 from asomers/seven_args
Browse files Browse the repository at this point in the history
Suppress clippy::too_many_arguments warnings in the generated code
  • Loading branch information
asomers committed May 26, 2023
2 parents 7aba6d3 + 5a44d9c commit 671abc7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
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

0 comments on commit 671abc7

Please sign in to comment.