laravel/framework

View on GitHub

Showing 864 of 1,073 total issues

Method increment has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function increment($key, $value = 1)
    {
        try {
            $response = $this->dynamo->updateItem([
                'TableName' => $this->table,
Severity: Minor
Found in src/Illuminate/Cache/DynamoDbStore.php - About 1 hr to fix

    Method assertListening has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function assertListening($expectedEvent, $expectedListener)
        {
            foreach ($this->dispatcher->getListeners($expectedEvent) as $listenerClosure) {
                $actualListener = (new ReflectionFunction($listenerClosure))
                            ->getStaticVariables()['listener'];
    Severity: Minor
    Found in src/Illuminate/Support/Testing/Fakes/EventFake.php - About 1 hr to fix

      Method goodnight has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function goodnight()
          {
              if ($this->alreadySlept || ! $this->shouldSleep) {
                  return;
              }
      Severity: Minor
      Found in src/Illuminate/Support/Sleep.php - About 1 hr to fix

        Function escape has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public function escape($value, $binary = false)
            {
                if ($value === null) {
                    return 'null';
                } elseif ($binary) {
        Severity: Minor
        Found in src/Illuminate/Database/Connection.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 getOriginalColumnNameForCursorPagination has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function getOriginalColumnNameForCursorPagination($builder, string $parameter)
            {
                $columns = $builder instanceof Builder ? $builder->getQuery()->getColumns() : $builder->getColumns();
        
                if (! is_null($columns)) {
        Severity: Minor
        Found in src/Illuminate/Database/Concerns/BuildsQueries.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 orderedLazyById has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function orderedLazyById($chunkSize = 1000, $column = null, $alias = null, $descending = false)
            {
                if ($chunkSize < 1) {
                    throw new InvalidArgumentException('The chunk size should be at least 1');
                }
        Severity: Minor
        Found in src/Illuminate/Database/Concerns/BuildsQueries.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 orderedChunkById has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public function orderedChunkById($count, callable $callback, $column = null, $alias = null, $descending = false)
            {
                $column ??= $this->defaultKeyName();
                $alias ??= $column;
                $lastId = null;
        Severity: Minor
        Found in src/Illuminate/Database/Concerns/BuildsQueries.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 compileStatements has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function compileStatements($template)
            {
                preg_match_all('/\B@(@?\w+(?:::\w+)?)([ \t]*)(\( ( [\S\s]*? ) \))?/x', $template, $matches);
        
                $offset = 0;
        Severity: Minor
        Found in src/Illuminate/View/Compilers/BladeCompiler.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 displayCli has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function displayCli($class, $database, $table, $policy, $attributes, $relations, $events, $observers)
            {
                $this->newLine();
        
                $this->components->twoColumnDetail('<fg=green;options=bold>'.$class.'</>');
        Severity: Minor
        Found in src/Illuminate/Database/Console/ShowModelCommand.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 newMorphToMany has 10 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            protected function newMorphToMany(Builder $query, Model $parent, $name, $table, $foreignPivotKey,
                                              $relatedPivotKey, $parentKey, $relatedKey,
                                              $relationName = null, $inverse = false)
        Severity: Major
        Found in src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php - About 1 hr to fix

          Method __construct has 10 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public function __construct(Builder $query, Model $parent, $name, $table, $foreignPivotKey,
                                          $relatedPivotKey, $parentKey, $relatedKey, $relationName = null, $inverse = false)
          Severity: Major
          Found in src/Illuminate/Database/Eloquent/Relations/MorphToMany.php - About 1 hr to fix

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

                public function handle($request, Closure $next, $options = [])
                {
                    $response = $next($request);
            
                    if (! $request->isMethodCacheable() || (! $response->getContent() && ! $response instanceof BinaryFileResponse && ! $response instanceof StreamedResponse)) {
            Severity: Minor
            Found in src/Illuminate/Http/Middleware/SetCacheHeaders.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 withFakeBatch has 10 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function withFakeBatch(string $id = '',
                                              string $name = '',
                                              int $totalJobs = 0,
                                              int $pendingJobs = 0,
                                              int $failedJobs = 0,
            Severity: Major
            Found in src/Illuminate/Bus/Batchable.php - About 1 hr to fix

              Function take has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function take($limit)
                  {
                      if ($limit < 0) {
                          return new static(function () use ($limit) {
                              $limit = abs($limit);
              Severity: Minor
              Found in src/Illuminate/Collections/LazyCollection.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 groupBy has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function groupBy($groupBy, $preserveKeys = false)
                  {
                      if (! $this->useAsCallable($groupBy) && is_array($groupBy)) {
                          $nextGroups = $groupBy;
              
              
              Severity: Minor
              Found in src/Illuminate/Collections/Collection.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 replaceEmbeddedAttachments has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function replaceEmbeddedAttachments(string $renderedView, array $attachments)
                  {
                      if (preg_match_all('/<img.+?src=[\'"]cid:([^\'"]+)[\'"].*?>/i', $renderedView, $matches)) {
                          foreach (array_unique($matches[1]) as $image) {
                              foreach ($attachments as $attachment) {
              Severity: Minor
              Found in src/Illuminate/Mail/Mailer.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 addDependencyForCallParameter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected static function addDependencyForCallParameter(
                      $container,
                      $parameter,
                      array &$parameters,
                      &$dependencies
              Severity: Minor
              Found in src/Illuminate/Container/BoundMethod.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 sliding has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function sliding($size = 2, $step = 1)
                  {
                      return new static(function () use ($size, $step) {
                          $iterator = $this->getIterator();
              
              
              Severity: Minor
              Found in src/Illuminate/Collections/LazyCollection.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 random has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function random($array, $number = null, $preserveKeys = false)
                  {
                      $requested = is_null($number) ? 1 : $number;
              
                      $count = count($array);
              Severity: Minor
              Found in src/Illuminate/Collections/Arr.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 setUpTraits has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function setUpTraits()
                  {
                      $uses = array_flip(class_uses_recursive(static::class));
              
                      if (isset($uses[RefreshDatabase::class])) {

              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