Skip to content

Pallet Pass

Pallet Pass #1

GitHub Actions / clippy failed Sep 26, 2024 in 1s

clippy

14 errors, 6 warnings

Details

Results

Message level Amount
Internal compiler error 0
Error 14
Warning 6
Note 0
Help 0

Versions

  • rustc 1.81.0 (eeb90cda1 2024-09-04)
  • cargo 1.81.0 (2dbb1af80 2024-08-20)
  • clippy 0.1.81 (eeb90cd 2024-09-04)

Annotations

Check failure on line 216 in pallets/pass/src/lib.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

mismatched types

error[E0308]: mismatched types
   --> pallets/pass/src/lib.rs:216:38
    |
216 |         let pass = T::Lookup::lookup(user)?;
    |                    ----------------- ^^^^ expected associated type, found `[u8; 32]`
    |                    |
    |                    arguments to this function are incorrect
    |
    = note: expected associated type `<<T as frame_system::Config>::Lookup as sp_runtime::traits::StaticLookup>::Source`
                         found array `[u8; 32]`
help: a method is available that returns `<<T as frame_system::Config>::Lookup as sp_runtime::traits::StaticLookup>::Source`
   --> /home/runner/.cargo/git/checkouts/polkadot-sdk-9b4d86516933931c/b788ee6/substrate/primitives/runtime/src/traits.rs:225:2
    |
225 |     fn unlookup(t: Self::Target) -> Self::Source;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ consider calling `sp_runtime::traits::StaticLookup::unlookup`
note: associated function defined here
   --> /home/runner/.cargo/git/checkouts/polkadot-sdk-9b4d86516933931c/b788ee6/substrate/primitives/runtime/src/traits.rs:223:5
    |
223 |     fn lookup(s: Self::Source) -> Result<Self::Target, LookupError>;
    |        ^^^^^^

Check failure on line 173 in pallets/pass/src/lib.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

`?` couldn't convert the error to `sp_runtime::DispatchError`

error[E0277]: `?` couldn't convert the error to `sp_runtime::DispatchError`
   --> pallets/pass/src/lib.rs:173:81
    |
173 |             let device = T::Authenticator::verify_device(&attestation).ok_or(())?;
    |                                                                                 ^ the trait `std::convert::From<()>` is not implemented for `sp_runtime::DispatchError`, which is required by `std::result::Result<_, _>: std::ops::FromResidual<std::result::Result<std::convert::Infallible, ()>>`
    |
    = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
    = help: the following other types implement trait `std::convert::From<T>`:
              `sp_runtime::DispatchError` implements `std::convert::From<&'static str>`
              `sp_runtime::DispatchError` implements `std::convert::From<frame_support::error::BadOrigin>`
              `sp_runtime::DispatchError` implements `std::convert::From<frame_support::error::LookupError>`
              `sp_runtime::DispatchError` implements `std::convert::From<frame_system::Error<T>>`
              `sp_runtime::DispatchError` implements `std::convert::From<pallet::Error<T, I>>`
              `sp_runtime::DispatchError` implements `std::convert::From<sp_runtime::ArithmeticError>`
              `sp_runtime::DispatchError` implements `std::convert::From<sp_runtime::TokenError>`
              `sp_runtime::DispatchError` implements `std::convert::From<sp_runtime::TransactionalError>`
    = note: required for `std::result::Result<(), sp_runtime::DispatchError>` to implement `std::ops::FromResidual<std::result::Result<std::convert::Infallible, ()>>`

Check failure on line 173 in pallets/pass/src/lib.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this function takes 2 arguments but 1 argument was supplied

error[E0061]: this function takes 2 arguments but 1 argument was supplied
   --> pallets/pass/src/lib.rs:173:26
    |
173 |             let device = T::Authenticator::verify_device(&attestation).ok_or(())?;
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------------ argument #1 of type `&<T as pallet::Config<I>>::Authenticator` is missing
    |
note: method defined here
   --> /home/runner/work/frame-contrib/frame-contrib/traits/authn/src/lib.rs:33:8
    |
33  |     fn verify_device(&self, attestation: &Self::DeviceAttestation) -> Option<Self::Device> {
    |        ^^^^^^^^^^^^^
help: provide the argument
    |
173 |             let device = T::Authenticator::verify_device(/* &<T as pallet::Config<I>>::Authenticator */, &attestation).ok_or(())?;
    |                                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Check failure on line 158 in pallets/pass/src/lib.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

mismatched types

error[E0308]: mismatched types
   --> pallets/pass/src/lib.rs:158:40
    |
158 |             Self::do_add_session(&who, &account_id, duration);
    |             --------------------       ^^^^^^^^^^^ expected `&<T as Config>::AccountId`, found `&Result<..., ...>`
    |             |
    |             arguments to this function are incorrect
    |
    = note: expected reference `&<T as frame_system::Config>::AccountId`
               found reference `&std::result::Result<<T as frame_system::Config>::AccountId, frame_support::error::LookupError>`
note: associated function defined here
   --> pallets/pass/src/lib.rs:264:19
    |
264 |     pub(crate) fn do_add_session(
    |                   ^^^^^^^^^^^^^^
265 |         session_key: &T::AccountId,
266 |         account_id: &T::AccountId,
    |         -------------------------

Check failure on line 156 in pallets/pass/src/lib.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

no method named `then_some` found for enum `std::option::Option` in the current scope

error[E0599]: no method named `then_some` found for enum `std::option::Option` in the current scope
   --> pallets/pass/src/lib.rs:156:45
    |
156 |             device.verify_user(&credential).then_some(()).ok_or();
    |                                             ^^^^^^^^^
    |
help: there is a method `is_some` with a similar name, but with different arguments
   --> /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/option.rs:609:5

Check failure on line 154 in pallets/pass/src/lib.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

the trait bound `&std::result::Result<<T as frame_system::Config>::AccountId, frame_support::error::LookupError>: parity_scale_codec::EncodeLike<<T as frame_system::Config>::AccountId>` is not satisfied

error[E0277]: the trait bound `&std::result::Result<<T as frame_system::Config>::AccountId, frame_support::error::LookupError>: parity_scale_codec::EncodeLike<<T as frame_system::Config>::AccountId>` is not satisfied
   --> pallets/pass/src/lib.rs:154:47
    |
154 |             let device = Devices::<T, I>::get(&account_id, &device_id)
    |                          -------------------- ^^^^^^^^^^^ the trait `parity_scale_codec::EncodeLike<<T as frame_system::Config>::AccountId>` is not implemented for `&std::result::Result<<T as frame_system::Config>::AccountId, frame_support::error::LookupError>`
    |                          |
    |                          required by a bound introduced by this call
    |
note: required by a bound in `frame_support::pallet_prelude::StorageDoubleMap::<Prefix, Hasher1, Key1, Hasher2, Key2, Value, QueryKind, OnEmpty, MaxValues>::get`
   --> /home/runner/.cargo/git/checkouts/polkadot-sdk-9b4d86516933931c/b788ee6/substrate/frame/support/src/storage/types/double_map.rs:240:10
    |
238 |     pub fn get<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> QueryKind::Query
    |            --- required by a bound in this associated function
239 |     where
240 |         KArg1: EncodeLike<Key1>,
    |                ^^^^^^^^^^^^^^^^ required by this bound in `StorageDoubleMap::<Prefix, Hasher1, Key1, Hasher2, Key2, Value, QueryKind, OnEmpty, MaxValues>::get`
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
    |
110 |     impl<T: Config<I>, I: 'static> Pallet<T, I> where &std::result::Result<<T as frame_system::Config>::AccountId, frame_support::error::LookupError>: parity_scale_codec::EncodeLike<<T as frame_system::Config>::AccountId> {
    |                                                 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Check failure on line 152 in pallets/pass/src/lib.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

the `?` operator can only be applied to values that implement `std::ops::Try`

error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try`
   --> pallets/pass/src/lib.rs:152:13
    |
152 |             Self::account_exists(&account_id)?;
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `?` operator cannot be applied to type `bool`
    |
    = help: the trait `std::ops::Try` is not implemented for `bool`

Check failure on line 152 in pallets/pass/src/lib.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

mismatched types

error[E0308]: mismatched types
   --> pallets/pass/src/lib.rs:152:34
    |
152 |             Self::account_exists(&account_id)?;
    |             -------------------- ^^^^^^^^^^^ expected `&<T as Config>::AccountId`, found `&Result<..., ...>`
    |             |
    |             arguments to this function are incorrect
    |
    = note: expected reference `&<T as frame_system::Config>::AccountId`
               found reference `&std::result::Result<<T as frame_system::Config>::AccountId, frame_support::error::LookupError>`
note: associated function defined here
   --> pallets/pass/src/lib.rs:220:19
    |
220 |     pub(crate) fn account_exists(who: &T::AccountId) -> bool {
    |                   ^^^^^^^^^^^^^^ ------------------

Check failure on line 151 in pallets/pass/src/lib.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

mismatched types

error[E0308]: mismatched types
   --> pallets/pass/src/lib.rs:151:48
    |
151 |             let account_id = T::Lookup::lookup(credential.user_id());
    |                              ----------------- ^^^^^^^^^^^^^^^^^^^^ expected associated type, found `[u8; 32]`
    |                              |
    |                              arguments to this function are incorrect
    |
    = note: expected associated type `<<T as frame_system::Config>::Lookup as sp_runtime::traits::StaticLookup>::Source`
                         found array `[u8; 32]`
    = help: consider constraining the associated type `<<T as frame_system::Config>::Lookup as sp_runtime::traits::StaticLookup>::Source` to `[u8; 32]`
    = note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
note: associated function defined here
   --> /home/runner/.cargo/git/checkouts/polkadot-sdk-9b4d86516933931c/b788ee6/substrate/primitives/runtime/src/traits.rs:223:5
    |
223 |     fn lookup(s: Self::Source) -> Result<Self::Target, LookupError>;
    |        ^^^^^^

Check failure on line 125 in pallets/pass/src/lib.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this function takes 2 arguments but 1 argument was supplied

error[E0061]: this function takes 2 arguments but 1 argument was supplied
   --> pallets/pass/src/lib.rs:125:26
    |
125 |             let device = T::Authenticator::verify_device(&attestation)
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------------ argument #1 of type `&<T as pallet::Config<I>>::Authenticator` is missing
    |
note: method defined here
   --> /home/runner/work/frame-contrib/frame-contrib/traits/authn/src/lib.rs:33:8
    |
33  |     fn verify_device(&self, attestation: &Self::DeviceAttestation) -> Option<Self::Device> {
    |        ^^^^^^^^^^^^^
help: provide the argument
    |
125 |             let device = T::Authenticator::verify_device(/* &<T as pallet::Config<I>>::Authenticator */, &attestation)
    |                                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Check failure on line 23 in pallets/pass/src/benchmarking.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

no variant or associated item named `Success` found for enum `pallet::Event` in the current scope

error[E0599]: no variant or associated item named `Success` found for enum `pallet::Event` in the current scope
  --> pallets/pass/src/benchmarking.rs:23:39
   |
23 |         assert_last_event::<T>(Event::Success.into());
   |                                       ^^^^^^^ variant or associated item not found in `Event<_, _>`
   |
  ::: pallets/pass/src/lib.rs:84:5
   |
84 |     pub enum Event<T: Config<I>, I: 'static = ()> {
   |     --------------------------------------------- variant or associated item `Success` not found for this enum

Check failure on line 23 in pallets/pass/src/benchmarking.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

function takes 2 generic arguments but 1 generic argument was supplied

error[E0107]: function takes 2 generic arguments but 1 generic argument was supplied
  --> pallets/pass/src/benchmarking.rs:23:9
   |
23 |         assert_last_event::<T>(Event::Success.into());
   |         ^^^^^^^^^^^^^^^^^   - supplied 1 generic argument
   |         |
   |         expected 2 generic arguments
   |
note: function defined here, with 2 generic parameters: `T`, `I`
  --> pallets/pass/src/benchmarking.rs:7:4
   |
7  | fn assert_last_event<T: Config<I>, I: 'static>(generic_event: <T as Config<I>>::RuntimeEvent) {
   |    ^^^^^^^^^^^^^^^^^ -             -
help: add missing generic argument
   |
23 |         assert_last_event::<T, I>(Event::Success.into());
   |                              +++

Check failure on line 11 in pallets/pass/src/benchmarking.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

this function takes 2 arguments but 0 arguments were supplied

error[E0061]: this function takes 2 arguments but 0 arguments were supplied
   --> pallets/pass/src/benchmarking.rs:11:1
    |
11  | #[benchmarks]
    | ^^^^^^^^^^^^^ two arguments of type `[u8; 32]` and `<<T as pallet::Config>::Authenticator as fc_traits_authn::Authenticator>::DeviceAttestation` are missing
    |
note: associated function defined here
   --> pallets/pass/src/lib.rs:113:16
    |
113 |         pub fn register(
    |                ^^^^^^^^
114 |             origin: OriginFor<T>,
115 |             user: HashedUserId,
    |             ------------------
116 |             attestation: DeviceAttestationOf<T, I>,
    |             --------------------------------------
    = note: this error originates in the attribute macro `benchmarks` (in Nightly builds, run with -Z macro-backtrace for more info)
help: provide the arguments
    |
11  | #[benchmarks](/* [u8; 32] */, /* <<T as pallet::Config>::Authenticator as fc_traits_authn::Authenticator>::DeviceAttestation */)
    |              +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Check warning on line 1 in pallets/template/src/benchmarking.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

duplicated attribute

warning: duplicated attribute
  --> pallets/template/src/benchmarking.rs:1:8
   |
1  | #![cfg(feature = "runtime-benchmarks")]
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: first defined here
  --> pallets/template/src/lib.rs:10:7
   |
10 | #[cfg(feature = "runtime-benchmarks")]
   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: remove this attribute
  --> pallets/template/src/benchmarking.rs:1:8
   |
1  | #![cfg(feature = "runtime-benchmarks")]
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#duplicated_attributes
   = note: `#[warn(clippy::duplicated_attributes)]` on by default

Check failure on line 20 in pallets/pass/src/benchmarking.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

failed to resolve: use of undeclared type `RawOrigin`

error[E0433]: failed to resolve: use of undeclared type `RawOrigin`
  --> pallets/pass/src/benchmarking.rs:20:11
   |
20 |         _(RawOrigin::Root);
   |           ^^^^^^^^^ use of undeclared type `RawOrigin`
   |
help: consider importing one of these enums
   |
13 +     use frame_support::dispatch::RawOrigin;
   |
13 +     use frame_system::RawOrigin;
   |

Check warning on line 32 in pallets/gas-transaction-payment/src/lib.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

using `map_err` over `inspect_err`

warning: using `map_err` over `inspect_err`
  --> pallets/gas-transaction-payment/src/lib.rs:32:15
   |
32 |     #[pallet::pallet]
   |               ^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_inspect
   = note: `#[warn(clippy::manual_inspect)]` on by default
help: try
   |
32 -     #[pallet::pallet]
32 +     #[pallet::&inspect_err]
   |

Check warning on line 120 in pallets/gas-transaction-payment/src/extensions.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

using `clone` on type `DispatchInfo` which implements the `Copy` trait

warning: using `clone` on type `DispatchInfo` which implements the `Copy` trait
   --> pallets/gas-transaction-payment/src/extensions.rs:120:22
    |
120 |                     &info.clone().into(),
    |                      ^^^^^^^^^^^^ help: try dereferencing it: `(*info)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
    = note: `#[warn(clippy::clone_on_copy)]` on by default

Check warning on line 120 in pallets/gas-transaction-payment/src/extensions.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

useless conversion to the same type: `frame_support::dispatch::DispatchInfo`

warning: useless conversion to the same type: `frame_support::dispatch::DispatchInfo`
   --> pallets/gas-transaction-payment/src/extensions.rs:120:22
    |
120 |                     &info.clone().into(),
    |                      ^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `info.clone()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
    = note: `#[warn(clippy::useless_conversion)]` on by default

Check warning on line 102 in pallets/gas-transaction-payment/src/extensions.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

redundant pattern matching, consider using `is_some()`

warning: redundant pattern matching, consider using `is_some()`
   --> pallets/gas-transaction-payment/src/extensions.rs:102:16
    |
102 |         if let Some(_) = T::GasBurner::check_available_gas(who, &info.weight) {
    |         -------^^^^^^^------------------------------------------------------- help: try: `if T::GasBurner::check_available_gas(who, &info.weight).is_some()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pattern_matching
    = note: `#[warn(clippy::redundant_pattern_matching)]` on by default

Check warning on line 98 in traits/memberships/src/lib.rs

See this annotation in the file changed.

@github-actions github-actions / clippy

`self.0.saturating_sub(n.get())` is never smaller than `Self::MIN.0` and has therefore no effect

warning: `self.0.saturating_sub(n.get())` is never smaller than `Self::MIN.0` and has therefore no effect
  --> traits/memberships/src/lib.rs:98:14
   |
98 |         Self(self.0.saturating_sub(n.get()).max(Self::MIN.0))
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `self.0.saturating_sub(n.get())`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_min_or_max
   = note: `#[warn(clippy::unnecessary_min_or_max)]` on by default