apparat/object

View on GitHub

Showing 170 of 170 total issues

Method createFromParams has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function createFromParams(array $params)
    {
        $datePrecision = intval(getenv('OBJECT_DATE_PRECISION'));

        // Object visibility
Severity: Minor
Found in src/Object/Ports/Factory/SelectorFactory.php - About 1 hr to fix

    Method __construct has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function __construct(array $data, ObjectInterface $object)
        {
            parent::__construct($data, $object);
    
            // Initialize the object ID
    Severity: Minor
    Found in src/Object/Domain/Model/Properties/SystemProperties.php - About 1 hr to fix

      Method parseRelationString has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected static function parseRelationString($relation, RepositoryInterface $contextRepository)
          {
              $parsed = [
                  self::PARSE_URL => null,
                  self::PARSE_LABEL => null,
      Severity: Minor
      Found in src/Object/Domain/Factory/RelationFactory.php - About 1 hr to fix

        Method testObjectUrlComparison has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function testObjectUrlComparison()
            {
                $this->assertFalse(
                    (
                    new ObjectUrl(
        Severity: Minor
        Found in src/Object/Tests/ObjectUrlTest.php - About 1 hr to fix

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

              public function findObjectResourceLocators(SelectorInterface $selector, RepositoryInterface $repository)
              {
                  chdir($this->root);
          
                  // Build a glob string from the selector
          Severity: Minor
          Found in src/Object/Infrastructure/Repository/FileAdapterStrategy.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 setUpBeforeClass has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function setUpBeforeClass()
              {
                  parent::setUpBeforeClass();
                  self::$globDirs[] =
                  self::$globBase = sys_get_temp_dir().DIRECTORY_SEPARATOR.'glob';
          Severity: Minor
          Found in src/Object/Tests/RepositoryTest.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 testCreateAndPublishArticleObject has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  public function testCreateAndPublishArticleObject()
                  {
                      putenv('OBJECT_DEFAULT_PRIVACY=public');
          
                      // Create a temporary repository & article
          Severity: Minor
          Found in src/Object/Tests/ArticleObjectTest.php - About 1 hr to fix

            Method getSelector has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getSelector()
                {
                    $wlc = SelectorInterface::WILDCARD;
                    $vsb = SelectorInterface::VISIBLE;
                    $pub = SelectorInterface::PUBLISHED;
            Severity: Minor
            Found in src/Object/Tests/SelectorTest.php - About 1 hr to fix

              Method __construct has 12 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      TypeServiceInterface $typeService,
                      $year = self::WILDCARD,
                      $month = self::WILDCARD,
                      $day = self::WILDCARD,
                      $hour = self::WILDCARD,
              Severity: Major
              Found in src/Object/Domain/Repository/Selector.php - About 1 hr to fix

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

                    public function findRelations(array $criteria)
                    {
                        // Validate the relation type (if given as a criteria)
                        if (array_key_exists(RelationInterface::FILTER_TYPE, $criteria)) {
                            RelationFactory::validateRelationType($criteria[RelationInterface::FILTER_TYPE]);
                Severity: Minor
                Found in src/Object/Domain/Model/Properties/Relations.php - About 1 hr to fix

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

                      public function __construct($locator = null, $datePrecision = null, &$leader = '')
                      {
                          if (!empty($locator)) {
                              // If the local default date precision should be used
                              if ($datePrecision === null) {
                  Severity: Minor
                  Found in src/Object/Domain/Model/Uri/Locator.php - About 1 hr to fix

                    Method testPSR7methods has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function testPSR7methods()
                        {
                            $url = new Url(self::REMOTE_URL);
                            $this->assertEquals(self::REMOTE_REPOSITORY_AUTHORITY, $url->getAuthority());
                            $this->assertEquals('apparat:tools', $url->getUserInfo());
                    Severity: Minor
                    Found in src/Object/Tests/UrlTest.php - About 1 hr to fix

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

                          protected function setMetaProperties(MetaProperties $metaProperties, $overwrite = false)
                          {
                              $this->metaProperties = $metaProperties;
                              $metaPropertiesState = spl_object_hash($this->metaProperties);
                      
                      
                      src/Object/Domain/Model/Object/Traits/DomainPropertiesTrait.php on lines 97..112
                      src/Object/Domain/Model/Object/Traits/ProcessingInstructionsTrait.php on lines 89..104
                      src/Object/Domain/Model/Object/Traits/RelationsTrait.php on lines 101..116
                      src/Object/Domain/Model/Object/Traits/SystemPropertiesTrait.php on lines 212..227

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

                      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 5 locations. Consider refactoring.
                      Open

                          protected function setSystemProperties(SystemProperties $systemProperties, $overwrite = false)
                          {
                              $this->systemProperties = $systemProperties;
                              $systemPropsState = spl_object_hash($this->systemProperties);
                      
                      
                      src/Object/Domain/Model/Object/Traits/DomainPropertiesTrait.php on lines 97..112
                      src/Object/Domain/Model/Object/Traits/MetaPropertiesTrait.php on lines 86..101
                      src/Object/Domain/Model/Object/Traits/ProcessingInstructionsTrait.php on lines 89..104
                      src/Object/Domain/Model/Object/Traits/RelationsTrait.php on lines 101..116

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

                      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 5 locations. Consider refactoring.
                      Open

                          protected function setDomainProperties(GenericPropertiesInterface $domainProperties, $overwrite = false)
                          {
                              $this->domainProperties = $domainProperties;
                              $domainPropsState = spl_object_hash($this->domainProperties);
                      
                      
                      src/Object/Domain/Model/Object/Traits/MetaPropertiesTrait.php on lines 86..101
                      src/Object/Domain/Model/Object/Traits/ProcessingInstructionsTrait.php on lines 89..104
                      src/Object/Domain/Model/Object/Traits/RelationsTrait.php on lines 101..116
                      src/Object/Domain/Model/Object/Traits/SystemPropertiesTrait.php on lines 212..227

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

                      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 5 locations. Consider refactoring.
                      Open

                          protected function setProcessingInstructions(GenericPropertiesInterface $procInstructions, $overwrite = false)
                          {
                              $this->processingInstructions = $procInstructions;
                              $procInstState = spl_object_hash($this->processingInstructions);
                      
                      
                      src/Object/Domain/Model/Object/Traits/DomainPropertiesTrait.php on lines 97..112
                      src/Object/Domain/Model/Object/Traits/MetaPropertiesTrait.php on lines 86..101
                      src/Object/Domain/Model/Object/Traits/RelationsTrait.php on lines 101..116
                      src/Object/Domain/Model/Object/Traits/SystemPropertiesTrait.php on lines 212..227

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

                      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 5 locations. Consider refactoring.
                      Open

                          protected function setRelations(Relations $relations, $overwrite = false)
                          {
                              $this->relations = $relations;
                              $relationsState = spl_object_hash($this->relations);
                      
                      
                      Severity: Major
                      Found in src/Object/Domain/Model/Object/Traits/RelationsTrait.php and 4 other locations - About 1 hr to fix
                      src/Object/Domain/Model/Object/Traits/DomainPropertiesTrait.php on lines 97..112
                      src/Object/Domain/Model/Object/Traits/MetaPropertiesTrait.php on lines 86..101
                      src/Object/Domain/Model/Object/Traits/ProcessingInstructionsTrait.php on lines 89..104
                      src/Object/Domain/Model/Object/Traits/SystemPropertiesTrait.php on lines 212..227

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

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

                          public function matches(Url $url)
                          {
                      
                              // Test the scheme
                              $urlScheme = $url->getScheme();
                      Severity: Minor
                      Found in src/Object/Domain/Model/Uri/Url.php - About 1 hr to fix

                        Method loadRevisionData has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function loadRevisionData($payload = '', array $propertyData = [])
                            {
                                $this->payload = $payload;
                        
                                // Instantiate the system properties
                        Severity: Minor
                        Found in src/Object/Domain/Model/Object/AbstractObject.php - About 1 hr to fix

                          Avoid using undefined variables such as '$enabledTypes' which will lead to PHP notices.
                          Open

                                  unset(parent::$enabledTypes['invalid']);
                          Severity: Minor
                          Found in src/Object/Tests/TestTypeService.php by phpmd

                          UndefinedVariable

                          Since: 2.8.0

                          Detects when a variable is used that has not been defined before.

                          Example

                          class Foo
                          {
                              private function bar()
                              {
                                  // $message is undefined
                                  echo $message;
                              }
                          }

                          Source https://phpmd.org/rules/cleancode.html#undefinedvariable

                          Severity
                          Category
                          Status
                          Source
                          Language