View on GitHub


1 hr
Test Coverage

Function parseDetails has 7 arguments (exceeds 4 allowed). Consider refactoring.

function parseDetails (stashId: AccountId, controllerIdOpt: Option<AccountId> | null, nominatorsOpt: Option<PalletStakingNominations>, rewardDestination: PalletStakingRewardDestination, validatorPrefs: PalletStakingValidatorPrefs, exposure: PalletStakingExposure, stakingLedgerOpt: Option<PalletStakingStakingLedger>): DeriveStakingQuery {
Severity: Major
Found in packages/api-derive/src/staking/query.ts - About 50 mins to fix

    Function getStashInfo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

    function getStashInfo (api: ApiInterfaceRx, stashIds: AccountId[], activeEra: EraIndex, { withController, withDestination, withExposure, withLedger, withNominations, withPrefs }: StakingQueryFlags): Observable<[(Option<AccountId> | null)[], Option<PalletStakingNominations>[], PalletStakingRewardDestination[], PalletStakingValidatorPrefs[], PalletStakingExposure[]]> {
      const emptyNoms = api.registry.createType<Option<PalletStakingNominations>>('Option<Nominations>');
      const emptyRewa = api.registry.createType<PalletStakingRewardDestination>('RewardDestination');
      const emptyExpo = api.registry.createType<PalletStakingExposure>('Exposure');
      const emptyPrefs = api.registry.createType<PalletStakingValidatorPrefs>('ValidatorPrefs');
    Severity: Minor
    Found in packages/api-derive/src/staking/query.ts - About 25 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    There are no issues that match your filters.