Showing 173 of 2,509 total issues
Function createValue
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function createValue (registry: Registry, type: string, value: unknown, asArray = true): Option<Codec> {
// We detect codec here as well - when found, generally this is constructed from itself
if (value && isFunction((value as Option<Codec>).unwrapOrDefault)) {
return value as Option<Codec>;
}
- 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 _decodeFixedVec
has a Cognitive Complexity of 9 (exceeds 5 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;
- 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 generateForMeta
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function generateForMeta (registry: Registry, meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean, customLookupDefinitions?: Definitions): void {
Avoid deeply nested control flow statements. Open
if (Array.isArray(subDef)) {
const subs = subDef.map(({ type }) => getSimilarTypes(registry, definitions, type, imports).join(' | '));
possibleTypes.push(`[${subs.join(', ')}]`);
}
Avoid deeply nested control flow statements. Open
if (!skipInspectType) {
it(`output ${type} is known`, (): void => {
expect(() => inspectType(type)).not.toThrow();
});
}
Avoid deeply nested control flow statements. Open
if (params.length) {
describe('params', (): void => {
for (const { name, type } of params) {
if (skipInspectTypes.includes(type)) {
continue;
Function getModules
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function getModules (api: DeriveApi): [string, string | null] {
const [council] = api.registry.getModuleInstances(api.runtimeVersion.specName, 'council') || ['council'];
const elections = api.query['phragmenElection']
? 'phragmenElection'
: api.query['electionsPhragmen']
- 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 dualParamsNotation
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function dualParamsNotation (registry: Registry, wrapper: string, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean): string {
Function extractStorageArgs
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export function extractStorageArgs (registry: Registry, creator: StorageEntry, _args: unknown[]): [StorageEntry, unknown[]] {
const args = _args.filter((a) => !isUndefined(a));
if (creator.meta.type.isPlain) {
if (args.length !== 0) {
- 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
Avoid deeply nested control flow statements. Open
if (ver) {
const methods = Object.entries(ver.methods);
const mcount = methods.length;
if (mcount) {
Function generateForMeta
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function generateForMeta (registry: Registry, meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean, customLookupDefinitions?: Definitions): void {
Function singleParamNotation
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function singleParamNotation (registry: Registry, wrapper: string, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean): string {
Function generateCallTypes
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
export function generateCallTypes (registry: Registry, meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean, customLookupDefinitions?: Definitions): void {
Function splitAlternatives
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function splitAlternatives (type: string): string[] {
const alternatives = [];
let beginOfAlternative = 1;
let level = 0;
- 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 tsResultGetter
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function tsResultGetter (registry: Registry, definitions: Record<string, ModuleTypes>, resultName = '', getter: 'Ok' | 'Err', def: TypeDef, imports: TypeImports): string {
Function entrySignature
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function entrySignature (lookup: PortableRegistry, allDefs: Record<string, ModuleTypes>, registry: Registry, section: string, storageEntry: StorageEntryMetadataLatest, imports: TypeImports): [boolean, string, string, string] {
Function filterEvents
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export function filterEvents (txHash: H256, { block: { extrinsics, header } }: SignedBlock, allEvents: EventRecord[], status: ExtrinsicStatus): { events?: EventRecord[], txIndex?: number, blockNumber?: BlockNumber } {
// extrinsics to hashes
for (const [txIndex, x] of extrinsics.entries()) {
if (x.hash.eq(txHash)) {
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 formatType
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
export function formatType (registry: Registry, definitions: Record<string, ModuleTypes>, type: AnyString | TypeDef, imports: TypeImports, withShortcut = false): string {
Function getBatch
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function getBatch (api: DeriveApi, activeEra: EraIndex, stashIds: AccountId[], flags: StakingQueryFlags, page: u32 | AnyNumber): Observable<DeriveStakingQuery[]> {
Function exportInterface
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
export function exportInterface (lookupIndex = -1, name = '', base: string, body = '', withShortcut = false): string {