app/Console/Commands/InitCommand.php

Summary

Maintainability
C
1 day
Test Coverage

File InitCommand.php has 282 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace App\Console\Commands;

use App\Console\Commands\Traits\AskForPassword;
Severity: Minor
Found in app/Console/Commands/InitCommand.php - About 2 hrs to fix

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

        public function handle(): int
        {
            $this->alert('KOEL INSTALLATION WIZARD');
            $this->info(
                'As a reminder, you can always install/upgrade manually following the guide at '
    Severity: Minor
    Found in app/Console/Commands/InitCommand.php - About 1 hr to fix

      Method setUpDatabase has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function setUpDatabase(): void
          {
              $config = [
                  'DB_HOST' => '',
                  'DB_PORT' => '',
      Severity: Minor
      Found in app/Console/Commands/InitCommand.php - About 1 hr to fix

        Function maybeSetUpDatabase has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            private function maybeSetUpDatabase(): void
            {
                $attempt = 0;
        
                while (true) {
        Severity: Minor
        Found in app/Console/Commands/InitCommand.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 maybeSetUpDatabase has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function maybeSetUpDatabase(): void
            {
                $attempt = 0;
        
                while (true) {
        Severity: Minor
        Found in app/Console/Commands/InitCommand.php - About 1 hr to fix

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

                  private MediaCacheService $mediaCacheService,
                  private Artisan $artisan,
                  private Hash $hash,
                  private DotenvEditor $dotenvEditor,
                  private DB $db,
          Severity: Minor
          Found in app/Console/Commands/InitCommand.php - About 45 mins to fix

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

                private function maybeSetMediaPath(): void
                {
                    if (Setting::get('media_path')) {
                        return;
                    }
            Severity: Minor
            Found in app/Console/Commands/InitCommand.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

            There are no issues that match your filters.

            Category
            Status