jsGiven/jsGiven

View on GitHub

Showing 20 of 29 total issues

File scenarios.js has 521 lines of code (exceeds 250 allowed). Consider refactoring.
Confirmed

// @flow
import _ from 'lodash';
import functionArguments from 'function-arguments';
import humanize from 'string-humanize';
import stripAnsi from 'strip-ansi';
Severity: Major
Found in js-given/src/scenarios.js - About 1 day to fix

    Function scenarios has 201 lines of code (exceeds 25 allowed). Consider refactoring.
    Confirmed

      scenarios<G: Stage, W: Stage, T: Stage>(
        groupName: string,
        stagesParams: StagesParam<G, W, T>,
        scenariosDescriptions: ScenariosDescriptions<G, W, T>
      ) {
    Severity: Major
    Found in js-given/src/scenarios.js - About 1 day to fix

      Function buildStage has 113 lines of code (exceeds 25 allowed). Consider refactoring.
      Confirmed

        buildStage<T>(tClass: Class<T>, runningScenario: RunningScenario): T {
          // $FlowIgnore
          const tInstance = new tClass();
          const tPrototype = Object.getPrototypeOf(tInstance);
      
      
      Severity: Major
      Found in js-given/src/scenarios.js - About 4 hrs to fix

        Function methodName has 72 lines of code (exceeds 25 allowed). Consider refactoring.
        Confirmed

              proxyPrototype[methodName] = function(...args: any[]): any {
                const {
                  state,
                  steps,
                  caseArguments,
        Severity: Major
        Found in js-given/src/scenarios.js - About 2 hrs to fix

          Function constructor has 64 lines of code (exceeds 25 allowed). Consider refactoring.
          Confirmed

            constructor(
              methodName: string,
              parameters: DecodedParameter[],
              isFirstStep: boolean,
              introWord: string | null,
          Severity: Major
          Found in js-given/src/reports.js - About 2 hrs to fix

            Function buildParameterFormatter has 51 lines of code (exceeds 25 allowed). Consider refactoring.
            Confirmed

            export function buildParameterFormatter(
              formatter: Formatter
            ): ParameterFormatter {
              const parameterFormatter = function(
                ...parameterNames: string[]
            Severity: Major
            Found in js-given/src/parameter-formatting.js - About 2 hrs to fix

              Function aroundToBeforeAfter has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function aroundToBeforeAfter(
                aroundMethod: AroundMethod
              ): BeforeAfterMethods {
                let currentlyExecuting: 'NONE' | 'BEFORE' | 'TEST' | 'AFTER' = 'NONE';
                let promiseOfAroundMethod;
              Severity: Minor
              Found in js-given/src/life-cycle.js - About 1 hr to fix

                Function getScenarios has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Confirmed

                      function getScenarios(scenarios: {
                        [key: string]: ScenarioDescription,
                      }): ScenarioDescriptionWithName[] {
                        const scenarioDescriptions: ScenarioDescriptionWithName[] = Object.keys(
                          scenarios
                Severity: Minor
                Found in js-given/src/scenarios.js - About 1 hr to fix

                  Function scenarios has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Confirmed

                    scenarios<G: Stage, W: Stage, T: Stage>(
                      groupName: string,
                      stagesParams: StagesParam<G, W, T>,
                      scenariosDescriptions: ScenariosDescriptions<G, W, T>
                    ) {
                  Severity: Minor
                  Found in js-given/src/scenarios.js - 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 scenarioDescriptions has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Confirmed

                          ).map(scenarioPropertyName => {
                            const scenarioDescription: ScenarioDescription =
                              scenarios[scenarioPropertyName];
                            const { scenarioFunction } = scenarioDescription;
                            if (scenarioFunction instanceof Function) {
                  Severity: Minor
                  Found in js-given/src/scenarios.js - About 1 hr to fix

                    Similar blocks of code found in 4 locations. Consider refactoring.
                    Open

                    export function Before(target: any, key: string, descriptor: any): any {
                      beforeProvider.getStoreFromTarget(target).addProperty(key);
                      return { ...descriptor, writable: true };
                    }
                    Severity: Major
                    Found in js-given/src/life-cycle.js and 3 other locations - About 1 hr to fix
                    js-given/src/State.js on lines 14..17
                    js-given/src/life-cycle.js on lines 27..30
                    js-given/src/life-cycle.js on lines 39..42

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 61.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 4 locations. Consider refactoring.
                    Open

                    export function After(target: any, key: string, descriptor: any): any {
                      afterProvider.getStoreFromTarget(target).addProperty(key);
                      return { ...descriptor, writable: true };
                    }
                    Severity: Major
                    Found in js-given/src/life-cycle.js and 3 other locations - About 1 hr to fix
                    js-given/src/State.js on lines 14..17
                    js-given/src/life-cycle.js on lines 15..18
                    js-given/src/life-cycle.js on lines 39..42

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 61.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 4 locations. Consider refactoring.
                    Open

                    export function Around(target: any, key: string, descriptor: any): any {
                      aroundProvider.getStoreFromTarget(target).addProperty(key);
                      return { ...descriptor, writable: true };
                    }
                    Severity: Major
                    Found in js-given/src/life-cycle.js and 3 other locations - About 1 hr to fix
                    js-given/src/State.js on lines 14..17
                    js-given/src/life-cycle.js on lines 15..18
                    js-given/src/life-cycle.js on lines 27..30

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 61.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 4 locations. Consider refactoring.
                    Open

                    export function State(target: any, key: string, descriptor: any): any {
                      stateProvider.getStoreFromTarget(target).addProperty(key);
                      return { ...descriptor, writable: true };
                    }
                    Severity: Major
                    Found in js-given/src/State.js and 3 other locations - About 1 hr to fix
                    js-given/src/life-cycle.js on lines 15..18
                    js-given/src/life-cycle.js on lines 27..30
                    js-given/src/life-cycle.js on lines 39..42

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 61.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 4 locations. Consider refactoring.
                    Open

                    Before.addProperty = (stageClass: Class<Stage>, property: string): void => {
                      beforeProvider.getStoreFromStageClass(stageClass).addProperty(property);
                    };
                    Severity: Major
                    Found in js-given/src/life-cycle.js and 3 other locations - About 1 hr to fix
                    js-given/src/State.js on lines 18..20
                    js-given/src/life-cycle.js on lines 31..33
                    js-given/src/life-cycle.js on lines 43..45

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 57.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 4 locations. Consider refactoring.
                    Open

                    After.addProperty = (stageClass: Class<Stage>, property: string): void => {
                      afterProvider.getStoreFromStageClass(stageClass).addProperty(property);
                    };
                    Severity: Major
                    Found in js-given/src/life-cycle.js and 3 other locations - About 1 hr to fix
                    js-given/src/State.js on lines 18..20
                    js-given/src/life-cycle.js on lines 19..21
                    js-given/src/life-cycle.js on lines 43..45

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 57.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 4 locations. Consider refactoring.
                    Open

                    Around.addProperty = (stageClass: Class<Stage>, property: string): void => {
                      aroundProvider.getStoreFromStageClass(stageClass).addProperty(property);
                    };
                    Severity: Major
                    Found in js-given/src/life-cycle.js and 3 other locations - About 1 hr to fix
                    js-given/src/State.js on lines 18..20
                    js-given/src/life-cycle.js on lines 19..21
                    js-given/src/life-cycle.js on lines 31..33

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 57.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Similar blocks of code found in 4 locations. Consider refactoring.
                    Open

                    State.addProperty = (stageClass: Class<Stage>, property: string): void => {
                      stateProvider.getStoreFromStageClass(stageClass).addProperty(property);
                    };
                    Severity: Major
                    Found in js-given/src/State.js and 3 other locations - About 1 hr to fix
                    js-given/src/life-cycle.js on lines 19..21
                    js-given/src/life-cycle.js on lines 31..33
                    js-given/src/life-cycle.js on lines 43..45

                    Duplicated Code

                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                    Tuning

                    This issue has a mass of 57.

                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                    Refactorings

                    Further Reading

                    Function constructor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Confirmed

                      constructor(
                        methodName: string,
                        parameters: DecodedParameter[],
                        isFirstStep: boolean,
                        introWord: string | null,
                    Severity: Minor
                    Found in js-given/src/reports.js - 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

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

                    export function aroundToBeforeAfter(
                      aroundMethod: AroundMethod
                    ): BeforeAfterMethods {
                      let currentlyExecuting: 'NONE' | 'BEFORE' | 'TEST' | 'AFTER' = 'NONE';
                      let promiseOfAroundMethod;
                    Severity: Minor
                    Found in js-given/src/life-cycle.js - 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