faasjs/faasjs

View on GitHub

Showing 18 of 100 total issues

Function FaasReactClient has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

export function FaasReactClient({
  domain,
  options,
  onError,
}: FaasReactClientOptions): FaasReactClientInstance {
Severity: Minor
Found in packages/react/src/client.tsx - About 3 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

Function transferValue has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

export function transferValue(type: FaasItemType, value: any): any {
  if (!type) type = 'string'

  if (
    !type.endsWith('[]') &&
Severity: Minor
Found in packages/ant-design/src/data.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 index.ts has 286 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * FaasJS's request module.
 *
 * [![License: MIT](https://img.shields.io/npm/l/@faasjs/request.svg)](https://github.com/faasjs/faasjs/blob/main/packages/faasjs/request/LICENSE)
 * [![NPM Version](https://img.shields.io/npm/v/@faasjs/request.svg)](https://www.npmjs.com/package/@faasjs/request)
Severity: Minor
Found in packages/request/src/index.ts - About 2 hrs to fix

    Function publish has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    async function publish(path) {
      const pkg = require(`${__dirname}/${path}`)
    
      console.log(pkg.name)
    
    
    Severity: Minor
    Found in publish.js - 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

    Consider simplifying this complex logical expression.
    Open

                if (
                  response.body &&
                  response.headers['content-type'] &&
                  response.headers['content-type'].includes('application/json') &&
                  typeof response.body === 'string' &&
    Severity: Major
    Found in packages/request/src/index.ts - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

              if (shouldMerge(value)) val = deepMerge(acc[key], value)
              else val = value
      Severity: Major
      Found in packages/deep_merge/src/index.ts - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    for (const val of value)
                      this.validContent(
                        type,
                        val,
                        baseKey ? `${baseKey}.${key}.` : `${key}.`,
        Severity: Major
        Found in packages/http/src/validator.ts - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      switch (rule.type) {
                        case 'array':
                          typed = Array.isArray(value)
                          break
                        case 'object':
          Severity: Major
          Found in packages/cloud_function/src/validator.ts - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                      else if (typeof value === 'object')
                        // object
                        this.validContent(
                          type,
                          value,
            Severity: Major
            Found in packages/cloud_function/src/validator.ts - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                          for (const val of value)
                            this.validContent(
                              type,
                              val,
                              baseKey ? `${baseKey}.${key}.` : `${key}.`,
              Severity: Major
              Found in packages/cloud_function/src/validator.ts - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                          else if (typeof value === 'object')
                            // object
                            this.validContent(
                              type,
                              value,
                Severity: Major
                Found in packages/http/src/validator.ts - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                              switch (rule.type) {
                                case 'array':
                                  typed = Array.isArray(value)
                                  break
                                case 'object':
                  Severity: Major
                  Found in packages/http/src/validator.ts - About 45 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                      if (
                        !type.endsWith('[]') &&
                        (typeof value === 'undefined' ||
                          value === null ||
                          value === '' ||
                    Severity: Major
                    Found in packages/ant-design/src/data.ts - About 40 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                          if (
                            apiInfo.ServiceType !== 'SCF' ||
                            apiInfo.ServiceTimeout !== config.config.ServiceTimeout ||
                            apiInfo.ServiceScfFunctionName !== config.config.ServiceScfFunctionName ||
                            apiInfo.ServiceScfFunctionNamespace !==
                      Severity: Major
                      Found in packages/tencentcloud/src/http/deploy.ts - About 40 mins to fix

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

                          public async action<PathOrData extends FaasAction>(
                            action: PathOrData | string,
                            params?: FaasParams<PathOrData>,
                            options?: Options
                          ): Promise<Response<FaasData<PathOrData>>> {
                        Severity: Minor
                        Found in packages/browser/src/index.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 null
                        Severity: Major
                        Found in packages/ant-design/src/Title.tsx - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                    return Promise.reject(
                                      new ResponseError({
                                        message: res,
                                        status: response.status,
                                        headers,
                          Severity: Major
                          Found in packages/browser/src/index.ts - About 30 mins to fix

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

                              constructor(label?: string) {
                                if (label) this.label = label
                            
                                // When run with Jest and --silent, logger won't output anything
                                if (
                            Severity: Minor
                            Found in packages/logger/src/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