neos/neos-development-collection

View on GitHub
Neos.ContentRepository/Classes/Domain/Model/Node.php

Summary

Maintainability
F
1 wk
Test Coverage

File Node.php has 1025 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
namespace Neos\ContentRepository\Domain\Model;

/*
 * This file is part of the Neos.ContentRepository package.
Severity: Major
Found in Neos.ContentRepository/Classes/Domain/Model/Node.php - About 2 days to fix

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

    class Node implements NodeInterface, CacheAwareInterface, TraversableNodeInterface
    {
        /**
         * The NodeData entity this version is for.
         *
    Severity: Major
    Found in Neos.ContentRepository/Classes/Domain/Model/Node.php - About 2 days to fix

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

          public function dimensionsAreMatchingTargetDimensionValues(): bool
          {
              $dimensions = $this->getDimensions();
              $contextDimensions = $this->context->getDimensions();
              foreach ($this->context->getTargetDimensions() as $dimensionName => $targetDimensionValue) {
      Severity: Minor
      Found in Neos.ContentRepository/Classes/Domain/Model/Node.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 findReferencedNodes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function findReferencedNodes(): TraversableNodes
          {
              $referencedNodes = [];
              foreach ($this->getNodeType()->getProperties() as $propertyName => $property) {
                  $propertyType = $this->getNodeType()->getPropertyType($propertyName);
      Severity: Minor
      Found in Neos.ContentRepository/Classes/Domain/Model/Node.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 createNode has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function createNode($name, NodeType $nodeType = null, $identifier = null): NodeInterface
          {
              $this->emitBeforeNodeCreate($this, $name, $nodeType, $identifier);
              $newNode = $this->createSingleNode($name, $nodeType, $identifier);
              if ($nodeType !== null) {
      Severity: Minor
      Found in Neos.ContentRepository/Classes/Domain/Model/Node.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 moveBefore has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function moveBefore(NodeInterface $referenceNode, string $newName = null): void
          {
              if ($referenceNode === $this) {
                  return;
              }
      Severity: Minor
      Found in Neos.ContentRepository/Classes/Domain/Model/Node.php - About 1 hr to fix

        Method moveAfter has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function moveAfter(NodeInterface $referenceNode, string $newName = null): void
            {
                if ($referenceNode === $this) {
                    return;
                }
        Severity: Minor
        Found in Neos.ContentRepository/Classes/Domain/Model/Node.php - About 1 hr to fix

          Method getProperty has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getProperty($propertyName, bool $returnNodesAsIdentifiers = false)
              {
                  $value = $this->nodeData->getProperty($propertyName);
                  $nodeType = $this->getNodeType();
                  $expectedPropertyType = null;
          Severity: Minor
          Found in Neos.ContentRepository/Classes/Domain/Model/Node.php - About 1 hr to fix

            Function moveBefore has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function moveBefore(NodeInterface $referenceNode, string $newName = null): void
                {
                    if ($referenceNode === $this) {
                        return;
                    }
            Severity: Minor
            Found in Neos.ContentRepository/Classes/Domain/Model/Node.php - About 55 mins 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 moveAfter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function moveAfter(NodeInterface $referenceNode, string $newName = null): void
                {
                    if ($referenceNode === $this) {
                        return;
                    }
            Severity: Minor
            Found in Neos.ContentRepository/Classes/Domain/Model/Node.php - About 55 mins 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 createVariantForContext has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function createVariantForContext($context): NodeInterface
                {
                    $autoCreatedChildNodes = [];
                    $nodeType = $this->getNodeType();
                    foreach ($nodeType->getAutoCreatedChildNodes() as $childNodeName => $childNodeConfiguration) {
            Severity: Minor
            Found in Neos.ContentRepository/Classes/Domain/Model/Node.php - About 55 mins 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 getProperty has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getProperty($propertyName, bool $returnNodesAsIdentifiers = false)
                {
                    $value = $this->nodeData->getProperty($propertyName);
                    $nodeType = $this->getNodeType();
                    $expectedPropertyType = null;
            Severity: Minor
            Found in Neos.ContentRepository/Classes/Domain/Model/Node.php - About 35 mins 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

            Avoid too many return statements within this method.
            Open

                    return $this->propertyMapper->convert($value, $expectedPropertyType);
            Severity: Major
            Found in Neos.ContentRepository/Classes/Domain/Model/Node.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return ($returnNodesAsIdentifiers ? $value : $this->context->getNodeByIdentifier($value));
              Severity: Major
              Found in Neos.ContentRepository/Classes/Domain/Model/Node.php - About 30 mins to fix

                Function moveInto has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function moveInto(NodeInterface $referenceNode, string $newName = null): void
                    {
                        if ($referenceNode === $this || $referenceNode === $this->getParent()) {
                            return;
                        }
                Severity: Minor
                Found in Neos.ContentRepository/Classes/Domain/Model/Node.php - About 25 mins 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 createRecursiveCopy has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function createRecursiveCopy(NodeInterface $referenceNode, string $nodeName, bool $detachedCopy): NodeInterface
                    {
                        $identifier = null;
                
                        $referenceNodeDimensions = $referenceNode->getDimensions();
                Severity: Minor
                Found in Neos.ContentRepository/Classes/Domain/Model/Node.php - About 25 mins 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 moveAfter(NodeInterface $referenceNode, string $newName = null): void
                    {
                        if ($referenceNode === $this) {
                            return;
                        }
                Severity: Major
                Found in Neos.ContentRepository/Classes/Domain/Model/Node.php and 1 other location - About 1 day to fix
                Neos.ContentRepository/Classes/Domain/Model/Node.php on lines 589..624

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

                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 moveBefore(NodeInterface $referenceNode, string $newName = null): void
                    {
                        if ($referenceNode === $this) {
                            return;
                        }
                Severity: Major
                Found in Neos.ContentRepository/Classes/Domain/Model/Node.php and 1 other location - About 1 day to fix
                Neos.ContentRepository/Classes/Domain/Model/Node.php on lines 637..672

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

                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 copyBefore(NodeInterface $referenceNode, $nodeName): NodeInterface
                    {
                        if ($referenceNode->getParent()->getNode($nodeName) !== null) {
                            throw new NodeExistsException(sprintf('Node with path "%s/%s" already exists.', $referenceNode->getParent()->getPath(), $nodeName), 1292503465);
                        }
                Severity: Major
                Found in Neos.ContentRepository/Classes/Domain/Model/Node.php and 1 other location - About 7 hrs to fix
                Neos.ContentRepository/Classes/Domain/Model/Node.php on lines 760..779

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

                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 copyAfter(NodeInterface $referenceNode, $nodeName): NodeInterface
                    {
                        if ($referenceNode->getParent()->getNode($nodeName) !== null) {
                            throw new NodeExistsException(sprintf('Node with path "%s/%s" already exists.', $referenceNode->getParent()->getPath(), $nodeName), 1292503466);
                        }
                Severity: Major
                Found in Neos.ContentRepository/Classes/Domain/Model/Node.php and 1 other location - About 7 hrs to fix
                Neos.ContentRepository/Classes/Domain/Model/Node.php on lines 727..746

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

                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 setHiddenAfterDateTime(\DateTimeInterface $dateTime = null): void
                    {
                        if ($this->getHiddenAfterDateTime() instanceof \DateTimeInterface && $dateTime instanceof \DateTimeInterface && $this->getHiddenAfterDateTime()->format(\DateTime::W3C) === $dateTime->format(\DateTime::W3C)) {
                            return;
                        }
                Severity: Major
                Found in Neos.ContentRepository/Classes/Domain/Model/Node.php and 1 other location - About 1 hr to fix
                Neos.ContentRepository/Classes/Domain/Model/Node.php on lines 1387..1397

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

                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 setHiddenBeforeDateTime(\DateTimeInterface $dateTime = null): void
                    {
                        if ($this->getHiddenBeforeDateTime() instanceof \DateTime && $dateTime instanceof \DateTime && $this->getHiddenBeforeDateTime()->format(\DateTime::W3C) === $dateTime->format(\DateTime::W3C)) {
                            return;
                        }
                Severity: Major
                Found in Neos.ContentRepository/Classes/Domain/Model/Node.php and 1 other location - About 1 hr to fix
                Neos.ContentRepository/Classes/Domain/Model/Node.php on lines 1419..1429

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

                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

                There are no issues that match your filters.

                Category
                Status