vstirbu/fsm-as-promised

View on GitHub

Showing 9 of 10 total issues

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

/*
 * @author Vlad Stirbu
 * @license MIT
 *
 * Copyright © 2014-2020
Severity: Major
Found in src/index.ts - About 1 day to fix

    Function buildEvent has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

        buildEvent: function buildEvent(name) {
          var callbacks = this.callbacks;
          var pseudoEvents = this.pseudoEvents;
          var pseudoStates = this.pseudoStates;
          var events = this.events;
    Severity: Minor
    Found in src/index.ts - About 4 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 buildEvent has 90 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        buildEvent: function buildEvent(name) {
          var callbacks = this.callbacks;
          var pseudoEvents = this.pseudoEvents;
          var pseudoStates = this.pseudoStates;
          var events = this.events;
    Severity: Major
    Found in src/index.ts - About 3 hrs to fix

      Function triggerEvent has 82 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            return function triggerEvent() {
              var args = _.toArray(arguments);
              var current = this.current;
              var target = this.target;
              var options: {
      Severity: Major
      Found in src/index.ts - About 3 hrs to fix

        Function addConditionalEvent has 79 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            addConditionalEvent: function addConditionalEvent(event) {
              var pseudoState: string;
              var factory = this.factory;
              var callbackPrefix = factory.callbackPrefix;
              var noChoiceFound = factory.noChoiceFound;
        Severity: Major
        Found in src/index.ts - About 3 hrs to fix

          StateMachineStamp has 22 functions (exceeds 20 allowed). Consider refactoring.
          Open

            methods: {
              emit: _.noop,
              error: function (msg, options) {
                if (this.target) {
                  options.instanceId = this.target.instanceId();
          Severity: Minor
          Found in src/index.ts - About 2 hrs to fix

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

                initTarget: function initTarget(target) {
                  var mixin;
                  const id = v4();
            
                  if (!_.isObject(target)) {
            Severity: Minor
            Found in src/index.ts - About 1 hr to fix

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

                  instanceErrorHandler: function instanceErrorHandler(
                    err,
                    instanceId,
                    action
                  ) {
              Severity: Minor
              Found in src/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 canTransition has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  canTransition: function canTransition(options) {
                    var factory = this.factory;
                    var Type = factory.Type;
              
                    switch (factory.type(options)) {
              Severity: Minor
              Found in src/index.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

              Severity
              Category
              Status
              Source
              Language