flextype/flextype

View on GitHub

Showing 112 of 112 total issues

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

<?php

declare(strict_types=1);

/**
src/flextype/core/Console/Commands/Entries/EntriesDeleteCommand.php on lines 1..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 175.

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

<?php

declare(strict_types=1);

/**
src/flextype/core/Console/Commands/Entries/EntrieHasCommand.php on lines 1..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 175.

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

    function imageFile(string $file, array $options = [])
    {
        $image = Image::make($file);

        if (count($options) === 0) {
Severity: Major
Found in src/flextype/helpers/image.php - About 4 hrs to fix

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

    emitter()->addListener('onEntriesFetchSingleHasResult', static function (): void {
    
        if (! entries()->registry()->get('methods.fetch.collection.fields.published_at.enabled')) {
            return;
        }
    src/flextype/core/Entries/Fields/Default/CreatedAtField.php on lines 10..21

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

    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

    emitter()->addListener('onEntriesFetchSingleHasResult', static function (): void {
    
        if (! entries()->registry()->get('methods.fetch.collection.fields.created_at.enabled')) {
            return;
        }
    Severity: Major
    Found in src/flextype/core/Entries/Fields/Default/CreatedAtField.php and 1 other location - About 4 hrs to fix
    src/flextype/core/Entries/Fields/Default/PublishedAtField.php on lines 10..21

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

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

        protected function execute(InputInterface $input, OutputInterface $output): int
        {
            $io = new SymfonyStyle($input, $output);
    
            $result = Command::SUCCESS;
    Severity: Minor
    Found in src/flextype/core/Console/Commands/Cache/CacheClearCommand.php - About 4 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

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

        public function delete(string $id): bool
        {
            // Setup registry.
            $this->registry()->set('methods.delete', [
                    'collection' => $this->getCollectionOptions($id),
    Severity: Major
    Found in src/flextype/core/Entries/Entries.php and 1 other location - About 3 hrs to fix
    src/flextype/core/Entries/Entries.php on lines 691..711

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

    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

        public function has(string $id): bool
        {   
            // Setup registry.
            $this->registry()->set('methods.has', [
                    'collection' => $this->getCollectionOptions($id),
    Severity: Major
    Found in src/flextype/core/Entries/Entries.php and 1 other location - About 3 hrs to fix
    src/flextype/core/Entries/Entries.php on lines 593..615

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

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

        protected function execute(InputInterface $input, OutputInterface $output): int
        {
            $io = new SymfonyStyle($input, $output);
    
            $id      = $input->getArgument('id') ? $input->getArgument('id') : '';
    Severity: Minor
    Found in src/flextype/core/Console/Commands/Entries/EntrieFetchCommand.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 init has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function init(): void
        {
            // Set empty plugins item
            registry()->set('plugins', []);
    
    
    Severity: Minor
    Found in src/flextype/core/Plugins.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

    File flextype.php has 299 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    declare(strict_types=1);
    
    /**
    Severity: Minor
    Found in src/flextype/flextype.php - About 3 hrs to fix

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

          public function validateApiRequest(array $options)
          {
              if (! isset($options['api']) && ! is_string($options['api'])) {
                  return $this->getStatusCodeMessage(400);
              }
      Severity: Minor
      Found in src/flextype/core/Endpoints/Api.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 getBaseUrl has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          function getBaseUrl(): string
          {
              $baseUrl  = registry()->get('flextype.settings.base_url') ?? '';
              $basePath = registry()->get('flextype.settings.base_path') ?? '';
      
      
      Severity: Minor
      Found in src/flextype/helpers/urls.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 init has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function init(): void
          {
              // Set empty plugins item
              registry()->set('plugins', []);
      
      
      Severity: Major
      Found in src/flextype/core/Plugins.php - About 2 hrs to fix

        Method getValidPluginsDependencies has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getValidPluginsDependencies(array $plugins): array
            {
                // Set verified plugins array
                $verifiedPlugins = [];
        
        
        Severity: Major
        Found in src/flextype/core/Plugins.php - About 2 hrs to fix

          Method filterCollection has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function filterCollection($items = [], array $options = []): array
              {
                  $collection = arrays($items);
          
                  ! isset($options['return']) and $options['return'] = 'all';
          Severity: Major
          Found in src/flextype/helpers/arrays.php - About 2 hrs to fix

            Method install has 55 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function install(): ?WhoopsRun 
                {
                    if ($this->settings['enable'] === false) {
                        return null;
                    }
            Severity: Major
            Found in src/flextype/core/Whoops.php - About 2 hrs to fix

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

              emitter()->addListener('onEntriesCreate', static function (): void {
              
                  if (! entries()->registry()->get('methods.create.collection.fields.routable.enabled')) {
                      return;
                  }
              Severity: Major
              Found in src/flextype/core/Entries/Fields/Default/RoutableField.php and 1 other location - About 2 hrs to fix
              src/flextype/core/Entries/Fields/Default/RoutableField.php on lines 10..22

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

              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

              emitter()->addListener('onEntriesFetchSingleHasResult', static function (): void {
              
                  if (! entries()->registry()->get('methods.fetch.collection.fields.routable.enabled')) {
                      return;
                  }
              Severity: Major
              Found in src/flextype/core/Entries/Fields/Default/RoutableField.php and 1 other location - About 2 hrs to fix
              src/flextype/core/Entries/Fields/Default/RoutableField.php on lines 24..35

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

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

                  protected function execute(InputInterface $input, OutputInterface $output): int
                  {
                      $io = new SymfonyStyle($input, $output);
              
                      $id      = $input->getArgument('id') ? $input->getArgument('id') : '';
              Severity: Major
              Found in src/flextype/core/Console/Commands/Entries/EntrieFetchCommand.php - About 2 hrs to fix
                Severity
                Category
                Status
                Source
                Language