Showing 600 of 2,052 total issues
File index.tsx
has 263 lines of code (exceeds 250 allowed). Consider refactoring. Open
// Copyright 2017-2024 @polkadot/app-staking authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { DeriveStakerReward } from '@polkadot/api-derive/types';
import type { OwnPool } from '@polkadot/app-staking2/Pools/types';
File index.tsx
has 263 lines of code (exceeds 250 allowed). Consider refactoring. Open
// Copyright 2017-2024 @polkadot/app-staking authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { DeriveStakerReward } from '@polkadot/api-derive/types';
import type { OwnPool } from '@polkadot/app-staking2/Pools/types';
File index.tsx
has 262 lines of code (exceeds 250 allowed). Consider refactoring. Open
// Copyright 2017-2024 @polkadot/app-poll authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Approvals, Balance, BlockNumber } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
Function getChartResult
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getChartResult (totalEligible: BN, isConvictionVote: boolean, info: PalletReferendaReferendumInfoConvictionVotingTally | PalletReferendaReferendumInfoRankedCollectiveTally, track: PalletReferendaTrackInfo, trackGraph: CurveGraph): ChartResultExt[] | null {
if (totalEligible && isConvictionVote && info.isOngoing) {
const ongoing = info.asOngoing;
if (ongoing.deciding.isSome) {
Function Deploy
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
function Deploy ({ codeHash, constructorIndex = 0, onClose, setConstructorIndex }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const { api } = useApi();
const [initTx, setInitTx] = useState<SubmittableExtrinsic<'promise'> | null>(null);
const [accountId, isAccountIdValid, setAccountId] = useFormField<string | null>(null);
- Read upRead up
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
Function extractInfo
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
function extractInfo (info: PalletReferendaReferendumInfoConvictionVotingTally | PalletReferendaReferendumInfoRankedCollectiveTally, track?: PalletReferendaTrackInfo): { confirmEnd: BN | null, enactAt: { at: boolean, blocks: BN, end: BN | null } | null, nextAlarm: null | BN, submittedIn: null | BN } {
let confirmEnd: BN | null = null;
let enactAt: { at: boolean, blocks: BN, end: BN | null } | null = null;
let nextAlarm: BN | null = null;
let submittedIn: BN | null = null;
- Read upRead up
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
Function curveDelay
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
export function curveDelay (curve: PalletReferendaCurve, input: BN, div: BN): BN {
try {
// if divisor is zero, we return the max
if (div.isZero()) {
return BN_BILLION;
- Read upRead up
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
Function findComponent
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
export default function findComponent (registry: Registry, def: TypeDef, overrides: ComponentMap = {}): React.ComponentType<Props> {
// Explicit/special handling for Account20/32 types where they don't match
// the actual chain we are connected to
if (['AccountId20', 'AccountId32'].includes(def.type)) {
const defType = `AccountId${registry.createType('AccountId').length}`;
- Read upRead up
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
Function valueToText
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
export default function valueToText (type: string, value: Codec | undefined | null): React.ReactNode {
if (isNull(value) || isUndefined(value)) {
const { cName, key, values } = div({}, '<unknown>');
return (
- Read upRead up
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
Function InputNumber
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
function InputNumber ({ autoFocus, bitLength = DEFAULT_BITLENGTH, children, className = '', defaultValue, isDecimal, isDisabled, isError = false, isFull, isLoading, isSi, isSigned = false, isWarning, isZeroable = true, label, labelExtra, maxLength, maxValue, onChange, onEnter, onEscape, placeholder, siDecimals, siDefault, siSymbol, value: propsValue }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const { api } = useApi();
const [si] = useState<SiDef | null>(() =>
isSi
- Read upRead up
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
Function getLocks
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getLocks (api: ApiPromise, palletVote: PalletVote, votes: [classId: BN, refIds: BN[], casting: PalletConvictionVotingVoteCasting][], referenda: [BN, PalletReferendaReferendumInfoConvictionVotingTally][]): Lock[] {
const lockPeriod = api.consts[palletVote].voteLockingPeriod as BN;
const locks: Lock[] = [];
for (let i = 0, voteCount = votes.length; i < voteCount; i++) {
File index.tsx
has 259 lines of code (exceeds 250 allowed). Consider refactoring. Open
// Copyright 2017-2024 @polkadot/react-components authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { IconName } from '@fortawesome/fontawesome-svg-core';
import type { QueueStatus, QueueTx, QueueTxStatus } from './types.js';
Function useScheduledImpl
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
function useScheduledImpl (): EntryInfoTyped[] {
const { api } = useApi();
const blockTime = useBlockInterval();
const bestNumber = useBestNumber();
const leaseRangeMax = useLeaseRangeMax();
File index.tsx
has 257 lines of code (exceeds 250 allowed). Consider refactoring. Open
// Copyright 2017-2024 @polkadot/app-settings authors & contributors
// SPDX-License-Identifier: Apache-2.0
import FileSaver from 'file-saver';
import React, { useCallback, useEffect, useState } from 'react';
Function extractEvents
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
function extractEvents (result?: SubmittableResult): ActionStatus[] {
return mergeStatus(
(result?.events || [])
// filter events handled globally, or those we are not interested in, these are
// handled by the global overview, so don't add them here
Function useOwnEraRewardsImpl
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
function useOwnEraRewardsImpl (maxEras?: number, ownValidators?: StakerState[], additional?: string[]): State {
const { api } = useApi();
const mountedRef = useIsMountedRef();
const stashIds = useOwnStashIds(additional);
const allEras = useCall<EraIndex[]>(api.derive.staking?.erasHistoric);
Function loadOnReady
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function loadOnReady (api: ApiPromise, endpoint: LinkOption | null, fork: Blockchain | null, injectedPromise: Promise<InjectedExtension[]>, store: KeyringStore | undefined, types: Record<string, Record<string, string>>, urlIsEthereum = false): Promise<ApiState> {
statics.registry.register(types);
const { injectedAccounts, properties, systemChain, systemChainType, systemName, systemVersion } = await retrieve(api, injectedPromise);
const chainSS58 = properties.ss58Format.unwrapOr(DEFAULT_SS58).toNumber();
File Queue.tsx
has 256 lines of code (exceeds 250 allowed). Consider refactoring. Open
// Copyright 2017-2024 @polkadot/react-hooks authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { SubmittableResult } from '@polkadot/api';
import type { SubmittableExtrinsic } from '@polkadot/api/promise/types';
Function useTreasuryImpl
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
function useTreasuryImpl (): Result {
const { api } = useApi();
const [result, setResult] = useState<Result>(() => ({
pendingBounties: BN_ZERO,
pendingProposals: BN_ZERO,
Function Upload
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
function Upload ({ onClose }: Props): React.ReactElement {
const { t } = useTranslation();
const { api } = useApi();
const [accountId, setAccountId] = useAccountId();
const [step, nextStep, prevStep] = useStepper();
- Read upRead up
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"