open-orchestra/open-orchestra-model-bundle

View on GitHub

Showing 72 of 72 total issues

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

<?php

namespace OpenOrchestra\ModelBundle\DataFixtures\MongoDB\DemoContent;

use OpenOrchestra\ModelBundle\Document\Block;
ModelBundle/DataFixtures/MongoDB/DemoContent/Error404DataGenerator.php on lines 1..106

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

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 OpenOrchestra\ModelBundle\DataFixtures\MongoDB\DemoContent;

use OpenOrchestra\ModelBundle\Document\Block;
ModelBundle/DataFixtures/MongoDB/DemoContent/Error503DataGenerator.php on lines 1..106

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

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

File NodeRepository.php has 757 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace OpenOrchestra\ModelBundle\Repository;

use Doctrine\Common\Collections\Collection;
Severity: Major
Found in ModelBundle/Repository/NodeRepository.php - About 1 day to fix

NodeRepository has 66 functions (exceeds 20 allowed). Consider refactoring.
Open

class NodeRepository extends AbstractAggregateRepository implements FieldAutoGenerableRepositoryInterface, NodeRepositoryInterface
{
    use AutoPublishableTrait;
    use UseTrackableTrait;
    use StatusableTrait;
Severity: Major
Found in ModelBundle/Repository/NodeRepository.php - About 1 day to fix

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

    protected function generateNodeGlobal($htmlContent, $name, $language, $routePattern)
    {
        $nodeAutoPublishBlock = new Block();
        $nodeAutoPublishBlock->setLabel('Wysiwyg');
        $nodeAutoPublishBlock->setLanguage($language);
ModelBundle/DataFixtures/MongoDB/DemoContent/LegalDataGenerator.php on lines 99..128

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

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

    protected function generateNodeGlobal($htmlContent, $name, $language, $routePattern)
    {
        $nodeLegalBlock = new Block();
        $nodeLegalBlock->setLabel('Wysiwyg');
        $nodeLegalBlock->setLanguage($language);
ModelBundle/DataFixtures/MongoDB/DemoContent/AutoPublishDataGenerator.php on lines 110..139

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

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

    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root('open_orchestra_model');

Severity: Major
Found in ModelBundle/DependencyInjection/Configuration.php - About 7 hrs to fix

RouteDocument has 41 functions (exceeds 20 allowed). Consider refactoring.
Open

class RouteDocument implements RouteDocumentInterface
{
    /**
     * @var string $id
     *
Severity: Minor
Found in ModelBundle/Document/RouteDocument.php - About 5 hrs to fix

Node has 41 functions (exceeds 20 allowed). Consider refactoring.
Open

class Node implements NodeInterface
{
    use TimestampableDocument;
    use BlameableDocument;
    use Versionable;
Severity: Minor
Found in ModelBundle/Document/Node.php - About 5 hrs to fix

File ContentRepository.php has 377 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace OpenOrchestra\ModelBundle\Repository;

use Doctrine\Common\Collections\Collection;
Severity: Minor
Found in ModelBundle/Repository/ContentRepository.php - About 5 hrs to fix

ContentRepository has 37 functions (exceeds 20 allowed). Consider refactoring.
Open

class ContentRepository extends AbstractAggregateRepository implements FieldAutoGenerableRepositoryInterface, ContentRepositoryInterface, KeywordableTraitInterface
{
    use KeywordableTrait;
    use UseTrackableTrait;
    use FilterTrait;
Severity: Minor
Found in ModelBundle/Repository/ContentRepository.php - About 4 hrs to fix

FieldType has 30 functions (exceeds 20 allowed). Consider refactoring.
Open

class FieldType implements FieldTypeInterface
{
    /**
     * @var string $fieldId
     *
Severity: Minor
Found in ModelBundle/Document/FieldType.php - About 3 hrs to fix

Site has 27 functions (exceeds 20 allowed). Consider refactoring.
Open

class Site implements SiteInterface
{
    use Sitemapable;
    use SoftDeleteable;

Severity: Minor
Found in ModelBundle/Document/Site.php - About 3 hrs to fix

ContentType has 27 functions (exceeds 20 allowed). Consider refactoring.
Open

class ContentType implements ContentTypeInterface
{
    use BlameableDocument;
    use TimestampableDocument;
    use Versionable;
Severity: Minor
Found in ModelBundle/Document/ContentType.php - About 3 hrs to fix

AbstractStatus has 25 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class AbstractStatus implements StatusInterface
{
    /**
     * @var string $id
     *
Severity: Minor
Found in ModelBundle/Document/AbstractStatus.php - About 2 hrs to fix

Method generateGlobalBlock has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function generateGlobalBlock(ObjectManager $manager, $language)
    {
        $siteBlockLogo = new Block();
        $siteBlockLogo->setLabel('Wysiwyg logo');
        $siteBlockLogo->setStyle('default');
Severity: Major
Found in ModelBundle/DataFixtures/MongoDB/LoadNodeRootFunctionalDemoData.php - About 2 hrs to fix

Block has 21 functions (exceeds 20 allowed). Consider refactoring.
Open

class Block implements BlockInterface
{
    use Cacheable;
    use TimestampableDocument;

Severity: Minor
Found in ModelBundle/Document/Block.php - About 2 hrs to fix

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

    public function transformSubConditionToMongoCondition($condition, array &$aliases)
    {
        $elements = array();
        $subElements = array();
        $operator = '$and';
Severity: Minor
Found in ModelBundle/Repository/RepositoryTrait/KeywordableTrait.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 preUpdate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public function preUpdate(LifecycleEventArgs $event)
    {
        if (!($object = $event->getDocument()) instanceof ContentInterface || in_array($object->getContentId(), $this->contentManaged)) {
            return;
        }

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

    protected function generateContentTypeCustomer()
    {
        $maxLengthOption = $this->generateOption('max_length', 25);
        $required = $this->generateOption('required', true);

Severity: Minor
Found in ModelBundle/DataFixtures/MongoDB/LoadContentTypeData.php - About 1 hr to fix
Severity
Category
Status
Source
Language