pact-foundation/pact-js

View on GitHub

Showing 37 of 37 total issues

Function setRequestDetails has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const setRequestDetails = (
  interaction: ConsumerInteraction,
  req: V3Request
): void => {
  interaction.withRequest(
Severity: Minor
Found in src/v3/ffi.ts - About 1 hr to fix

    Function setupStates has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    export const setupStates = (
      state: ProviderState,
      config: ProxyOptions
    ): Promise<JsonMap | void> => {
      logger.debug(`setting up state '${JSON.stringify(state)}'`);
    Severity: Minor
    Found in src/dsl/verifier/proxy/stateHandler/setupStates.ts - About 55 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 registerBeforeHook has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    export const registerBeforeHook = (
      app: express.Express,
      config: ProxyOptions,
      stateSetupPath: string
    ): void => {
    Severity: Minor
    Found in src/dsl/verifier/proxy/hooks.ts - About 55 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 9 (exceeds 5 allowed). Consider refactoring.
    Open

      constructor(config: VerifierOptions) {
        this.config = config;
    
        if (this.config.logLevel && !isEmpty(this.config.logLevel)) {
          serviceFactory.logLevel(this.config.logLevel);
    Severity: Minor
    Found in src/dsl/verifier/verifier.ts - About 55 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 cleanup has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const cleanup = (
      success: boolean,
      pact: ConsumerPact,
      opts: PactV4Options,
      cleanupFn: () => void,
    Severity: Minor
    Found in src/v4/message/index.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 traceHttpInteractions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    export const traceHttpInteractions = (): void => {
      const originalRequest = http.request;
      http.request = (
        options: RequestOptions | string | URL,
        cb: RequestOptions | ((res: IncomingMessage) => void) | undefined
    Severity: Minor
    Found in src/httpPact/tracing.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 executeTest has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const executeTest = async <T>(
      pact: ConsumerPact,
      opts: PactV4Options,
      testFn: TestFunction<T>,
      cleanupFn: () => void
    Severity: Minor
    Found in src/v4/http/index.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 reify has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    export function reify(input: unknown): AnyJson {
      if (isMatcher(input)) {
        return reify(input.value);
      }
    
    
    Severity: Minor
    Found in src/v3/matchers.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 executeTest has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      public async executeTest<T>(
        testFn: (mockServer: V3MockServer) => Promise<T>
      ): Promise<T | undefined> {
        const scheme = this.opts.tls ? 'https' : 'http';
        const host = this.opts.host || '127.0.0.1';
    Severity: Minor
    Found in src/v3/pact.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 input;
    Severity: Major
    Found in src/v3/matchers.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

            return `Unknown mismatch: ${mismatch}`;
      Severity: Major
      Found in src/v3/display.ts - About 30 mins to fix

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

        export const setRequestDetails = (
          interaction: ConsumerInteraction,
          req: V3Request
        ): void => {
          interaction.withRequest(
        Severity: Minor
        Found in src/v3/ffi.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 printMismatch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export function printMismatch(m: Mismatch): string {
          if (isPluginContentMismatch(m)) {
            const s = [
              `\t${m.path}: ${m.mismatch}\n`,
              m.mismatch
        Severity: Minor
        Found in src/v3/display.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 setHeaders has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        export const setHeaders = (
          part: InteractionPart,
          interaction: ConsumerInteraction,
          headers?: Headers
        ): void => {
        Severity: Minor
        Found in src/httpPact/ffi.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 executeTest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          async executeTest<T>(
            integrationTest: (tc: TransportConfig, m: SynchronousMessage) => Promise<T>
          ): Promise<T | undefined> {
            let val: T | undefined;
            let error: Error | undefined;
        Severity: Minor
        Found in src/v4/message/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

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

        export function eachLike<T>(
          template: T,
          opts?: { min: number }
        ): ArrayMatcher<T[]> {
          if (isUndefined(template)) {
        Severity: Minor
        Found in src/dsl/matchers.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 appendText has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          public appendText(content: string | Matcher<string>): XmlElement {
            if (typeof content === 'object' && content['pact:matcher:type']) {
              this.children.push(
                new XmlText(
                  isMatcher(content) &&
        Severity: Minor
        Found in src/v3/xml/xmlElement.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