hnhdigital-os/laravel-model-change-tracking

View on GitHub

Showing 9 of 12 total issues

Method processManyToManyChange has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function processManyToManyChange($relation_method_name, $new_value, $override_relationship_method = null)
    {
        // The join between the model and the other model
        $relation = $this->$relation_method_name();

Severity: Major
Found in src/LogChangeTrait.php - About 2 hrs to fix

    Function bootLogChangeTrait has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function bootLogChangeTrait()
        {
            // Saved model event
            static::saved(function ($model) {
    
    
    Severity: Minor
    Found in src/LogChangeTrait.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

    Function getModelChangeDiff has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function getModelChangeDiff($column_name, &$log_change, $old_text, $new_text)
        {
            if (is_array($old_text) && is_array($new_text)) {
                $difference = (new MapDiffer())->doDiff($old_text, $new_text);
    
    
    Severity: Minor
    Found in src/LogChangeTrait.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 bootLogChangeTrait has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function bootLogChangeTrait()
        {
            // Saved model event
            static::saved(function ($model) {
    
    
    Severity: Minor
    Found in src/LogChangeTrait.php - About 1 hr to fix

      Method getModelChangeDiff has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static function getModelChangeDiff($column_name, &$log_change, $old_text, $new_text)
          {
              if (is_array($old_text) && is_array($new_text)) {
                  $difference = (new MapDiffer())->doDiff($old_text, $new_text);
      
      
      Severity: Minor
      Found in src/LogChangeTrait.php - About 1 hr to fix

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

            public static function bootChangeByUserTrait()
            {
                static::creating(function ($model) {
                    if (!App::runningInConsole() && Auth::check()) {
                        if ($model->getCreatedByColumn()) {
        Severity: Minor
        Found in src/ChangeByUserTrait.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

        Method addModelChange has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                $model_id,
                $table_name,
                $column_name,
                $old_text,
                $new_text,
        Severity: Major
        Found in src/LogChangeTrait.php - About 50 mins to fix

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

              public function handle()
              {
                  // Read the app folder & save
                  $models = Storage::disk('models')->allFiles();
          
          
          Severity: Minor
          Found in src/ModelSyncCommand.php - 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 processManyToManyChange has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              public function processManyToManyChange($relation_method_name, $new_value, $override_relationship_method = null)
              {
                  // The join between the model and the other model
                  $relation = $this->$relation_method_name();
          
          
          Severity: Minor
          Found in src/LogChangeTrait.php - 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

          Severity
          Category
          Status
          Source
          Language