dothiv/DothivContentfulBundle

View on GitHub

Showing 28 of 28 total issues

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

<?php

namespace Dothiv\Bundle\ContentfulBundle\Command;

use Doctrine\Common\Cache\Cache;
Severity: Major
Found in Command/ListEntriesCommand.php and 1 other location - About 6 hrs to fix
Command/ListContentTypesCommand.php on lines 1..49

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

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

namespace Dothiv\Bundle\ContentfulBundle\Command;

use Doctrine\Common\Cache\Cache;
Severity: Major
Found in Command/ListContentTypesCommand.php and 1 other location - About 6 hrs to fix
Command/ListEntriesCommand.php on lines 1..49

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

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

    protected function getValue($value, $spaceId, $locale)
    {
        if (is_scalar($value)) {
            return Option::fromValue($value);
        }
Severity: Minor
Found in Output/ViewBuilder.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

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

<?php

namespace Dothiv\Bundle\ContentfulBundle\Listener;

use Dothiv\Bundle\ContentfulBundle\Event\ContentfulAssetEvent;
Severity: Major
Found in Listener/SyncAsset.php and 1 other location - About 3 hrs to fix
Listener/SyncEntry.php on lines 1..44

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

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

namespace Dothiv\Bundle\ContentfulBundle\Listener;

use Dothiv\Bundle\ContentfulBundle\Event\ContentfulEntryEvent;
Severity: Major
Found in Listener/SyncEntry.php and 1 other location - About 3 hrs to fix
Listener/SyncAsset.php on lines 1..44

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

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

    public function getEntry(\stdClass $data)
    {
        $postFill = function () {
        };
        switch ($data->sys->type) {
Severity: Minor
Found in Adapter/ContentfulEntityReader.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 webhookAction has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function webhookAction(Request $request)
    {
        $topic = $request->headers->get('X-Contentful-Topic');
        if (!$topic) {
            $this->log('Missing X-Contentful-Topic header!');
Severity: Major
Found in Controller/WebhookController.php - About 2 hrs to fix

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

        public function scaleAsset(ContentfulAsset $asset)
        {
            if (!isset($asset->file)) {
                $this->log('Asset %s has no file.', $asset);
                return;
    Severity: Minor
    Found in Output/ImageAssetScaler.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 getValue has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function getValue($value, $spaceId, $locale)
        {
            if (is_scalar($value)) {
                return Option::fromValue($value);
            }
    Severity: Minor
    Found in Output/ViewBuilder.php - About 1 hr to fix

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

      <?php
      
      namespace Dothiv\Bundle\ContentfulBundle\Command;
      
      use Doctrine\Common\Cache\Cache;
      Severity: Major
      Found in Command/AssetCacheCommand.php and 1 other location - About 1 hr to fix
      Command/ScaleAssetsImagesCommand.php on lines 1..34

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

      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
      
      namespace Dothiv\Bundle\ContentfulBundle\Command;
      
      use Doctrine\Common\Cache\Cache;
      Severity: Major
      Found in Command/ScaleAssetsImagesCommand.php and 1 other location - About 1 hr to fix
      Command/AssetCacheCommand.php on lines 1..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 116.

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

          public function scale(\SplFileInfo $source, ThumbnailConfiguration $size, \SplFileInfo $target)
          {
              $img = $this->imagine->open($source->getPathname());
      
              if ($size->getThumbnail()) {
      Severity: Minor
      Found in Service/ImageScaler/ImagineImageScaler.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 getEntry has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getEntry(\stdClass $data)
          {
              $postFill = function () {
              };
              switch ($data->sys->type) {
      Severity: Minor
      Found in Adapter/ContentfulEntityReader.php - About 1 hr to fix

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

            protected function localize(ContentfulItem $entry, $locale)
            {
                $fields = array();
                foreach ($entry->getFields() as $k => $v) {
                    $localValue = isset($v[$locale]) ? $v[$locale] : null;
        Severity: Minor
        Found in Output/ViewBuilder.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 scale has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function scale(\SplFileInfo $source, ThumbnailConfiguration $size, \SplFileInfo $target)
            {
                $img = $this->imagine->open($source->getPathname());
        
                if ($size->getThumbnail()) {
        Severity: Minor
        Found in Service/ImageScaler/ImagineImageScaler.php - About 1 hr to fix

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

              public function onContentTypeSync(ContentfulContentTypeEvent $event)
              {
                  $syncContentType     = $event->getContentType();
                  $contentTypeOptional = $this->contentTypeRepo->findNewestById($syncContentType->getSpaceId(), $syncContentType->getId());
                  if ($contentTypeOptional->isEmpty()) {
          Severity: Minor
          Found in Listener/SyncContentType.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 cache has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function cache(ContentfulAsset $asset)
              {
                  if (!isset($asset->file)) {
                      $this->log('Asset %s has no file.', $asset);
                      return;
          Severity: Minor
          Found in Adapter/FilesystemAssetAdapter.php - About 1 hr to fix

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

                protected function execute(InputInterface $input, OutputInterface $output)
                {
                    /** @var Cache $cache */
                    /** @var EntityManager $em */
                    $client  = new HttpClient($input->getArgument('access_token'));
            Severity: Minor
            Found in Command/SyncCommand.php - About 1 hr to fix

              Method getConfigTreeBuilder has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getConfigTreeBuilder()
                  {
                      $treeBuilder = new TreeBuilder();
                      $rootNode = $treeBuilder->root('dothiv_contentful');
                      $rootNode
              Severity: Minor
              Found in DependencyInjection/Configuration.php - About 1 hr to fix

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

                    public function cache(ContentfulAsset $asset)
                    {
                        if (!isset($asset->file)) {
                            $this->log('Asset %s has no file.', $asset);
                            return;
                Severity: Minor
                Found in Adapter/FilesystemAssetAdapter.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