laravel/framework

View on GitHub

Showing 864 of 1,073 total issues

Function addCastAttributesToArray has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    protected function addCastAttributesToArray(array $attributes, array $mutatedAttributes)
    {
        foreach ($this->getCasts() as $key => $value) {
            if (! array_key_exists($key, $attributes) ||
                in_array($key, $mutatedAttributes)) {
Severity: Minor
Found in src/Illuminate/Database/Eloquent/Concerns/HasAttributes.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 resolveDumpSource has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function resolveDumpSource()
    {
        if (static::$dumpSourceResolver === false) {
            return null;
        }
Severity: Minor
Found in src/Illuminate/Foundation/Concerns/ResolvesDumpSource.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

File Mailer.php has 280 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Illuminate\Mail;

use Closure;
Severity: Minor
Found in src/Illuminate/Mail/Mailer.php - About 2 hrs to fix

    Method handle has 68 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function handle()
        {
            if (! is_dir($stubsPath = $this->laravel->basePath('stubs'))) {
                (new Filesystem)->makeDirectory($stubsPath);
            }
    Severity: Major
    Found in src/Illuminate/Foundation/Console/StubPublishCommand.php - About 2 hrs to fix

      File FormatsMessages.php has 280 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace Illuminate\Validation\Concerns;
      
      use Closure;
      Severity: Minor
      Found in src/Illuminate/Validation/Concerns/FormatsMessages.php - About 2 hrs to fix

        Method paginateUsingCursor has 67 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function paginateUsingCursor($perPage, $columns = ['*'], $cursorName = 'cursor', $cursor = null)
            {
                if (! $cursor instanceof Cursor) {
                    $cursor = is_string($cursor)
                        ? Cursor::fromEncoded($cursor)
        Severity: Major
        Found in src/Illuminate/Database/Concerns/BuildsQueries.php - About 2 hrs to fix

          File InteractsWithInput.php has 278 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          namespace Illuminate\Http\Concerns;
          
          use Illuminate\Http\UploadedFile;
          Severity: Minor
          Found in src/Illuminate/Http/Concerns/InteractsWithInput.php - About 2 hrs to fix

            Component has 24 functions (exceeds 20 allowed). Consider refactoring.
            Open

            abstract class Component
            {
                /**
                 * The properties / methods that should not be exposed to the component.
                 *
            Severity: Minor
            Found in src/Illuminate/View/Component.php - About 2 hrs to fix

              DatabaseManager has 24 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class DatabaseManager implements ConnectionResolverInterface
              {
                  use Macroable {
                      __call as macroCall;
                  }
              Severity: Minor
              Found in src/Illuminate/Database/DatabaseManager.php - About 2 hrs to fix

                BelongsTo has 24 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class BelongsTo extends Relation
                {
                    use ComparesRelatedModels,
                        InteractsWithDictionary,
                        SupportsDefaultModels;
                Severity: Minor
                Found in src/Illuminate/Database/Eloquent/Relations/BelongsTo.php - About 2 hrs to fix

                  Consider simplifying this complex logical expression.
                  Open

                          if (($this->option('name') && ! Str::contains((string) $route['name'], $this->option('name'))) ||
                              ($this->option('path') && ! Str::contains($route['uri'], $this->option('path'))) ||
                              ($this->option('method') && ! Str::contains($route['method'], strtoupper($this->option('method')))) ||
                              ($this->option('domain') && ! Str::contains((string) $route['domain'], $this->option('domain'))) ||
                              ($this->option('except-vendor') && $route['vendor']) ||
                  Severity: Critical
                  Found in src/Illuminate/Foundation/Console/RouteListCommand.php - About 2 hrs to fix

                    FilesystemManager has 24 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    class FilesystemManager implements FactoryContract
                    {
                        /**
                         * The application instance.
                         *
                    Severity: Minor
                    Found in src/Illuminate/Filesystem/FilesystemManager.php - About 2 hrs to fix

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

                          public function handle($request, Closure $next)
                          {
                              if ($this->inExceptArray($request)) {
                                  return $next($request);
                              }

                      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 displayForCli has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function displayForCli(array $data)
                          {
                              $platform = $data['platform'];
                              $tables = $data['tables'];
                              $views = $data['views'] ?? null;
                      Severity: Major
                      Found in src/Illuminate/Database/Console/ShowCommand.php - About 2 hrs to fix

                        Method causedByLostConnection has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function causedByLostConnection(Throwable $e)
                            {
                                $message = $e->getMessage();
                        
                                return Str::contains($message, [
                        Severity: Major
                        Found in src/Illuminate/Database/DetectsLostConnections.php - About 2 hrs to fix

                          Method withoutVite has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function withoutVite()
                              {
                                  if ($this->originalVite == null) {
                                      $this->originalVite = app(Vite::class);
                                  }
                          Severity: Major
                          Found in src/Illuminate/Foundation/Testing/Concerns/InteractsWithContainer.php - About 2 hrs to fix

                            File DocsCommand.php has 273 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            <?php
                            
                            namespace Illuminate\Foundation\Console;
                            
                            use Carbon\CarbonInterval;
                            Severity: Minor
                            Found in src/Illuminate/Foundation/Console/DocsCommand.php - About 2 hrs to fix

                              File MailFake.php has 273 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              <?php
                              
                              namespace Illuminate\Support\Testing\Fakes;
                              
                              use Closure;
                              Severity: Minor
                              Found in src/Illuminate/Support/Testing/Fakes/MailFake.php - About 2 hrs to fix

                                MorphTo has 23 functions (exceeds 20 allowed). Consider refactoring.
                                Open

                                class MorphTo extends BelongsTo
                                {
                                    use InteractsWithDictionary;
                                
                                    /**
                                Severity: Minor
                                Found in src/Illuminate/Database/Eloquent/Relations/MorphTo.php - About 2 hrs to fix

                                  Grammar has 23 functions (exceeds 20 allowed). Consider refactoring.
                                  Open

                                  abstract class Grammar extends BaseGrammar
                                  {
                                      use CompilesJsonPaths;
                                  
                                      /**
                                  Severity: Minor
                                  Found in src/Illuminate/Database/Schema/Grammars/Grammar.php - About 2 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language