open-orchestra/open-orchestra-model-bundle

View on GitHub

Showing 72 of 72 total issues

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

    protected function generateContentTypeNews()
    {
        $maxLengthOption = $this->generateOption('max_length', 25);
        $required = $this->generateOption('required', true);
        $dateWidgetOption = $this->generateOption('widget', 'single_text');
Severity: Minor
Found in ModelBundle/DataFixtures/MongoDB/LoadContentTypeData.php - About 1 hr to fix

Function process has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function process(ContainerBuilder $container)
    {
        $resourcePath = '.';

        foreach ($container->getResources() as $resource) {

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

    protected function execute(InputInterface $input, OutputInterface $output)
    {

        if (!is_null($input->getOption('type'))) {
            $type = $input->getOption('type');
Severity: Minor
Found in ModelBundle/Command/OrchestraLoadDataFixturesDoctrineODMCommand.php - About 1 hr to fix

Method provideDocumentClass has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function provideDocumentClass()
    {
        return array(
            '1'  => array("empty", "OpenOrchestra\\ModelBundle\\Document\\Content"          , "content"           , "OpenOrchestra\\ModelBundle\\Repository\\ContentRepository"         , true),
            '2'  => array("empty", "OpenOrchestra\\ModelBundle\\Document\\ContentAttribute" , "content_attribute"                                                                             ),

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

    public function provideAnnotations()
    {
        $document0 = Phake::mock('OpenOrchestra\ModelInterface\Model\NodeInterface');
        Phake::when($document0)->getNodeId()->thenReturn(null);

Severity: Minor
Found in ModelBundle/Tests/EventListener/GenerateIdListenerTest.php - About 1 hr to fix

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

    public function prePersist(LifecycleEventArgs $event)
    {
        $document = $event->getDocument();
        $className = get_class($document);
        $generateAnnotations = $this->annotationReader->getClassAnnotation(new \ReflectionClass($className), 'OpenOrchestra\Mapping\Annotations\Document');
Severity: Minor
Found in ModelBundle/EventListener/GenerateIdListener.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 loadStatus has 11 arguments (exceeds 4 allowed). Consider refactoring.
Open

        $enName,
        $frName,
        $name,
        $color,
        $publishedState = false,
Severity: Major
Found in ModelBundle/DataFixtures/MongoDB/AbstractLoadStatus.php - About 1 hr to fix

Method generateContentTypeCar has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function generateContentTypeCar()
    {
        $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

Method load has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function load(array $configs, ContainerBuilder $container)
    {
        $configuration = new Configuration();
        $config = $this->processConfiguration($configuration, $configs);

Severity: Minor
Found in ModelBundle/DependencyInjection/OpenOrchestraModelExtension.php - About 1 hr to fix

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

    protected function generateNodeGlobal($htmlContent, $language, $routePattern)
    {
        $nodeHomeBlock = new Block();
        $nodeHomeBlock->setLabel('Wysiwyg');
        $nodeHomeBlock->setLanguage($language);

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

    protected function addNode(
        ObjectManager $manager,
        AbstractDataGenerator $dataGenerator,
        array $languages = array("fr", "en")
    ) {
ModelBundle/DataFixtures/MongoDB/LoadNodeDemoData.php on lines 65..76

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

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

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

    protected function addNode(
        ObjectManager $manager,
        AbstractDataGenerator $dataGenerator,
        array $languages = array("fr", "en")
    ){
Severity: Major
Found in ModelBundle/DataFixtures/MongoDB/LoadNodeDemoData.php and 1 other location - About 1 hr to fix
ModelBundle/DataFixtures/MongoDB/LoadNodeRootFunctionalDemoData.php on lines 86..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 106.

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

    protected function filterSearch(PaginateFinderConfiguration $configuration, Stage $qa)
    {
        $siteName = $configuration->getSearchIndex('site_name');
        if (null !== $siteName && '' !== $siteName) {
            $qa->match(array('siteName' => new \MongoRegex('/.*' . $siteName . '.*/i')));
Severity: Minor
Found in ModelBundle/Repository/RedirectionRepository.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 load has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function load(array $configs, ContainerBuilder $container)
    {
        $configuration = new Configuration();
        $config = $this->processConfiguration($configuration, $configs);

Severity: Minor
Found in ModelBundle/DependencyInjection/OpenOrchestraModelExtension.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 generateNodeFr has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function generateNodeFr()
    {
        $htmlContent = <<<EOF
<div class="contact-information">
    <h3>Contactez-nous</h3>

Method findByAliasDomain has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function findByAliasDomain($domain)
    {
        $database = $this->dm->getDocumentDatabase($this->documentName);
        $collectionName = $this->dm->getClassMetadata($this->documentName)->collection;

Severity: Minor
Found in ModelBundle/Repository/SiteRepository.php - About 1 hr to fix

Method generateNodeFr has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function generateNodeFr()
    {
        $htmlContent = <<<EOF
<div class='content2'>
    <h1>Open-Orchestra</h1>

Method provideNodeForRecord has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function provideNodeForRecord()
    {
        $node0 = Phake::mock('OpenOrchestra\ModelBundle\Document\Node');
        Phake::when($node0)->getNodeId()->thenReturn('fakeId');
        Phake::when($node0)->getPath()->thenReturn('fakeParentPath/fakePastId');
Severity: Minor
Found in ModelBundle/Tests/EventListener/GeneratePathListenerTest.php - About 1 hr to fix

Method generateNodeEn has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function generateNodeEn()
    {
        $htmlContent = <<<EOF
<div class="contact-information">
    <h3>Contact Us</h3>

Method generateNodeDe has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function generateNodeDe()
    {
        $htmlContent = <<<EOF
<div class="contact-information">
    <h3>Kontaktieren Sie uns</h3>
Severity
Category
Status
Source
Language