polkadot-js/api

View on GitHub

Showing 171 of 2,493 total issues

Avoid too many return statements within this function.
Open

      return '(For applications)';
Severity: Major
Found in packages/rpc-provider/src/ws/errors.ts - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

        return sortArray(a, b);
    Severity: Major
    Found in packages/types-codec/src/utils/sortValues.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return sortAsc(a.toU8a(true), b.toU8a(true));
      Severity: Major
      Found in packages/types-codec/src/utils/sortValues.ts - About 30 mins to fix

        Function injectFunctions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function injectFunctions (instanceId: string, api: DeriveApi, derives: DeriveCustom): ExactDerive {
          const result: Record<string, Record<string, AnyFunction>> = {};
          const names = Object.keys(derives);
          const keys = Object.keys(api.query);
          const specName = api.runtimeVersion.specName;
        Severity: Minor
        Found in packages/api-derive/src/bundle.ts - About 25 mins 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

        Function docsVecToMarkdown has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function docsVecToMarkdown (docLines: Vec<Text>, indent = 0): string {
          const md = docLines
            .map((docLine) =>
              docLine
                .toString()
        Severity: Minor
        Found in packages/typegen/src/metadataMd.ts - About 25 mins 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

        Function extractAuthor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export function extractAuthor (digest: Digest, sessionValidators: AccountId[]): AccountId | undefined {
          const [citem] = digest.logs.filter((e) => e.isConsensus);
          const [pitem] = digest.logs.filter((e) => e.isPreRuntime);
          const [sitem] = digest.logs.filter((e) => e.isSeal);
          let accountId: AccountId | undefined;
        Severity: Minor
        Found in packages/api-derive/src/type/util.ts - About 25 mins 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

        Function formatType has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export function formatType (registry: Registry, definitions: Record<string, ModuleTypes>, type: AnyString | TypeDef, imports: TypeImports, withShortcut = false): string {
          let typeDef: TypeDef;
        
          if (isString(type)) {
            const _type = type.toString();
        Severity: Minor
        Found in packages/typegen/src/util/formatting.ts - About 25 mins 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

        Function constructor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          constructor (api: ApiBase<ApiType>, abi: string | Record<string, unknown> | Abi, decorateMethod: DecorateMethod<ApiType>) {
            if (!api || !api.isConnected || !api.tx) {
              throw new Error('Your API has not been initialized correctly and is not connected to a chain');
            } else if (!api.tx.contracts || !isFunction(api.tx.contracts.instantiateWithCode) || api.tx.contracts.instantiateWithCode.meta.args.length !== 6) {
              throw new Error('The runtime does not expose api.tx.contracts.instantiateWithCode with storageDepositLimit');
        Severity: Minor
        Found in packages/api-contract/src/base/Base.ts - About 25 mins 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

        Function findMethodExcludes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function findMethodExcludes <T> (src: Sections<T>, dst: Sections<T>): string[] {
          const srcSections = Object.keys(src);
          const dstSections = findSectionIncludes(Object.keys(dst), srcSections);
          const excludes: string[] = [];
        
        
        Severity: Minor
        Found in packages/api/src/util/augmentObject.ts - About 25 mins 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

        Function exportInterface has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export function exportInterface (lookupIndex = -1, name = '', base: string, body = '', withShortcut = false): string {
          // * @description extends [[${base}]]
          const doc = withShortcut
            ? ''
            : `/** @name ${name}${lookupIndex !== -1 ? ` (${lookupIndex})` : ''} */\n`;
        Severity: Minor
        Found in packages/typegen/src/util/formatting.ts - About 25 mins 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

        Function decorateErrors has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export function decorateErrors (registry: Registry, { lookup, pallets }: MetadataLatest, version: number): Errors {
          const result: Errors = {};
        
          for (let i = 0, count = pallets.length; i < count; i++) {
            const { errors, index, name } = pallets[i];
        Severity: Minor
        Found in packages/types/src/metadata/decorate/errors/index.ts - About 25 mins 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

        Severity
        Category
        Status
        Source
        Language