Showing 600 of 2,050 total issues
Function ApiCtxRoot
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
export function ApiCtxRoot ({ apiUrl, children, isElectron, store: keyringStore }: Props): React.ReactElement<Props> | null {
const { queuePayload, queueSetTxStatus } = useQueue();
const [state, setState] = useState<ApiState>(EMPTY_STATE);
const [isApiConnected, setIsApiConnected] = useState(false);
const [isApiInitialized, setIsApiInitialized] = useState(false);
- 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 _setExtrinsicHex
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
(hex: string): void => {
try {
assert(isHex(hex), 'Expected a hex-encoded call');
let extrinsicCall: Call;
Function useSortedTargetsImpl
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
function useSortedTargetsImpl (favorites: string[], withLedger: boolean): SortedTargets {
const { api } = useApi();
const { allAccounts } = useAccounts();
const { counterForNominators, counterForValidators, historyDepth, maxNominatorsCount, maxValidatorsCount, minNominatorBond, minValidatorBond, totalIssuance } = useCallMulti<MultiResult>([
api.query.staking.historyDepth,
Function useAbiImpl
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
function useAbiImpl (initialValue: [string | null | undefined, Abi | null | undefined] = [null, null], codeHash: string | null = null, isRequired = false): UseAbi {
const [state, setAbi] = useState<AbiState>(() => fromInitial(initialValue, isRequired));
useEffect(
() => setAbi((state) =>
Function useSortedTargetsImpl
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
function useSortedTargetsImpl (favorites: string[], withLedger: boolean): SortedTargets {
const { api } = useApi();
const { allAccounts } = useAccounts();
const { counterForNominators, counterForValidators, historyDepth, maxNominatorsCount, maxValidatorsCount, minNominatorBond, minValidatorBond, totalIssuance } = useCallMulti<MultiResult>([
api.query.staking.historyDepth,
Function createErasString
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function createErasString (eras: BN[]): React.ReactNode {
if (!eras.length) {
return '';
}
Function NewStash
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
function NewStash (): React.ReactElement {
const { t } = useTranslation();
const [isVisible, toggleVisible] = useToggle();
const [{ bondTx, stashId }, setBondInfo] = useState<BondInfo>({});
Function createErasString
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function createErasString (eras: BN[]): React.ReactNode {
if (!eras.length) {
return '';
}
Function NewStash
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
function NewStash (): React.ReactElement {
const { t } = useTranslation();
const [isVisible, toggleVisible] = useToggle();
const [{ bondTx, stashId }, setBondInfo] = useState<BondInfo>({});
Function mergeStatus
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function mergeStatus (status: ActionStatusPartial[]): ActionStatus[] {
let others: ActionStatus | null = null;
const initial = status
.reduce((result: StatusCount[], status): StatusCount[] => {
Function useOwnStashInfosImpl
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function useOwnStashInfosImpl (): StakerState[] | undefined {
const { api } = useApi();
const { allAccounts } = useAccounts();
const mountedRef = useIsMountedRef();
const ownStashes = useOwnStashes();
Function groupLocks
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function groupLocks (t: (key: string, options?: { replace: Record<string, unknown> }) => string, bestNumber: BN, locks: Partial<DeriveDemocracyLock>[] = []): State {
return {
maxBalance: bnMax(...locks.map(({ balance }) => balance).filter((b): b is Balance => !!b)),
sorted: locks
.map((info): [Partial<DeriveDemocracyLock>, BN] => [info, info.unlockAt && info.unlockAt.gt(bestNumber) ? info.unlockAt.sub(bestNumber) : BN_ZERO])
Function Account
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function Account ({ allSlashes, className = '', info: { controllerId, destination, hexSessionIdNext, hexSessionIdQueue, isLoading, isOwnController, isOwnStash, isStashNominating, isStashValidating, nominating, sessionIds, stakingLedger, stashId }, isDisabled, minCommission, targets }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const { api } = useApi();
const { queueExtrinsic } = useQueue();
const [isBondExtraOpen, toggleBondExtra] = useToggle();
- 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 Account
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function Account ({ allSlashes, className = '', info: { controllerId, destination, hexSessionIdNext, hexSessionIdQueue, isLoading, isOwnController, isOwnStash, isStashNominating, isStashValidating, nominating, sessionIds, stakingLedger, stashId }, isDisabled, minCommission, targets }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const { api } = useApi();
const { queueExtrinsic } = useQueue();
const [isBondExtraOpen, toggleBondExtra] = useToggle();
- 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 calcBlockTime
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export function calcBlockTime (blockTime: BN, blocks: BN, t: (key: string, options?: { replace: Record<string, unknown> }) => string): Result {
// in the case of excessively large locks, limit to the max JS integer value
const value = bnMin(BN_MAX_INTEGER, blockTime.mul(blocks)).toNumber();
// time calculations are using the absolute value (< 0 detection only on strings)
- 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 toAddress
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export function toAddress (value?: string | Uint8Array | null, allowIndices = false, bytesLength?: 20 | 32): string | undefined {
if (value) {
try {
const u8a = isHex(value)
? hexToU8a(value)
- 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 curveThreshold
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function curveThreshold (curve: PalletReferendaCurve, input: BN, div: BN): BN {
// if divisor is zero, we return the max
if (div.isZero()) {
return BN_BILLION;
}
Function approxChanges
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function approxChanges (threshold: VoteThreshold, sqrtElectorate: BN, state: ApproxState): Approx {
const isPassing = calcPassing(threshold, sqrtElectorate, state);
// simple case, we have an aye > nay to determine passing
if (threshold.isSimpleMajority) {
Function setAccounts
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public setAccounts (accounts: [string, AccountOverrides][]): void {
this.useAccounts = {
allAccounts: accounts.map(([address]) => address),
allAccountsHex: [],
areAccountsLoaded: true,
Function getBytesParams
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getBytesParams (interimResult: PreimageStatus, someOptStatus: Option<PalletPreimageRequestStatus>): BytesParams {
const result = objectSpread<PreimageStatus>({}, interimResult, {
status: someOptStatus.unwrapOr(null)
});