teamdigitale/italia-ts-commons

View on GitHub

Showing 13 of 107 total issues

File requests.ts has 546 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Type safe wrapper around the fetch API
 */

// eslint-disable camelcase
Severity: Major
Found in src/requests.ts - About 1 day to fix

    File responses.ts has 421 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* eslint-disable sonarjs/no-duplicate-string */
    import * as express from "express";
    import * as t from "io-ts";
    
    import { errorsToReadableMessages } from "./reporters";
    Severity: Minor
    Found in src/responses.ts - About 6 hrs to fix

      File requests.test.ts has 304 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { isLeft, right } from "fp-ts/lib/Either";
      import * as t from "io-ts";
      
      import {
        basicResponseDecoder,
      Severity: Minor
      Found in src/__tests__/requests.test.ts - About 3 hrs to fix

        Function mockRes has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default function mockRes(): any {
          const response = {
            append: jest.fn(),
            attachment: jest.fn(),
            clearCookie: jest.fn(),
        Severity: Minor
        Found in src/__mocks__/response.ts - About 1 hr to fix

          Function createFetchRequestForApi has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function createFetchRequestForApi<
            P,
            KH extends RequestHeaderKey,
            Q extends string,
            R
          Severity: Minor
          Found in src/requests.ts - About 1 hr to fix

            Function withRetries has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              (task, shouldAbort = Promise.resolve(false)) => {
                // Whether we must stop retrying
                // the abort process gets triggered when the shouldAbort promise resolves
                // to true. Not that aborting stops the retry process, it does NOT stop
                // the execution of the current task.
            Severity: Minor
            Found in src/tasks.ts - About 1 hr to fix

              Function startAppInsights has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function startAppInsights(
                connectionString: string,
                aiConfig: ApplicationInsightsConfig
              ): appInsights.TelemetryClient {
                const ai = appInsights.setup(connectionString);
              Severity: Minor
              Found in src/appinsights.ts - About 1 hr to fix

                Function withRetries has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                  <E, T>(
                    maxRetries: number,
                    backoff: (count: number) => Millisecond
                  ): ((
                    _: RetriableTask<E, T>,
                Severity: Minor
                Found in src/tasks.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

                Function mockReq has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export default function mockReq(): any {
                  const request = {
                    accepts: jest.fn(),
                    acceptsCharset: jest.fn(),
                    acceptsCharsets: jest.fn(),
                Severity: Minor
                Found in src/__mocks__/request.ts - About 1 hr to fix

                  Function getContextPathSimplified has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const getContextPathSimplified = (context: Context): string => {
                    if (context.length === 0) {
                      return " (decoder info n/a)";
                    }
                  
                  
                  Severity: Minor
                  Found in src/reporters.ts - About 45 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 filter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export const filter = <A, E = unknown>(
                    p: Pot<A, E>,
                    f: (v: A) => boolean
                  ): Pot<A, E> =>
                    fold(
                  Severity: Minor
                  Found in src/pot.ts - About 45 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 getKeepAliveAgentOptions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export const getKeepAliveAgentOptions = (env: typeof process.env) => ({
                    freeSocketTimeout:
                      env.FETCH_KEEPALIVE_FREE_SOCKET_TIMEOUT === undefined
                        ? undefined
                        : parseInt(env.FETCH_KEEPALIVE_FREE_SOCKET_TIMEOUT, 10),
                  Severity: Minor
                  Found in src/agent.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 patternDateFromString has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export const patternDateFromString = (
                    pattern: string,
                    tagName: string
                  ): t.Type<Date, string> =>
                    new t.Type<Date, string>(
                  Severity: Minor
                  Found in src/dates.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