sroehrl/neoan.io-lenkrad-core

View on GitHub

Showing 31 of 31 total issues

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

<?php

namespace Neoan\Cli\Create;

use Neoan\NeoanApp;
Severity: Major
Found in src/Cli/Create/CreateGuardCommand.php and 2 other locations - About 4 hrs to fix
src/Cli/Create/CreateControllerCommand.php on lines 1..42
src/Cli/Create/CreateModelCommand.php on lines 1..42

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 163.

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 3 locations. Consider refactoring.
Open

<?php

namespace Neoan\Cli\Create;

use Neoan\NeoanApp;
Severity: Major
Found in src/Cli/Create/CreateControllerCommand.php and 2 other locations - About 4 hrs to fix
src/Cli/Create/CreateGuardCommand.php on lines 1..42
src/Cli/Create/CreateModelCommand.php on lines 1..42

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 163.

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 3 locations. Consider refactoring.
Open

<?php

namespace Neoan\Cli\Create;

use Neoan\NeoanApp;
Severity: Major
Found in src/Cli/Create/CreateModelCommand.php and 2 other locations - About 4 hrs to fix
src/Cli/Create/CreateControllerCommand.php on lines 1..42
src/Cli/Create/CreateGuardCommand.php on lines 1..42

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 163.

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 __invoke has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    public function __invoke(): static
    {
        $reflection = new \ReflectionClass(static::class);

        foreach ($reflection->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
Severity: Minor
Found in src/Request/RequestGuard.php - About 3 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 updateTable has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    function updateTable(): void
    {
        $doubleDown = [];
        $sql = "CREATE TABLE `{$this->interimTableName}`(";
        foreach ($this->interpreter->filteredProperties() as $i => $property) {
Severity: Minor
Found in src/Cli/MigrationHelper/SqLiteMigration.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

Request has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

class Request implements RequestInterface
{
    private static ?RequestInterface $instance = null;

    public string $requestMethod;
Severity: Minor
Found in src/Request/Request.php - About 2 hrs to fix

    Function initialize has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        public function initialize(array $staticModel = []): Model
        {
    
            foreach ($this->parsedModel as $property) {
    
    
    Severity: Minor
    Found in src/Model/Interpreter.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

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

        protected function execute(InputInterface $input, OutputInterface $output): int
        {
    
            $modelName = $input->getArgument('model');
            $sanitizedModelName = preg_replace('/[\/\\\]/', '_', $modelName);
    Severity: Minor
    Found in src/Cli/MigrateCommand.php - About 1 hr to fix

      Method updateTable has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function updateTable(): void
          {
              $doubleDown = [];
              $sql = "CREATE TABLE `{$this->interimTableName}`(";
              foreach ($this->interpreter->filteredProperties() as $i => $property) {
      Severity: Minor
      Found in src/Cli/MigrationHelper/SqLiteMigration.php - About 1 hr to fix

        Function removePrivateAttributes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            public function removePrivateAttributes(Model &$instance) : void
            {
                foreach ($this->reflection->properties as $property){
                    foreach ($property->getAttributes() as $attribute){
                        if($attribute->newInstance()->getType() === AttributeType::PRIVATE && $property->isPublic() && !$property->isReadOnly()) {
        Severity: Minor
        Found in src/Model/Interpreter.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 execute has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function execute(InputInterface $input, OutputInterface $output): int
            {
        
                $modelName = $input->getArgument('model');
                $sanitizedModelName = preg_replace('/[\/\\\]/', '_', $modelName);
        Severity: Minor
        Found in src/Cli/MigrateCommand.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 getDependencies has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getDependencies($parameters): array
            {
                $dependencies = [];
                foreach ($parameters as $parameter) {
                    foreach($this->getParameterTypes($parameter) as $dependency) {
        Severity: Minor
        Found in src/Provider/DefaultProvider.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 migrateOne has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function migrateOne($modelName): void
            {
                if ($this->input->getArgument('dialect') === 'sqlite') {
                    $migrate = new SqLiteMigration(new ModelInterpreter($modelName), $this->input->getOption('with-copy'));
                } else {
        Severity: Minor
        Found in src/Cli/MigrateAllCommand.php - About 1 hr to fix

          Method parseClass has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function parseClass(): array
              {
                  $this->parsedClass[] = [];
                  foreach ($this->properties as $i => $property) {
                      $attributes = $this->propertyMatchList[$property->getName()];
          Severity: Minor
          Found in src/Helper/AttributeHelper.php - About 1 hr to fix

            Method __invoke has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function __invoke(): static
                {
                    $reflection = new \ReflectionClass(static::class);
            
                    foreach ($reflection->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
            Severity: Minor
            Found in src/Request/RequestGuard.php - About 1 hr to fix

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

                  public function parseClass(): array
                  {
                      $this->parsedClass[] = [];
                      foreach ($this->properties as $i => $property) {
                          $attributes = $this->propertyMatchList[$property->getName()];
              Severity: Minor
              Found in src/Helper/AttributeHelper.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 migrateOne has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function migrateOne($modelName): void
                  {
                      if ($this->input->getArgument('dialect') === 'sqlite') {
                          $migrate = new SqLiteMigration(new ModelInterpreter($modelName), $this->input->getOption('with-copy'));
                      } else {
              Severity: Minor
              Found in src/Cli/MigrateAllCommand.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 __construct has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function __construct(string $message)
                  {
                      Event::dispatch(GenericEvent::UNRECOVERABLE_ERROR,[
                          self::class => $message
                      ]);
              Severity: Minor
              Found in src/Errors/SystemError.php - About 1 hr to fix

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

                    public function __construct(string $message)
                    {
                        Event::dispatch(GenericEvent::UNRECOVERABLE_ERROR,[
                            self::class => $message
                        ]);
                Severity: Minor
                Found in src/Errors/SystemError.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 initialize has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function initialize(array $staticModel = []): Model
                    {
                
                        foreach ($this->parsedModel as $property) {
                
                
                Severity: Minor
                Found in src/Model/Interpreter.php - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language