core/modules/user/UserSsoController.php

Summary

Maintainability
A
3 hrs
Test Coverage

Method callback has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function callback()
    {
        // from querystring?
        $returnto = Ajde::app()->getRequest()->getParam('returnto', '');
        if (empty($returnto)) {
Severity: Minor
Found in core/modules/user/UserSsoController.php - About 1 hr to fix

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

        public function callback()
        {
            // from querystring?
            $returnto = Ajde::app()->getRequest()->getParam('returnto', '');
            if (empty($returnto)) {
    Severity: Minor
    Found in core/modules/user/UserSsoController.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

    Missing class import via use statement (line '48', column '32').
    Open

            $returntoSession = new Ajde_Session('returnto');

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '74', column '28').
    Open

                    $sso = new SsoModel();

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '106', column '24').
    Open

                $sso = new SsoModel();

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Avoid assigning values to variables in if clauses and the like (line '62', column '13').
    Open

        public function callback()
        {
            // from querystring?
            $returnto = Ajde::app()->getRequest()->getParam('returnto', '');
            if (empty($returnto)) {

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

    Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

    The method callback uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                } else {
                    $username = $this->_provider->getUsernameSuggestion();
                    $email = $this->_provider->getEmailSuggestion();
                    $fullname = $this->_provider->getNameSuggestion();
                    $this->redirect('user/register?provider='.$this->_providername.

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

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

    Avoid using static access to class 'Ajde_Session_Flash' in method 'callback'.
    Open

                    Ajde_Session_Flash::alert(ucfirst($this->_providername).' user '.$this->_provider->getUsernameSuggestion().' is already connected to another account.');

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid assigning values to variables in if clauses and the like (line '105', column '13').
    Open

        public function disconnect()
        {
            $returnto = Ajde::app()->getRequest()->getParam('returnto', '');
    
            if ($user = $this->getLoggedInUser()) { // should always be true, since we are inside a Ajde_User_Controller

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

    Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

    The method callback uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                } else {
                    $user->login();
                    $user->storeCookie(false);
                    $this->redirect($returnto);
                }

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

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

    Avoid using static access to class 'Ajde_Http_Response' in method 'beforeInvoke'.
    Open

                Ajde_Http_Response::redirectNotFound();

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid assigning values to variables in if clauses and the like (line '73', column '17').
    Open

        public function callback()
        {
            // from querystring?
            $returnto = Ajde::app()->getRequest()->getParam('returnto', '');
            if (empty($returnto)) {

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

    Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

    Avoid using static access to class 'Ajde_Session_Flash' in method 'disconnect'.
    Open

                    Ajde_Session_Flash::alert('Could not disconnect from '.ucfirst($this->_providername));

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    The method callback uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                // A user is already logged in, link this account and redirect
                if ($user = $this->getLoggedInUser()) {
                    $sso = new SsoModel();
                    $sso->populate([

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

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

    Avoid using static access to class 'Ajde_Session_Flash' in method 'disconnect'.
    Open

                    Ajde_Session_Flash::alert('Disconnected from '.ucfirst($this->_providername));

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    The method disconnect uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                } else {
                    Ajde_Session_Flash::alert('Could not disconnect from '.ucfirst($this->_providername));
                    $this->redirect($returnto);
                }

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

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

    Avoid using static access to class 'Ajde_Session_Flash' in method 'callback'.
    Open

                Ajde_Session_Flash::alert('Permission request cancelled for '.ucfirst($this->_providername));

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    The property $_provider is not named in camelCase.
    Open

    class UserSsoController extends Ajde_User_Controller
    {
        protected $_allowedActions = [
            'login',
            'callback',

    CamelCasePropertyName

    Since: 0.2

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

    Example

    class ClassName {
        protected $property_name;
    }

    Source

    The property $_providername is not named in camelCase.
    Open

    class UserSsoController extends Ajde_User_Controller
    {
        protected $_allowedActions = [
            'login',
            'callback',

    CamelCasePropertyName

    Since: 0.2

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

    Example

    class ClassName {
        protected $property_name;
    }

    Source

    The property $_allowedActions is not named in camelCase.
    Open

    class UserSsoController extends Ajde_User_Controller
    {
        protected $_allowedActions = [
            'login',
            'callback',

    CamelCasePropertyName

    Since: 0.2

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

    Example

    class ClassName {
        protected $property_name;
    }

    Source

    There are no issues that match your filters.

    Category
    Status