Jagepard/Rudra-Framework

View on GitHub

Showing 18 of 18 total issues

Similar blocks of code found in 5 locations. Consider refactoring.
Open

<?php

namespace App\Ship\Command;

use App\Ship\Utils\FileCreator;
Severity: Major
Found in app/Ship/Command/CreateMiddlewareCommand.php and 4 other locations - About 7 hrs to fix
app/Ship/Command/CreateFactoryCommand.php on lines 1..62
app/Ship/Command/CreateInterfaceCommand.php on lines 1..59
app/Ship/Command/CreateListenerCommand.php on lines 1..59
app/Ship/Command/CreateObserverCommand.php on lines 1..64

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 226.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 5 locations. Consider refactoring.
Open

<?php

namespace App\Ship\Command;

use App\Ship\Utils\FileCreator;
Severity: Major
Found in app/Ship/Command/CreateFactoryCommand.php and 4 other locations - About 7 hrs to fix
app/Ship/Command/CreateInterfaceCommand.php on lines 1..59
app/Ship/Command/CreateListenerCommand.php on lines 1..59
app/Ship/Command/CreateMiddlewareCommand.php on lines 1..71
app/Ship/Command/CreateObserverCommand.php on lines 1..64

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 226.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 5 locations. Consider refactoring.
Open

<?php

namespace App\Ship\Command;

use App\Ship\Utils\FileCreator;
Severity: Major
Found in app/Ship/Command/CreateObserverCommand.php and 4 other locations - About 7 hrs to fix
app/Ship/Command/CreateFactoryCommand.php on lines 1..62
app/Ship/Command/CreateInterfaceCommand.php on lines 1..59
app/Ship/Command/CreateListenerCommand.php on lines 1..59
app/Ship/Command/CreateMiddlewareCommand.php on lines 1..71

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 226.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 5 locations. Consider refactoring.
Open

<?php

namespace App\Ship\Command;

use App\Ship\Utils\FileCreator;
Severity: Major
Found in app/Ship/Command/CreateListenerCommand.php and 4 other locations - About 7 hrs to fix
app/Ship/Command/CreateFactoryCommand.php on lines 1..62
app/Ship/Command/CreateInterfaceCommand.php on lines 1..59
app/Ship/Command/CreateMiddlewareCommand.php on lines 1..71
app/Ship/Command/CreateObserverCommand.php on lines 1..64

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 226.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 5 locations. Consider refactoring.
Open

<?php

namespace App\Ship\Command;

use App\Ship\Utils\FileCreator;
Severity: Major
Found in app/Ship/Command/CreateInterfaceCommand.php and 4 other locations - About 7 hrs to fix
app/Ship/Command/CreateFactoryCommand.php on lines 1..62
app/Ship/Command/CreateListenerCommand.php on lines 1..59
app/Ship/Command/CreateMiddlewareCommand.php on lines 1..71
app/Ship/Command/CreateObserverCommand.php on lines 1..64

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 226.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        if (!empty($container)) {
            $fileList  = array_slice(scandir(str_replace('/', DIRECTORY_SEPARATOR, Rudra::config()->get('app.path') . "/app/Containers/" . $container . "/Seed/")), 2);
            $namespace = "App\\Containers\\$container\\Seed\\";
        } else {
            $fileList  = array_slice(scandir(str_replace('/', DIRECTORY_SEPARATOR, Rudra::config()->get('app.path') . "/app/Ship/Seed/")), 2);
Severity: Major
Found in app/Ship/Command/SeedCommand.php and 1 other location - About 3 hrs to fix
app/Ship/Command/MigrateCommand.php on lines 22..28

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 146.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        if (!empty($container)) {
            $fileList  = array_slice(scandir(str_replace('/', DIRECTORY_SEPARATOR, Rudra::config()->get('app.path') . "/app/Containers/" . $container . "/Migration/")), 2);
            $namespace = "App\\Containers\\$container\\Migration\\";
        } else {
            $fileList  = array_slice(scandir(str_replace('/', DIRECTORY_SEPARATOR, Rudra::config()->get('app.path') . "/app/Ship/Migration/")), 2);
Severity: Major
Found in app/Ship/Command/MigrateCommand.php and 1 other location - About 3 hrs to fix
app/Ship/Command/SeedCommand.php on lines 22..28

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 146.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method createClass has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function createClass(string $className, string $table, string $namespace, bool $multiline = false): string
    {
        if ($multiline) {
            return <<<EOT
<?php
Severity: Minor
Found in app/Ship/Command/CreateSeedCommand.php - About 1 hr to fix

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

        public function actionIndex(): void
        {
            Cli::printer("Enter table name: ", "magneta");
            $table = str_replace(PHP_EOL, "", Cli::reader());
    
    
    Severity: Minor
    Found in app/Ship/Command/CreateMigrationCommand.php - About 1 hr to fix

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

          public static function renderLinks(array $links, string $page, $pg_limit, $uri)
          {
              $last = array_key_last($links) + 1;
              ?>
              <!-- FIRST -->
      Severity: Minor
      Found in app/Containers/Web/UI/UI.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 createClass has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function createClass(string $controllerPrefix, string $container): string
          {
              $url = strtolower("$container/$controllerPrefix");
      
              if (Rudra::config()->get("attributes")) {
      Severity: Minor
      Found in app/Ship/Command/CreateControllerCommand.php - About 1 hr to fix

        Function actionIndex has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function actionIndex(): void
            {
                Cli::printer("Enter table name: ", "magneta");
                $table = str_replace(PHP_EOL, "", Cli::reader());
        
        
        Severity: Minor
        Found in app/Ship/Command/CreateMigrationCommand.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 actionIndex has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function actionIndex(): void
            {
                Cli::printer("Enter container (empty for Ship): ", "magneta");
                $container = ucfirst(str_replace(PHP_EOL, "", Cli::reader()));
        
        
        Severity: Minor
        Found in app/Ship/Command/SeedCommand.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 actionIndex has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function actionIndex(): void
            {
                Cli::printer("Enter container name: ", "magneta");
                $container = ucfirst(str_replace(PHP_EOL, "", Cli::reader()));
                $className = $container . 'Controller';
        Severity: Minor
        Found in app/Ship/Command/CreateContainerCommand.php - About 1 hr to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                      } elseif (Rudra::get("DSN")->getAttribute(\PDO::ATTR_DRIVER_NAME) === "sqlite") {
                          $this->writeFile([str_replace('/', DIRECTORY_SEPARATOR, Rudra::config()->get('app.path') . "/app/Containers/" . $container . "/Migration/"), "{$className}_migration.php"],
                              $this->createSqliteMigration($className, $table, $namespace)
                          );
                      }
          Severity: Minor
          Found in app/Ship/Command/CreateMigrationCommand.php and 1 other location - About 45 mins to fix
          app/Ship/Command/CreateMigrationCommand.php on lines 35..39

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 96.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                      } elseif (Rudra::get("DSN")->getAttribute(\PDO::ATTR_DRIVER_NAME) === "pgsql") {
                          $this->writeFile([str_replace('/', DIRECTORY_SEPARATOR, Rudra::config()->get('app.path') . "/app/Containers/" . $container . "/Migration/"), "{$className}_migration.php"],
                              $this->createPgsqlMigration($className, $table, $namespace)
                          );
                      } elseif (Rudra::get("DSN")->getAttribute(\PDO::ATTR_DRIVER_NAME) === "sqlite") {
          Severity: Minor
          Found in app/Ship/Command/CreateMigrationCommand.php and 1 other location - About 45 mins to fix
          app/Ship/Command/CreateMigrationCommand.php on lines 39..43

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 96.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

              public function actionIndex(): void
              {
                  Cli::printer("Enter container (empty for Ship): ", "magneta");
                  $container = ucfirst(str_replace(PHP_EOL, "", Cli::reader()));
          
          
          Severity: Minor
          Found in app/Ship/Command/MigrateCommand.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 handle404 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function handle404($data, string $type = 'db', array $page = []): void
              {
                  if ($type == 'db') {
                      if (count($data) < 1 || !$data) {
                          throw new RouterException('404');
          Severity: Minor
          Found in app/Ship/Errors/Controller/HttpErrorsController.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

          Severity
          Category
          Status
          Source
          Language