Showing 179 of 2,612 total issues
Function extendPrefixedMap
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function extendPrefixedMap (registry: Registry, itemFn: CreateItemFn, storageFn: StorageEntry): StorageEntry {
const { meta: { type }, method, section } = itemFn;
storageFn.iterKey = extendHeadMeta(registry, itemFn, storageFn, (...args: unknown[]): Raw => {
if (args.length && (type.isPlain || (args.length >= type.asMap.hashers.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 generateInterfaceTypes
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function generateInterfaceTypes (importDefinitions: Record<string, Record<string, ModuleTypes>>, dest: string): void {
const registry = new TypeRegistry();
writeFile(dest, (): string => {
Object.entries(importDefinitions).reduce((acc, def) => Object.assign(acc, def), {});
Function entrySignature
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function entrySignature (lookup: PortableRegistry, allDefs: Record<string, ModuleTypes>, registry: Registry, section: string, storageEntry: StorageEntryMetadataLatest, imports: TypeImports): [boolean, string, string, string] {
try {
const outputType = lookup.getTypeDef(unwrapStorageSi(storageEntry.type));
if (storageEntry.type.isPlain) {
Function sections
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
.reduce((all: Section[], _sectionName): Section[] => {
const section = definitions[_sectionName as 'babe'];
Object
.keys(section.rpc || {})
Function keys
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
const keys = named.map((def): string => {
const { info, lookupName, name = '', sub, type } = def;
const getter = stringPascalCase(name.replace(' ', '_'));
const isComplex = [TypeDefInfo.Option, TypeDefInfo.Range, TypeDefInfo.RangeInclusive, TypeDefInfo.Result, TypeDefInfo.Struct, TypeDefInfo.Tuple, TypeDefInfo.Vec, TypeDefInfo.VecFixed].includes(info);
Function _decodeFixedVec
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _decodeFixedVec (value: TypeDef, type: string, _: string, count: number): TypeDef {
const max = type.length - 1;
let index = -1;
let inner = 0;
Function getStashInfo
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function getStashInfo (api: DeriveApi, stashIds: AccountId[], activeEra: EraIndex, { withClaimedRewardsEras, withController, withDestination, withExposure, withExposureErasStakersLegacy, withExposureMeta, withLedger, withNominations, withPrefs }: StakingQueryFlags, page: u32 | AnyNumber): Observable<[(Option<AccountId> | null)[], Option<PalletStakingNominations>[], Option<PalletStakingRewardDestination>[], PalletStakingValidatorPrefs[], Option<SpStakingExposurePage>[], Option<SpStakingPagedExposureMetadata>[], number[][], SpStakingExposure[]]> {
const emptyNoms = api.registry.createType<Option<PalletStakingNominations>>('Option<Nominations>');
const emptyRewa = api.registry.createType<Option<PalletStakingRewardDestination>>('RewardDestination');
const emptyExpoEraStakers = api.registry.createType<SpStakingExposure>('Exposure');
const emptyPrefs = api.registry.createType<PalletStakingValidatorPrefs>('ValidatorPrefs');
- 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 _membersCurr
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _membersCurr (api: DeriveApi, accountIds: AccountId[]): Observable<DeriveSocietyMember[]> {
return combineLatest([
of(accountIds),
api.query.society.members.multi(accountIds),
api.query.society.payouts.multi(accountIds),
Function setImports
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function setImports (allDefs: Record<string, ModuleTypes>, imports: TypeImports, types: (string | null | undefined)[]): void {
const { codecTypes, extrinsicTypes, genericTypes, ignoredTypes, localTypes, metadataTypes, primitiveTypes, typesTypes } = imports;
types.filter((t): t is string => !!t).forEach((type): void => {
if (ignoredTypes.includes(type)) {
Function findSiType
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function findSiType (registry: Registry, type: string): PortableType | undefined {
let portable = findSiPrimitive(registry, type);
// some types are either Sequence or Arrays, cater for these
// specifically (these all come from the base substrate known keys)
Function parseDetails
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
function parseDetails (api: DeriveApi, stashId: AccountId, controllerIdOpt: Option<AccountId> | null, nominatorsOpt: Option<PalletStakingNominations>, rewardDestinationOpts: Option<PalletStakingRewardDestination> | PalletStakingRewardDestination, validatorPrefs: PalletStakingValidatorPrefs, exposure: Option<SpStakingExposurePage>, stakingLedgerOpt: Option<PalletStakingStakingLedger>, exposureMeta: Option<SpStakingPagedExposureMetadata>, claimedRewards: number[], exposureEraStakers: SpStakingExposure): DeriveStakingQuery {
Function getDefs
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getDefs (apis: Apis | null, defs: Record<string, Definitions>): Record<string, Record<string, DefinitionCallNamed>> {
const named: Record<string, Record<string, DefinitionCallNamed>> = {};
const all = Object.values(defs);
for (let j = 0, jcount = all.length; j < jcount; j++) {
Function sections
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
.reduce((all: Section[], _sectionName): Section[] => {
Object
.entries(definitions[_sectionName as 'babe'].runtime || {})
.forEach(([apiName, versions]) => {
versions
Function mainPromise
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function mainPromise (): Promise<void> {
const { endpoint, output, package: pkg, strict: isStrict } = yargs(hideBin(process.argv)).strict().options({
endpoint: {
description: 'The endpoint to connect to (e.g. wss://kusama-rpc.polkadot.io) or relative path to a file containing the JSON output of an RPC state_getMetadata call',
required: true,
Function renderPage
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function renderPage (page: Page): string {
let md = `---\ntitle: ${page.title}\n---\n\n`;
if (page.description) {
md += `${page.description}\n\n`;
Function getFakeChain
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getFakeChain (spec: string, callback: Sc.JsonRpcCallback): MockChain {
const _receivedRequests: string[] = [];
let _isTerminated = false;
let terminateInterceptor = Function.prototype;
Function generateLookupTypes
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function generateLookupTypes (registry: Registry, filtered: [PortableType, TypeDef][], destDir: string, subPath?: string): void {
const imports = {
...createImports(
{ '@polkadot/types/interfaces': defaultDefinitions },
{ types: {} }
Function queryScheduler
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function queryScheduler (api: DeriveApi): Observable<DeriveDispatch[]> {
return schedulerEntries(api).pipe(
switchMap(([blockNumbers, agendas]): Observable<[SchedulerInfo[], (DeriveProposalImage | undefined)[]]> => {
const result: SchedulerInfo[] = [];
Function mainPromise
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
async function mainPromise (): Promise<void> {
const { endpoint, input, package: pkg } = yargs(hideBin(process.argv)).strict().options({
endpoint: {
description: 'The endpoint to connect to (e.g. wss://kusama-rpc.polkadot.io) or relative path to a file containing the JSON output of an RPC state_getMetadata call',
type: 'string'
- 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 entrySignature
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function entrySignature (lookup: PortableRegistry, allDefs: Record<string, ModuleTypes>, registry: Registry, section: string, storageEntry: StorageEntryMetadataLatest, imports: TypeImports): [boolean, string, string, string] {
try {
const outputType = lookup.getTypeDef(unwrapStorageSi(storageEntry.type));
if (storageEntry.type.isPlain) {
- 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"