flextype/flextype

View on GitHub

Showing 112 of 112 total issues

Function loadCollectionsEvents has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    private function loadCollectionsEvents(): void
    {
        $events = [];

        if (! isset($this->options['collections']) ||
Severity: Minor
Found in src/flextype/core/Entries/Entries.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 validateApiRequest has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function validateApiRequest(array $options)
    {
        if (! isset($options['api']) && ! is_string($options['api'])) {
            return $this->getStatusCodeMessage(400);
        }
Severity: Major
Found in src/flextype/core/Endpoints/Api.php - About 2 hrs to fix

    Method execute has 49 lines of code (exceeds 25 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 1 hr to fix

      Function loadCollectionsFields has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          private function loadCollectionsFields(): void
          {
              $fields = [];
      
              if (! isset($this->options['collections']) ||
      Severity: Minor
      Found in src/flextype/core/Entries/Entries.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

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

              if (isset($options['heighten'])) {
                  $image->heighten($options['heighten']['height'],
                                  function ($constraint) use ($options) {
                                      if (isset($options['heighten']['constraint']) &&
                                          is_array($options['heighten']['constraint'])) {
      Severity: Major
      Found in src/flextype/helpers/image.php and 1 other location - About 1 hr to fix
      src/flextype/helpers/image.php on lines 85..97

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

      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 (isset($options['widen'])) {
                  $image->heighten($options['widen']['width'], 
                                  function ($constraint) use ($options) {
                                      if (isset($options['widen']['constraint']) &&
                                          is_array($options['widen']['constraint'])) {
      Severity: Major
      Found in src/flextype/helpers/image.php and 1 other location - About 1 hr to fix
      src/flextype/helpers/image.php on lines 71..83

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

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

          public function install(): ?WhoopsRun 
          {
              if ($this->settings['enable'] === false) {
                  return null;
              }
      Severity: Minor
      Found in src/flextype/core/Whoops.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 getBaseUrl has 43 lines of code (exceeds 25 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 1 hr to fix

        Method move has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function move(string $id, string $newID): bool
            {  
                // Collections validation helper.
                // Check if collections are identical.
                $isValidCollections = function ($id, $newID) {
        Severity: Minor
        Found in src/flextype/core/Entries/Entries.php - About 1 hr to fix

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

                  if ($input->getOption('find-depth-from') || $input->getOption('find-depth-to')) {
                      $options['find']['depth'] = [];
                      $input->getOption('find-depth-from') and array_push($options['find']['depth'], $input->getOption('find-depth-from'));
                      $input->getOption('find-depth-to') and array_push($options['find']['depth'], $input->getOption('find-depth-to'));
                  }
          src/flextype/core/Console/Commands/Entries/EntrieFetchCommand.php on lines 65..69
          src/flextype/core/Console/Commands/Entries/EntrieFetchCommand.php on lines 71..75

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

          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

                  if ($input->getOption('find-size-from') || $input->getOption('find-size-to')) {
                      $options['find']['size'] = [];
                      $input->getOption('find-size-from') and array_push($options['find']['size'], $input->getOption('find-size-from'));
                      $input->getOption('find-size-to') and array_push($options['find']['size'], $input->getOption('find-size-to'));
                  }
          src/flextype/core/Console/Commands/Entries/EntrieFetchCommand.php on lines 59..63
          src/flextype/core/Console/Commands/Entries/EntrieFetchCommand.php on lines 65..69

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

          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

                  if ($input->getOption('find-date-from') || $input->getOption('find-date-to')) {
                      $options['find']['date'] = [];
                      $input->getOption('find-date-from') and array_push($options['find']['date'], $input->getOption('find-date-from'));
                      $input->getOption('find-date-to') and array_push($options['find']['date'], $input->getOption('find-date-to'));
                  }
          src/flextype/core/Console/Commands/Entries/EntrieFetchCommand.php on lines 59..63
          src/flextype/core/Console/Commands/Entries/EntrieFetchCommand.php on lines 71..75

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

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

              public function copy(string $id, string $newID): bool
              {  
                  // Collections validation helper.
                  // Check if collections are identical.
                  $isValidCollections = function ($id, $newID) {
          Severity: Minor
          Found in src/flextype/core/Entries/Entries.php - About 1 hr to fix

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

                    if ($input->getOption('data')) {
                        if (filesystem()->directory(PATH['tmp'] . '/data')->exists()) {
                            if (filesystem()->directory(PATH['tmp'] . '/data')->delete()) {
                                $io->success('Data were successfully cleared from the cache.');
                                $result = Command::SUCCESS;
            src/flextype/core/Console/Commands/Cache/CacheClearCommand.php on lines 47..57
            src/flextype/core/Console/Commands/Cache/CacheClearCommand.php on lines 59..69

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

            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

                    if ($input->getOption('routes')) {
                        if (filesystem()->directory(PATH['tmp'] . '/routes')->exists()) {
                            if (filesystem()->directory(PATH['tmp'] . '/routes')->delete()) {
                                $io->success('Routes were successfully cleared from the cache.');
                                $result = Command::SUCCESS;
            src/flextype/core/Console/Commands/Cache/CacheClearCommand.php on lines 35..45
            src/flextype/core/Console/Commands/Cache/CacheClearCommand.php on lines 47..57

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

            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

                    if ($input->getOption('config')) {
                        if (filesystem()->directory(PATH['tmp'] . '/config')->exists()) {
                            if (filesystem()->directory(PATH['tmp'] . '/config')->delete()) {
                                $io->success('Config were successfully cleared from the cache.');
                                $result = Command::SUCCESS;
            src/flextype/core/Console/Commands/Cache/CacheClearCommand.php on lines 35..45
            src/flextype/core/Console/Commands/Cache/CacheClearCommand.php on lines 59..69

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

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

                public function initShortcodes(): void
                {
                    $shortcodes = registry()->get('flextype.settings.parsers.shortcodes.shortcodes');
            
                    if (
            Severity: Minor
            Found in src/flextype/core/Parsers/Shortcodes.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 decode has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function decode(string $input)
                {
                    $cache  = registry()->get('flextype.settings.serializers.yaml.decode.cache');
                    $flags  = registry()->get('flextype.settings.serializers.yaml.decode.flags');
                    $native = registry()->get('flextype.settings.serializers.yaml.decode.native');
            Severity: Minor
            Found in src/flextype/core/Serializers/Yaml.php - About 1 hr to fix

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

                  public function getPluginsDictionary(array $pluginsList, string $locale): array
                  {
                      foreach ($pluginsList as $plugin) {
                          $languageFile = PATH['project'] . '/plugins/' . $plugin['dirname'] . '/lang/' . $locale . '.yaml';
              
              
              Severity: Minor
              Found in src/flextype/core/Plugins.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 upload has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  function upload(array $file, string $folder): UploadResultFile
                  {
                      $settings = registry()->get('flextype.settings.upload');
              
                      $uploadFolder = strings(PATH['project']  . '/' . $settings['directory'] . '/' . $folder . '/')->reduceSlashes()->toString();
              Severity: Minor
              Found in src/flextype/helpers/upload.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

              Severity
              Category
              Status
              Source
              Language