pact-foundation/pact-js

View on GitHub

Showing 37 of 37 total issues

File matchers.spec.ts has 761 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { expect } from 'chai';
import {
  boolean,
  decimal,
  eachLike,
Severity: Major
Found in src/dsl/matchers.spec.ts - About 1 day to fix

    File matchers.spec.ts has 657 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import * as chai from 'chai';
    import * as MatchersV3 from './matchers';
    
    const { expect } = chai;
    
    
    Severity: Major
    Found in src/v3/matchers.spec.ts - About 1 day to fix

      File matchers.ts has 382 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { isNil, pickBy, times } from 'ramda';
      import RandExp from 'randexp';
      
      import {
        ArrayContainsMatcher,
      Severity: Minor
      Found in src/v3/matchers.ts - About 5 hrs to fix

        File index.ts has 363 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /* eslint-disable */
        import { ConsumerInteraction, ConsumerPact } from '@pact-foundation/pact-core';
        import { JsonMap } from '../../common/jsonTypes';
        import { forEachObjIndexed } from 'ramda';
        import { Path, TemplateHeaders, TemplateQuery, V3MockServer } from '../../v3';
        Severity: Minor
        Found in src/v4/http/index.ts - About 4 hrs to fix

          File index.ts has 338 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /* eslint-disable */
          import { Metadata } from '../../dsl/message';
          import { AnyJson, JsonMap } from '../../common/jsonTypes';
          import {
            PluginConfig,
          Severity: Minor
          Found in src/v4/message/index.ts - About 4 hrs to fix

            Function traceHttpInteractions has 53 lines of code (exceeds 25 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: Major
            Found in src/httpPact/tracing.ts - About 2 hrs to fix

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

                http.request = (
                  options: RequestOptions | string | URL,
                  cb: RequestOptions | ((res: IncomingMessage) => void) | undefined
                ): ClientRequest => {
                  if (typeof options === 'string' || options instanceof URL) {
              Severity: Minor
              Found in src/httpPact/tracing.ts - About 1 hr to fix

                Function url2 has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function url2(
                  basePath: string | null,
                  pathFragments: Array<string | V3RegexMatcher | RegExp>
                ): V3RegexMatcher {
                  const regexpr = [
                Severity: Minor
                Found in src/v3/matchers.ts - About 1 hr to fix

                  Function constructor has 36 lines of code (exceeds 25 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 1 hr to fix

                    Function url2 has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export function url2(
                      basePath: string | null,
                      pathFragments: Array<string | V3RegexMatcher | RegExp>
                    ): V3RegexMatcher {
                      const regexpr = [
                    Severity: Minor
                    Found in src/v3/matchers.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 executeTest has 34 lines of code (exceeds 25 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 1 hr to fix

                      Function setHeaders has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export const setHeaders = (
                        part: InteractionPart,
                        interaction: ConsumerInteraction,
                        headers?: Headers
                      ): void => {
                      Severity: Minor
                      Found in src/httpPact/ffi.ts - About 1 hr to fix

                        Function createProxy has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export const createProxy = (
                          config: ProxyOptions,
                          stateSetupPath: string,
                          messageTransportPath: string
                        ): http.Server => {
                        Severity: Minor
                        Found in src/dsl/verifier/proxy/proxy.ts - About 1 hr to fix

                          Function generateMockServerError has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export function generateMockServerError(
                            mismatches: MatchingResult[],
                            indent: string
                          ): string {
                            return [
                          Severity: Minor
                          Found in src/v3/display.ts - About 1 hr to fix

                            Function verifyProvider has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              public verifyProvider(): Promise<string> {
                                logger.info('Verifying provider');
                            
                                if (isEmpty(this.config)) {
                                  return Promise.reject(
                            Severity: Minor
                            Found in src/dsl/verifier/verifier.ts - About 1 hr to fix

                              Function executeTest has 30 lines of code (exceeds 25 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 1 hr to fix

                                Function executeTest has 29 lines of code (exceeds 25 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 1 hr to fix

                                  Function reify has 28 lines of code (exceeds 25 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 1 hr to fix

                                    Function setupStates has 28 lines of code (exceeds 25 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 1 hr to fix

                                      Function registerAfterHook has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                      export const registerAfterHook = (
                                        app: express.Express,
                                        config: ProxyOptions,
                                        stateSetupPath: string
                                      ): void => {
                                      Severity: Minor
                                      Found in src/dsl/verifier/proxy/hooks.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

                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language