laravel/framework

View on GitHub
src/Illuminate/Database/Eloquent/Model.php

Summary

Maintainability
F
6 days
Test Coverage

Model has 146 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class Model implements Arrayable, ArrayAccess, CanBeEscapedWhenCastToString, HasBroadcastChannel, Jsonable, JsonSerializable, QueueableEntity, Stringable, UrlRoutable
{
    use Concerns\HasAttributes,
        Concerns\HasEvents,
        Concerns\HasGlobalScopes,
Severity: Major
Found in src/Illuminate/Database/Eloquent/Model.php - About 2 days to fix

    File Model.php has 1000 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace Illuminate\Database\Eloquent;
    
    use ArrayAccess;
    Severity: Major
    Found in src/Illuminate/Database/Eloquent/Model.php - About 2 days to fix

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

          public function fill(array $attributes)
          {
              $totallyGuarded = $this->totallyGuarded();
      
              $fillable = $this->fillableFromArray($attributes);
      Severity: Minor
      Found in src/Illuminate/Database/Eloquent/Model.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

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

          public function getQueueableRelations()
          {
              $relations = [];
      
              foreach ($this->getRelations() as $key => $relation) {
      Severity: Minor
      Found in src/Illuminate/Database/Eloquent/Model.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 fill has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function fill(array $attributes)
          {
              $totallyGuarded = $this->totallyGuarded();
      
              $fillable = $this->fillableFromArray($attributes);
      Severity: Minor
      Found in src/Illuminate/Database/Eloquent/Model.php - About 1 hr to fix

        Method newPivot has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function newPivot(self $parent, array $attributes, $table, $exists, $using = null)
        Severity: Minor
        Found in src/Illuminate/Database/Eloquent/Model.php - About 35 mins to fix

          Function save has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function save(array $options = [])
              {
                  $this->mergeAttributesFromCachedCasts();
          
                  $query = $this->newModelQuery();
          Severity: Minor
          Found in src/Illuminate/Database/Eloquent/Model.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 push has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function push()
              {
                  if (! $this->save()) {
                      return false;
                  }
          Severity: Minor
          Found in src/Illuminate/Database/Eloquent/Model.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 performInsert has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function performInsert(Builder $query)
              {
                  if ($this->usesUniqueIds()) {
                      $this->setUniqueIds();
                  }
          Severity: Minor
          Found in src/Illuminate/Database/Eloquent/Model.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 destroy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function destroy($ids)
              {
                  if ($ids instanceof EloquentCollection) {
                      $ids = $ids->modelKeys();
                  }
          Severity: Minor
          Found in src/Illuminate/Database/Eloquent/Model.php - 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

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

              protected static function bootTraits()
              {
                  $class = static::class;
          
                  $booted = [];
          Severity: Minor
          Found in src/Illuminate/Database/Eloquent/Model.php - 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

          There are no issues that match your filters.

          Category
          Status