GemsTracker/gemstracker-library

View on GitHub
classes/Gems/Model.php

Summary

Maintainability
C
1 day
Test Coverage
F
48%

The class Gems_Model has an overall complexity of 54 which is very high. The configured complexity threshold is 50.
Open

class Gems_Model extends \Gems_Loader_TargetLoaderAbstract
{
    const ID_TYPE = 'id_type';

    /**
Severity: Minor
Found in classes/Gems/Model.php by phpmd

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

class Gems_Model extends \Gems_Loader_TargetLoaderAbstract
{
    const ID_TYPE = 'id_type';

    /**
Severity: Minor
Found in classes/Gems/Model.php - About 3 hrs to fix

    File Model.php has 265 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    /**
     *
     * @package    Gems
    Severity: Minor
    Found in classes/Gems/Model.php - About 2 hrs to fix

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

          public static function setChangeFieldsByPrefix(\MUtil_Model_DatabaseModelAbstract $model, $prefix, $userid = null)
          {
              $changed_field    = $prefix . '_changed';
              $changed_by_field = $prefix . '_changed_by';
              $created_field    = $prefix . '_created';
      Severity: Minor
      Found in classes/Gems/Model.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 setChangeFieldsByPrefix has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function setChangeFieldsByPrefix(\MUtil_Model_DatabaseModelAbstract $model, $prefix, $userid = null)
          {
              $changed_field    = $prefix . '_changed';
              $changed_by_field = $prefix . '_changed_by';
              $created_field    = $prefix . '_created';
      Severity: Minor
      Found in classes/Gems/Model.php - About 1 hr to fix

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

            public function getFileModel($dir, $detailed = true, $extensionsOrMask = null, $recursive = false, $followSymlinks = false)
            {
                $model = new \MUtil_Model_FolderModel($dir, $extensionsOrMask, $recursive, $followSymlinks);
        
                if ($recursive) {
        Severity: Minor
        Found in classes/Gems/Model.php - About 1 hr to fix

          Method getFileModel has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public function getFileModel($dir, $detailed = true, $extensionsOrMask = null, $recursive = false, $followSymlinks = false)
          Severity: Minor
          Found in classes/Gems/Model.php - About 35 mins to fix

            The class Gems_Model has a coupling between objects value of 31. Consider to reduce the number of dependencies under 13.
            Open

            class Gems_Model extends \Gems_Loader_TargetLoaderAbstract
            {
                const ID_TYPE = 'id_type';
            
                /**
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            CouplingBetweenObjects

            Since: 1.1.0

            A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

            Example

            class Foo {
                /**
                 * @var \foo\bar\X
                 */
                private $x = null;
            
                /**
                 * @var \foo\bar\Y
                 */
                private $y = null;
            
                /**
                 * @var \foo\bar\Z
                 */
                private $z = null;
            
                public function setFoo(\Foo $foo) {}
                public function setBar(\Bar $bar) {}
                public function setBaz(\Baz $baz) {}
            
                /**
                 * @return \SplObjectStorage
                 * @throws \OutOfRangeException
                 * @throws \InvalidArgumentException
                 * @throws \ErrorException
                 */
                public function process(\Iterator $it) {}
            
                // ...
            }

            Source https://phpmd.org/rules/design.html#couplingbetweenobjects

            Avoid unused parameters such as '$context'.
            Open

                public function createGemsUserId($value, $isNew = false, $name = null, array $context = array())
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            UnusedFormalParameter

            Since: 0.2

            Avoid passing parameters to methods or constructors and then not using those parameters.

            Example

            class Foo
            {
                private function bar($howdy)
                {
                    // $howdy is not used
                }
            }

            Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

            Avoid unused parameters such as '$isNew'.
            Open

                public function createGemsUserId($value, $isNew = false, $name = null, array $context = array())
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            UnusedFormalParameter

            Since: 0.2

            Avoid passing parameters to methods or constructors and then not using those parameters.

            Example

            class Foo
            {
                private function bar($howdy)
                {
                    // $howdy is not used
                }
            }

            Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

            Avoid unused parameters such as '$name'.
            Open

                public function createGemsUserId($value, $isNew = false, $name = null, array $context = array())
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            UnusedFormalParameter

            Since: 0.2

            Avoid passing parameters to methods or constructors and then not using those parameters.

            Example

            class Foo
            {
                private function bar($howdy)
                {
                    // $howdy is not used
                }
            }

            Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

            Avoid excessively long variable names like $respondentLoginIdField. Keep variable name length under 20.
            Open

                public $respondentLoginIdField  = 'gr2o_patient_nr';
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            LongVariable

            Since: 0.2

            Detects when a field, formal or local variable is declared with a long name.

            Example

            class Something {
                protected $reallyLongIntName = -3; // VIOLATION - Field
                public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                    $otherReallyLongName = -5; // VIOLATION - Local
                    for ($interestingIntIndex = 0; // VIOLATION - For
                         $interestingIntIndex < 10;
                         $interestingIntIndex++ ) {
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#longvariable

            Avoid variables with short names like $db. Configured minimum length is 3.
            Open

                protected $db;
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            ShortVariable

            Since: 0.2

            Detects when a field, local, or parameter has a very short name.

            Example

            class Something {
                private $q = 15; // VIOLATION - Field
                public static function main( array $as ) { // VIOLATION - Formal
                    $r = 20 + $this->q; // VIOLATION - Local
                    for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                        $r += $this->q;
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#shortvariable

            Avoid variables with short names like $db. Configured minimum length is 3.
            Open

                public function getExportDbaModel(\Zend_Db_Adapter_Abstract $db, array $directories)
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            ShortVariable

            Since: 0.2

            Detects when a field, local, or parameter has a very short name.

            Example

            class Something {
                private $q = 15; // VIOLATION - Field
                public static function main( array $as ) { // VIOLATION - Formal
                    $r = 20 + $this->q; // VIOLATION - Local
                    for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                        $r += $this->q;
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#shortvariable

            The variable $changed_field is not named in camelCase.
            Open

                public static function setChangeFieldsByPrefix(\MUtil_Model_DatabaseModelAbstract $model, $prefix, $userid = null)
                {
                    $changed_field    = $prefix . '_changed';
                    $changed_by_field = $prefix . '_changed_by';
                    $created_field    = $prefix . '_created';
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            The variable $changed_field is not named in camelCase.
            Open

                public static function setChangeFieldsByPrefix(\MUtil_Model_DatabaseModelAbstract $model, $prefix, $userid = null)
                {
                    $changed_field    = $prefix . '_changed';
                    $changed_by_field = $prefix . '_changed_by';
                    $created_field    = $prefix . '_created';
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            The variable $created_by_field is not named in camelCase.
            Open

                public static function setChangeFieldsByPrefix(\MUtil_Model_DatabaseModelAbstract $model, $prefix, $userid = null)
                {
                    $changed_field    = $prefix . '_changed';
                    $changed_by_field = $prefix . '_changed_by';
                    $created_field    = $prefix . '_created';
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            The variable $created_field is not named in camelCase.
            Open

                public static function setChangeFieldsByPrefix(\MUtil_Model_DatabaseModelAbstract $model, $prefix, $userid = null)
                {
                    $changed_field    = $prefix . '_changed';
                    $changed_by_field = $prefix . '_changed_by';
                    $created_field    = $prefix . '_created';
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            The variable $created_by_field is not named in camelCase.
            Open

                public static function setChangeFieldsByPrefix(\MUtil_Model_DatabaseModelAbstract $model, $prefix, $userid = null)
                {
                    $changed_field    = $prefix . '_changed';
                    $changed_by_field = $prefix . '_changed_by';
                    $created_field    = $prefix . '_created';
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            The variable $created_by_field is not named in camelCase.
            Open

                public static function setChangeFieldsByPrefix(\MUtil_Model_DatabaseModelAbstract $model, $prefix, $userid = null)
                {
                    $changed_field    = $prefix . '_changed';
                    $changed_by_field = $prefix . '_changed_by';
                    $created_field    = $prefix . '_created';
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            The variable $changed_by_field is not named in camelCase.
            Open

                public static function setChangeFieldsByPrefix(\MUtil_Model_DatabaseModelAbstract $model, $prefix, $userid = null)
                {
                    $changed_field    = $prefix . '_changed';
                    $changed_by_field = $prefix . '_changed_by';
                    $created_field    = $prefix . '_created';
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            The variable $created_field is not named in camelCase.
            Open

                public static function setChangeFieldsByPrefix(\MUtil_Model_DatabaseModelAbstract $model, $prefix, $userid = null)
                {
                    $changed_field    = $prefix . '_changed';
                    $changed_by_field = $prefix . '_changed_by';
                    $created_field    = $prefix . '_created';
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            The variable $created_field is not named in camelCase.
            Open

                public static function setChangeFieldsByPrefix(\MUtil_Model_DatabaseModelAbstract $model, $prefix, $userid = null)
                {
                    $changed_field    = $prefix . '_changed';
                    $changed_by_field = $prefix . '_changed_by';
                    $created_field    = $prefix . '_created';
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            The variable $changed_by_field is not named in camelCase.
            Open

                public static function setChangeFieldsByPrefix(\MUtil_Model_DatabaseModelAbstract $model, $prefix, $userid = null)
                {
                    $changed_field    = $prefix . '_changed';
                    $changed_by_field = $prefix . '_changed_by';
                    $created_field    = $prefix . '_created';
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            The variable $created_field is not named in camelCase.
            Open

                public static function setChangeFieldsByPrefix(\MUtil_Model_DatabaseModelAbstract $model, $prefix, $userid = null)
                {
                    $changed_field    = $prefix . '_changed';
                    $changed_by_field = $prefix . '_changed_by';
                    $created_field    = $prefix . '_created';
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            The variable $created_by_field is not named in camelCase.
            Open

                public static function setChangeFieldsByPrefix(\MUtil_Model_DatabaseModelAbstract $model, $prefix, $userid = null)
                {
                    $changed_field    = $prefix . '_changed';
                    $changed_by_field = $prefix . '_changed_by';
                    $created_field    = $prefix . '_created';
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            The variable $changed_field is not named in camelCase.
            Open

                public static function setChangeFieldsByPrefix(\MUtil_Model_DatabaseModelAbstract $model, $prefix, $userid = null)
                {
                    $changed_field    = $prefix . '_changed';
                    $changed_by_field = $prefix . '_changed_by';
                    $created_field    = $prefix . '_created';
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            The variable $changed_by_field is not named in camelCase.
            Open

                public static function setChangeFieldsByPrefix(\MUtil_Model_DatabaseModelAbstract $model, $prefix, $userid = null)
                {
                    $changed_field    = $prefix . '_changed';
                    $changed_by_field = $prefix . '_changed_by';
                    $created_field    = $prefix . '_created';
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            The variable $changed_field is not named in camelCase.
            Open

                public static function setChangeFieldsByPrefix(\MUtil_Model_DatabaseModelAbstract $model, $prefix, $userid = null)
                {
                    $changed_field    = $prefix . '_changed';
                    $changed_by_field = $prefix . '_changed_by';
                    $created_field    = $prefix . '_created';
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            The variable $changed_by_field is not named in camelCase.
            Open

                public static function setChangeFieldsByPrefix(\MUtil_Model_DatabaseModelAbstract $model, $prefix, $userid = null)
                {
                    $changed_field    = $prefix . '_changed';
                    $changed_by_field = $prefix . '_changed_by';
                    $created_field    = $prefix . '_created';
            Severity: Minor
            Found in classes/Gems/Model.php by phpmd

            CamelCaseVariableName

            Since: 0.2

            It is considered best practice to use the camelCase notation to name variables.

            Example

            class ClassName {
                public function doSomething() {
                    $data_module = new DataModule();
                }
            }

            Source

            There are no issues that match your filters.

            Category
            Status