polkadot-js/api

View on GitHub

Showing 179 of 2,612 total issues

Function convertCalls has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

function convertCalls (specs: TypeSpec[], registry: Registry, modName: Text, calls: FunctionMetadataV13[], sectionTypes: OverrideModuleType): PalletCallMetadataV14 {
Severity: Minor
Found in packages/types/src/metadata/v13/toV14.ts - About 35 mins to fix

    Function createCallFunction has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    export function createCallFunction (registry: Registry, lookup: PortableRegistry, variant: SiVariant, sectionName: string, sectionIndex: number): CallFunction {
    Severity: Minor
    Found in packages/types/src/metadata/decorate/extrinsics/index.ts - About 35 mins to fix

      Function convertEvents has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function convertEvents (specs: TypeSpec[], registry: Registry, modName: Text, events: EventMetadataV13[], sectionTypes: OverrideModuleType): PalletEventMetadataV14 {
      Severity: Minor
      Found in packages/types/src/metadata/v13/toV14.ts - About 35 mins to fix

        Function inspectType has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        function inspectType (type: string): void {
          try {
            // get the definition
            const { sub } = getTypeDef(registry.createType(type).toRawType());
        
        
        Severity: Minor
        Found in packages/types/src/interfaces/definitions.spec.ts - About 35 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 findClosing has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        export function findClosing (value: string, start: number): number {
          let depth = 0;
        
          for (let i = start, count = value.length; i < count; i++) {
            if (value[i] === '>') {
        Severity: Minor
        Found in packages/types-codec/src/utils/sanitize.ts - About 35 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 compareRationals has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        export function compareRationals (n1: BN, d1: BN, n2: BN, d2: BN): boolean {
          while (true) {
            const q1 = n1.div(d1);
            const q2 = n2.div(d2);
        
        
        Severity: Minor
        Found in packages/api-derive/src/democracy/util.ts - About 35 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

        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

            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 known[code] || '(Unknown)';
              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 [...new Set(possibleTypes)];
                Severity: Major
                Found in packages/typegen/src/util/derived.ts - About 30 mins to fix

                  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 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 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 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 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 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 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 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