faasjs/faasjs

View on GitHub
packages/request/src/index.ts

Summary

Maintainability
A
3 hrs
Test Coverage
B
81%

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 request has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Wontfix

    export async function request<T = any>(
      url: string,
      options: RequestOptions = { headers: {} }
    ): Promise<Response<T>> {
      const requestId = randomUUID()
    Severity: Minor
    Found in packages/request/src/index.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

    Function querystringify has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Wontfix

    export function querystringify(obj: any) {
      const pairs: string[] = []
      let value: string
      let key: string
    
    
    Severity: Minor
    Found in packages/request/src/index.ts - About 1 hr 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

      There are no issues that match your filters.

      Category
      Status