d1g1tinc/fairlight

View on GitHub

Showing 5 of 13 total issues

Function useApiQuery has 117 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function useApiQuery<TResponseBody extends ResponseBody>(
  params: ApiRequestParams<ApiRequestMethod, TResponseBody> | FalsyValue,
  opts: UseApiQueryOptions<TResponseBody> = {}
): [UseApiQueryData<TResponseBody>, UseApiQueryActions<TResponseBody>] {
  const {
Severity: Major
Found in src/react/use-api-query/index.tsx - About 4 hrs to fix

    Function useApiQuery has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    export function useApiQuery<TResponseBody extends ResponseBody>(
      params: ApiRequestParams<ApiRequestMethod, TResponseBody> | FalsyValue,
      opts: UseApiQueryOptions<TResponseBody> = {}
    ): [UseApiQueryData<TResponseBody>, UseApiQueryActions<TResponseBody>] {
      const {
    Severity: Minor
    Found in src/react/use-api-query/index.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 getRequestHeadersAndBody has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private getRequestHeadersAndBody(
        params: ApiRequestParams
      ): {headers: ApiHeaders; body: BodyInit | undefined} {
        let headers: ApiHeaders = cloneHeaders(this.defaultHeaders)
    
    
    Severity: Minor
    Found in src/api/request-manager/index.tsx - About 1 hr to fix

      Avoid too many return statements within this function.
      Open

          return null
      Severity: Major
      Found in src/api/request-fetcher/index.tsx - About 30 mins to fix

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

          private maybeThrowApiError(
            params: ApiRequestParams,
            {status, body, bodyType}: RequestFetcherResponse
          ): void {
            if (Array.isArray(params.successCodes)) {
        Severity: Minor
        Found in src/api/request-manager/index.tsx - 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