convenia/revisionable

View on GitHub

Showing 15 of 33 total issues

Function getValue has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    protected function getValue($which = 'new')
    {
        $whichValue = $which.'_value';

        // First find the main model that was updated
Severity: Minor
Found in src/Revision.php - About 3 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

File RevisionableTrait.php has 297 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Convenia\Revisionable;

/*
Severity: Minor
Found in src/RevisionableTrait.php - About 3 hrs to fix

    Function postSave has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        public function postSave()
        {
            $limitReached = false;
    
            if (isset($this->historyLimit) && $this->revisionHistory()->count() >= $this->historyLimit) {
    Severity: Minor
    Found in src/RevisionableTrait.php - About 2 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

    Method postSave has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function postSave()
        {
            $limitReached = false;
    
            if (isset($this->historyLimit) && $this->revisionHistory()->count() >= $this->historyLimit) {
    Severity: Minor
    Found in src/RevisionableTrait.php - About 1 hr to fix

      Function preSave has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          public function preSave()
          {
              if (self::$suspended === true) {
                  return;
              }
      Severity: Minor
      Found in src/RevisionableTrait.php - 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

      Method getValue has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function getValue($which = 'new')
          {
              $whichValue = $which.'_value';
      
              // First find the main model that was updated
      Severity: Minor
      Found in src/Revision.php - About 1 hr to fix

        Method preSave has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function preSave()
            {
                if (self::$suspended === true) {
                    return;
                }
        Severity: Minor
        Found in src/RevisionableTrait.php - About 1 hr to fix

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

              public static function format($key, $value, $formats)
              {
                  foreach ($formats as $pkey => $format) {
                      $parts = explode(':', $format);
                      if (count($parts) === 1) {
          Severity: Minor
          Found in src/FieldFormatter.php - 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

          Method postCreate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function postCreate()
              {
                  // Check if we should store creations in our revision history
                  // Set this value to true in your model if you want to
                  if (empty($this->revisionCreationsEnabled)) {
          Severity: Minor
          Found in src/RevisionableTrait.php - About 1 hr to fix

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

                protected function changedRevisionableFields()
                {
                    $changesToRecord = [];
                    foreach ($this->dirtyData as $key => $value) {
                        // check that the field is revisionable, and double check
            Severity: Minor
            Found in src/RevisionableTrait.php - 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 postCreate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function postCreate()
                {
                    // Check if we should store creations in our revision history
                    // Set this value to true in your model if you want to
                    if (empty($this->revisionCreationsEnabled)) {
            Severity: Minor
            Found in src/RevisionableTrait.php - 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 userResponsible has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function userResponsible()
                {
                    if (empty($this->user_id)) {
                        return false;
                    }
            Severity: Minor
            Found in src/Revision.php - 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 method.
            Open

                    return $userModel::find($this->user_id);
            Severity: Major
            Found in src/Revision.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return $this->format($this->key, $this->$whichValue);
              Severity: Major
              Found in src/Revision.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return $this->format($this->key, $mainModel->$mutator($this->$whichValue));
                Severity: Major
                Found in src/Revision.php - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language