GemsTracker/gemstracker-library

View on GitHub
classes/Gems/Model/StaffModel.php

Summary

Maintainability
F
3 days
Test Coverage
F
0%

Method applySystemUserSettings has 145 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function applySystemUserSettings($detailed, $action)
    {
        $this->addLeftTable('gems__systemuser_setup', ['gsf_id_user' => 'gsus_id_user'], 'gsus');
        $this->resetOrder();

Severity: Major
Found in classes/Gems/Model/StaffModel.php - About 5 hrs to fix

    File StaffModel.php has 395 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    /**
     * The staff model
     *
    Severity: Minor
    Found in classes/Gems/Model/StaffModel.php - About 5 hrs to fix

      Method applySettings has 99 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function applySettings($detailed, $action)
          {
              $this->resetOrder();
      
              $dbLookup   = $this->util->getDbLookup();
      Severity: Major
      Found in classes/Gems/Model/StaffModel.php - About 3 hrs to fix

        Method _addLoginSettings has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function _addLoginSettings($editing)
            {
                if ($this->currentUser->hasPrivilege('pr.staff.see.all') || (! $editing)) {
                    // Select organization
                    $options = $this->util->getDbLookup()->getOrganizations();
        Severity: Minor
        Found in classes/Gems/Model/StaffModel.php - About 1 hr to fix

          Function applySettings has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public function applySettings($detailed, $action)
              {
                  $this->resetOrder();
          
                  $dbLookup   = $this->util->getDbLookup();
          Severity: Minor
          Found in classes/Gems/Model/StaffModel.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 applyOwnAccountEdit has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function applyOwnAccountEdit()
              {
                  $noscript = new \MUtil_Validate_NoScript();
          
                  $this->set('gsf_id_user',        'elementClass', 'None');
          Severity: Minor
          Found in classes/Gems/Model/StaffModel.php - About 1 hr to fix

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

                protected function _addLoginSettings($editing)
                {
                    if ($this->currentUser->hasPrivilege('pr.staff.see.all') || (! $editing)) {
                        // Select organization
                        $options = $this->util->getDbLookup()->getOrganizations();
            Severity: Minor
            Found in classes/Gems/Model/StaffModel.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 save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function save(array $newValues, array $filter = null, array $saveTables = null)
                {
                    //First perform a save
                    $savedValues = parent::save($newValues, $filter, $saveTables);
            
            
            Severity: Minor
            Found in classes/Gems/Model/StaffModel.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

            The method applySettings() has 118 lines of code. Current threshold is set to 100. Avoid really long methods.
            Open

                public function applySettings($detailed, $action)
                {
                    $this->resetOrder();
            
                    $dbLookup   = $this->util->getDbLookup();
            Severity: Minor
            Found in classes/Gems/Model/StaffModel.php by phpmd

            The method applySystemUserSettings() has 168 lines of code. Current threshold is set to 100. Avoid really long methods.
            Open

                public function applySystemUserSettings($detailed, $action)
                {
                    $this->addLeftTable('gems__systemuser_setup', ['gsf_id_user' => 'gsus_id_user'], 'gsus');
                    $this->resetOrder();
            
            
            Severity: Minor
            Found in classes/Gems/Model/StaffModel.php by phpmd

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

            class Gems_Model_StaffModel extends \Gems_Model_JoinModel
            {
                /**
                 *
                 * @var \Gems_User_Organization
            Severity: Minor
            Found in classes/Gems/Model/StaffModel.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 '$detailed'.
            Open

                public function applySystemUserSettings($detailed, $action)
            Severity: Minor
            Found in classes/Gems/Model/StaffModel.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 __construct($name = 'staff')
            Severity: Minor
            Found in classes/Gems/Model/StaffModel.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

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

                        if (1 == count($defaultStaffDefinitions)) {
                            reset($defaultStaffDefinitions);
                            $this->set('gul_user_class',
                                    'default', key($defaultStaffDefinitions),
                                    'elementClass', 'Hidden',
            Severity: Major
            Found in classes/Gems/Model/StaffModel.php and 1 other location - About 3 hrs to fix
            classes/Gems/Model/StaffModel.php on lines 110..126

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

            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

                    if (1 == count($defaultStaffDefinitions)) {
                        reset($defaultStaffDefinitions);
                        $this->set('gul_user_class',
                                'default', key($defaultStaffDefinitions),
                                'elementClass', 'Hidden',
            Severity: Major
            Found in classes/Gems/Model/StaffModel.php and 1 other location - About 3 hrs to fix
            classes/Gems/Model/StaffModel.php on lines 271..287

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

            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

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

                        $defaultStaffDefinitions = $this->loader->getUserLoader()->getAvailableStaffDefinitions();
            Severity: Minor
            Found in classes/Gems/Model/StaffModel.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 excessively long variable names like $defaultStaffDefinitions. Keep variable name length under 20.
            Open

                    $defaultStaffDefinitions = $this->loader->getUserLoader()->getAvailableStaffDefinitions();
            Severity: Minor
            Found in classes/Gems/Model/StaffModel.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 excessively long variable names like $allowedRespondentGroups. Keep variable name length under 20.
            Open

                    $allowedRespondentGroups = $dbLookup->getAllowedRespondentGroups();
            Severity: Minor
            Found in classes/Gems/Model/StaffModel.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 excessively long variable names like $defaultStaffDefinition. Keep variable name length under 20.
            Open

                protected $defaultStaffDefinition = \Gems_User_UserLoader::USER_STAFF;
            Severity: Minor
            Found in classes/Gems/Model/StaffModel.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

            There are no issues that match your filters.

            Category
            Status