Showing 171 of 2,493 total issues
File types.ts
has 348 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
import type { GenericEthereumAccountId, GenericEthereumLookupSource } from '@polkadot/types';
import type { Bytes, Enum, Option, Struct, U256, U64, U8aFixed, Vec, bool, f64, u32, u64 } from '@polkadot/types-codec';
File types.ts
has 344 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
import type { GenericChainProperties, GenericEvent } from '@polkadot/types';
import type { Bytes, Compact, Enum, HashMap, Option, Result, Struct, Text, U8aFixed, Vec, bool, i32, u32, u64, u8 } from '@polkadot/types-codec';
File runtime.ts
has 334 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
// Copyright 2017-2024 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { DefinitionsCall, DefinitionsCallEntry } from '../../types/index.js';
Function generateRpcTypes
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function generateRpcTypes (registry: TypeRegistry, importDefinitions: Record<string, Definitions>, dest: string, extraTypes: ExtraTypes): void {
writeFile(dest, (): string => {
const allTypes: ExtraTypes = { '@polkadot/types/interfaces': importDefinitions, ...extraTypes };
const imports = createImports(allTypes);
const definitions = imports.definitions as Record<string, Definitions>;
File definitions.ts
has 314 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
// Copyright 2017-2024 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// order important in structs... :)
/* eslint-disable sort-keys */
File definitions.ts
has 305 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
// Copyright 2017-2024 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Definitions } from '../../types/index.js';
Function getSimilarTypes
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function getSimilarTypes (registry: Registry, definitions: Record<string, ModuleTypes>, _type: string, imports: TypeImports): string[] {
const typeParts = _type.split('::');
const type = typeParts[typeParts.length - 1];
const possibleTypes = [formatType(registry, definitions, type, imports)];
File types.ts
has 298 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
import type { BTreeMap, Bytes, Enum, Option, Raw, Struct, Text, U8aFixed, Vec, bool, u32, u64 } from '@polkadot/types-codec';
import type { ITuple } from '@polkadot/types-codec/types';
Function generateForMeta
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function generateForMeta (registry: Registry, meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean, customLookupDefinitions?: Definitions): void {
writeFile(dest, (): string => {
const allTypes: ExtraTypes = {
'@polkadot/types-augment': {
lookup: {
Function generateCallTypes
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function generateCallTypes (registry: Registry, meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean, customLookupDefinitions?: Definitions): void {
writeFile(dest, (): string => {
const allTypes: ExtraTypes = {
'@polkadot/types-augment': {
lookup: {
File definitions.ts
has 294 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
// Copyright 2017-2024 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// order important in structs... :)
/* eslint-disable sort-keys */
Function sortAsc
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
Open
export function sortAsc<V extends SortArg = Codec> (a: V, b: V): number {
if (isNumberLike(a) && isNumberLike(b)) {
return bnToBn(a).cmp(bnToBn(b));
} else if (a instanceof Map && b instanceof Map) {
return sortAsc(Array.from(a.values()), Array.from(b.values()));
- 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
File types.ts
has 283 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
import type { BTreeMap, Compact, Enum, Option, Struct, Vec, bool, u128, u16, u32, u64 } from '@polkadot/types-codec';
import type { ITuple } from '@polkadot/types-codec/types';
Function getImageHashBounded
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
Open
export function getImageHashBounded (hash: Uint8Array | string | Hash | FrameSupportPreimagesBounded): HexString {
return (hash as FrameSupportPreimagesBounded).isLegacy
? (hash as FrameSupportPreimagesBounded).asLegacy.hash_.toHex()
: (hash as FrameSupportPreimagesBounded).isLookup
? (hash as FrameSupportPreimagesBounded).asLookup.hash_.toHex()
- 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
File consts.ts
has 277 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
/* eslint-disable */
// import type lookup before we augment - in some environments
// this is required to allow for ambient/previous definitions
formatters
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
Open
const formatters: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => string> = {
[TypeDefInfo.Compact]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
return singleParamNotation(registry, 'Compact', typeDef, definitions, imports, withShortcut);
},
infoMapping
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
Open
const infoMapping: Record<TypeDefInfo, (registry: Registry, value: TypeDef) => CodecClass<Codec>> = {
[TypeDefInfo.BTreeMap]: (_registry: Registry, value: TypeDef): CodecClass<Codec> =>
createHashMap(BTreeMap, value),
[TypeDefInfo.BTreeSet]: (_registry: Registry, value: TypeDef): CodecClass<Codec> =>
encoders
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
Open
const encoders: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef) => string> = {
[TypeDefInfo.BTreeMap]: (registry: Registry, typeDef: TypeDef) =>
encodeWithParams(registry, typeDef, 'BTreeMap'),
[TypeDefInfo.BTreeSet]: (registry: Registry, typeDef: TypeDef) =>
Function modules
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const modules = rpcKeys.map((sectionFullName) => {
const rpc = definitions[sectionFullName].rpc || {};
const section = sectionFullName.split('/').pop();
const allMethods = Object.keys(rpc).sort().map((methodName) => {
Function mainPromise
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
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'