polkadot-js/api

View on GitHub

Showing 171 of 2,493 total issues

File types.ts has 348 lines of code (exceeds 250 allowed). Consider refactoring.
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';
Severity: Minor
Found in packages/types/src/interfaces/eth/types.ts - About 4 hrs to fix

    File types.ts has 344 lines of code (exceeds 250 allowed). Consider refactoring.
    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';
    Severity: Minor
    Found in packages/types/src/interfaces/system/types.ts - About 4 hrs to fix

      File runtime.ts has 334 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      // Copyright 2017-2024 @polkadot/types authors & contributors
      // SPDX-License-Identifier: Apache-2.0
      
      import type { DefinitionsCall, DefinitionsCallEntry } from '../../types/index.js';
      
      
      Severity: Minor
      Found in packages/types/src/interfaces/eth/runtime.ts - About 4 hrs to fix

        Function generateRpcTypes has 93 lines of code (exceeds 25 allowed). Consider refactoring.
        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>;
        Severity: Major
        Found in packages/typegen/src/generate/rpc.ts - About 3 hrs to fix

          File definitions.ts has 314 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          // Copyright 2017-2024 @polkadot/types authors & contributors
          // SPDX-License-Identifier: Apache-2.0
          
          // order important in structs... :)
          /* eslint-disable sort-keys */
          Severity: Minor
          Found in packages/types/src/interfaces/system/definitions.ts - About 3 hrs to fix

            File definitions.ts has 305 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            // Copyright 2017-2024 @polkadot/types authors & contributors
            // SPDX-License-Identifier: Apache-2.0
            
            import type { Definitions } from '../../types/index.js';
            
            
            Severity: Minor
            Found in packages/types/src/interfaces/contractsAbi/definitions.ts - About 3 hrs to fix

              Function getSimilarTypes has 82 lines of code (exceeds 25 allowed). Consider refactoring.
              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)];
              
              
              Severity: Major
              Found in packages/typegen/src/util/derived.ts - About 3 hrs to fix

                File types.ts has 298 lines of code (exceeds 250 allowed). Consider refactoring.
                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';
                Severity: Minor
                Found in packages/types/src/interfaces/contractsAbi/types.ts - About 3 hrs to fix

                  Function generateForMeta has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                  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: {
                  Severity: Major
                  Found in packages/typegen/src/generate/tx.ts - About 3 hrs to fix

                    Function generateCallTypes has 77 lines of code (exceeds 25 allowed). Consider refactoring.
                    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: {
                    Severity: Major
                    Found in packages/typegen/src/generate/runtime.ts - About 3 hrs to fix

                      File definitions.ts has 294 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      // Copyright 2017-2024 @polkadot/types authors & contributors
                      // SPDX-License-Identifier: Apache-2.0
                      
                      // order important in structs... :)
                      /* eslint-disable sort-keys */
                      Severity: Minor
                      Found in packages/types/src/interfaces/staking/definitions.ts - About 3 hrs to fix

                        Function sortAsc has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                        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()));
                        Severity: Minor
                        Found in packages/types-codec/src/utils/sortValues.ts - About 2 hrs to fix

                        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

                        // 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';
                        Severity: Minor
                        Found in packages/types/src/interfaces/staking/types.ts - About 2 hrs to fix

                          Function getImageHashBounded has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                          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()
                          Severity: Minor
                          Found in packages/api-derive/src/democracy/util.ts - About 2 hrs to fix

                          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

                          // 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
                          Severity: Minor
                          Found in packages/api-augment/src/kusama/consts.ts - About 2 hrs to fix

                            formatters has 23 functions (exceeds 20 allowed). Consider refactoring.
                            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);
                              },
                            
                            
                            Severity: Minor
                            Found in packages/typegen/src/util/formatting.ts - About 2 hrs to fix

                              infoMapping has 23 functions (exceeds 20 allowed). Consider refactoring.
                              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> =>
                              Severity: Minor
                              Found in packages/types-create/src/create/class.ts - About 2 hrs to fix

                                encoders has 23 functions (exceeds 20 allowed). Consider refactoring.
                                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) =>
                                Severity: Minor
                                Found in packages/types-create/src/util/encodeTypes.ts - About 2 hrs to fix

                                  Function modules has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      const modules = rpcKeys.map((sectionFullName) => {
                                        const rpc = definitions[sectionFullName].rpc || {};
                                        const section = sectionFullName.split('/').pop();
                                  
                                        const allMethods = Object.keys(rpc).sort().map((methodName) => {
                                  Severity: Major
                                  Found in packages/typegen/src/generate/rpc.ts - About 2 hrs to fix

                                    Function mainPromise has 62 lines of code (exceeds 25 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'
                                    Severity: Major
                                    Found in packages/typegen/src/fromDefs.ts - About 2 hrs to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language