Showing 600 of 2,050 total issues
Consider simplifying this complex logical expression. Open
Open
if (value && currentPeriod) {
active = value.filter(({ firstSlot, isCapped, isEnded, isWinner }) =>
!(isCapped || isEnded || isWinner) &&
currentPeriod.lte(firstSlot)
);
Consider simplifying this complex logical expression. Open
Open
} else if (isFunction(api.query.identity?.identityOf)) {
isVisible = !!identity && (!!identity.display || !!identity.displayParent) && (
hasAddressMatch ||
(!!identity.display && identity.display.toLowerCase().includes(filterLower)) ||
(!!identity.displayParent && identity.displayParent.toLowerCase().includes(filterLower))
Consider simplifying this complex logical expression. Open
Open
if (balances && balances.accountId?.eq(fromId) && fromId && toId && api.call.transactionPaymentApi && api.tx.balances) {
nextTick(async (): Promise<void> => {
try {
const extrinsic = (api.tx.balances.transferAllowDeath || api.tx.balances.transfer)(toId, balances.availableBalance);
const { partialFee } = await extrinsic.paymentInfo(fromId);
Function createStakingInfo
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function createStakingInfo (bestNumber: BlockNumber, blockTime: BN, sessionInfo: DeriveSessionProgress, unapplied: SlashEntry[], slashDeferDuration?: BlockNumber): [EntryType, EntryInfo[]][] {
const blocksEra = sessionInfo.eraLength.sub(sessionInfo.eraProgress);
const blocksSes = sessionInfo.sessionLength.sub(sessionInfo.sessionProgress);
const slashDuration = slashDeferDuration?.mul(sessionInfo.eraLength);
const slashEras = slashDuration
Function extractExternal
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function extractExternal (accountId: string | null): AddressFlags {
if (!accountId) {
return NO_FLAGS;
}
Function getStats
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function getStats (...apis: ApiPromise[]): { stats: ProviderStats, when: number } {
const stats: ProviderStats = {
active: {
requests: 0,
subscriptions: 0
Function getPreimageHash
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function getPreimageHash (api: ApiPromise, hashOrBounded: Hash | HexString | FrameSupportPreimagesBounded): StatusParams {
let proposalHash: HexString | undefined;
let inlineData: Uint8Array | undefined;
if (isString(hashOrBounded)) {
Function createResult
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function createResult (interimResult: PreimageStatus, optBytes: Option<Bytes> | Uint8Array): Preimage {
const callData = isU8a(optBytes)
? optBytes
: optBytes.unwrapOr(null);
let proposal: Call | null = null;
Function needsApiCheck
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function needsApiCheck (api: ApiPromise): boolean {
try {
// we need a known Exposure type
const { nominatorCount, own, pageCount, total } = api.registry.createType<SpStakingPagedExposureMetadata>(
unwrapStorageType(api.registry, api.query.staking.erasStakersOverview.creator.meta.type),
Function useWeightImpl
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function useWeightImpl (call?: Call | null): Result {
const { api } = useApi();
const mountedRef = useIsMountedRef();
const [state, setState] = useState<Result>(() => objectSpread({
// eslint-disable-next-line @typescript-eslint/unbound-method
Function createOptions
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function createOptions (api: ApiPromise, rpcs: Record<string, Record<string, DefinitionRpcExt>>, sectionName: string): DropdownOptions {
const section = rpcs[sectionName];
if (!section || Object.keys((api.rpc as unknown as Record<string, Record<string, unknown>>)[sectionName]).length === 0) {
return [];
Function groupAccounts
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function groupAccounts (accounts: SortedAccount[]): Record<GroupName, string[]> {
const ret: Record<GroupName, string[]> = {
accounts: [],
chopsticks: [],
hardware: [],
Function updateAddress
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function updateAddress (seed: string, derivePath: string, seedType: SeedType, pairType: PairType): AddressState {
let address: string | null = null;
let deriveValidation: DeriveValidationOutput = deriveValidate(seed, seedType, derivePath, pairType);
let isSeedValid = false;
Function draw
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export default function draw (ctx: CanvasRenderingContext2D, accountId: AccountId): void {
console.log(`Generating ink for ${accountId.toString()} as ${accountId.toHex()}`);
const bits = addressToBits(accountId.toU8a());
Function TupleDisplay
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function TupleDisplay (props: Props): React.ReactElement<Props> {
const { className = '', defaultValue, isDisabled, label, onChange, overrides, registry, type, withLabel } = props;
const params = useParamDefs(registry, type);
const [values] = useState<RawParam[]>(() => getInitialValues(defaultValue));
Function expandOngoing
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function expandOngoing (api: ApiPromise, info: Referendum['info'], track?: PalletReferendaTrackInfo): Expanded {
const ongoing = info.asOngoing;
const proposalHash = getPreimageHash(api, ongoing.proposal || (ongoing as unknown as { proposalHash: Hash }).proposalHash).proposalHash;
let prepareEnd: BN | null = null;
let decideEnd: BN | null = null;
Function DispatchResultDisplay
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function DispatchResultDisplay (props: Props): React.ReactElement<Props> {
const { defaultValue, isDisabled, label } = props;
const dispatchError = useMemo(
() => defaultValue && isDispatchResultErr(defaultValue.value)
? { isValid: true, value: defaultValue.value.asErr }
Function Account
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function Account (props: Props): React.ReactElement<Props> {
const { className = '', defaultValue: { value }, isDisabled, isError, label, onChange, type, withLabel } = props;
const [defaultValue] = useState(() => (value as string)?.toString());
const _onChange = useCallback(
Function calcBlockTime
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
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)
Function getBountyStatus
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const getBountyStatus = (status: BountyStatus): BountyStatusType => {
const statusAsString = status.type as StatusName;
let result: BountyStatusType = {
beneficiary: undefined,