Firesphere/silverstripe-yubiauth

View on GitHub
src/Handlers/YubikeyLoginHandler.php

Summary

Maintainability
A
0 mins
Test Coverage

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

        if ($member = $this->checkLogin($data, $request, $result)) {
Severity: Minor
Found in src/Handlers/YubikeyLoginHandler.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

Avoid using static access to class '\Firesphere\YubiAuth\Forms\YubikeyLoginForm' in method 'LoginForm'.
Open

        return YubikeyLoginForm::create(
            $this,
            get_class($this->authenticator),
            'LoginForm'
        );
Severity: Minor
Found in src/Handlers/YubikeyLoginHandler.php by phpmd

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 using static access to class '\Firesphere\YubiAuth\Forms\YubikeyForm' in method 'yubikeyForm'.
Open

        return YubikeyForm::create($this, 'yubikeyForm');
Severity: Minor
Found in src/Handlers/YubikeyLoginHandler.php by phpmd

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 using static access to class '\SilverStripe\ORM\ValidationResult' in method 'validateToken'.
Open

        $validationResult = ValidationResult::create();
Severity: Minor
Found in src/Handlers/YubikeyLoginHandler.php by phpmd

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 using static access to class '\SilverStripe\Security\Security' in method 'validateToken'.
Open

            Security::setCurrentUser($member);
Severity: Minor
Found in src/Handlers/YubikeyLoginHandler.php by phpmd

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 '64', column '13').
Open

    public function doLogin($data, MemberLoginForm $form, HTTPRequest $request)
    {
        if ($member = $this->checkLogin($data, $request, $result)) {
            $session = $request->getSession();
            $session->set(BootstrapMFAAuthenticator::SESSION_KEY . '.MemberID', $member->ID);
Severity: Minor
Found in src/Handlers/YubikeyLoginHandler.php by phpmd

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 unused private fields such as '$url_handlers'.
Open

    private static $url_handlers = [
        'yubikey-authentication' => 'secondFactor',
        'verify'                 => 'secondFactor'
    ];
Severity: Minor
Found in src/Handlers/YubikeyLoginHandler.php by phpmd

UnusedPrivateField

Since: 0.2

Detects when a private field is declared and/or assigned a value, but not used.

Example

class Something
{
    private static $FOO = 2; // Unused
    private $i = 5; // Unused
    private $j = 6;
    public function addOne()
    {
        return $this->j++;
    }
}

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

Avoid unused local variables such as '$result'.
Open

        if ($member = $this->checkLogin($data, $request, $result)) {
Severity: Minor
Found in src/Handlers/YubikeyLoginHandler.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

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

Avoid unused private fields such as '$allowed_actions'.
Open

    private static $allowed_actions = [
        'LoginForm',
        'dologin',
        'secondFactor',
        'yubikeyForm',
Severity: Minor
Found in src/Handlers/YubikeyLoginHandler.php by phpmd

UnusedPrivateField

Since: 0.2

Detects when a private field is declared and/or assigned a value, but not used.

Example

class Something
{
    private static $FOO = 2; // Unused
    private $i = 5; // Unused
    private $j = 6;
    public function addOne()
    {
        return $this->j++;
    }
}

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

Avoid unused parameters such as '$form'.
Open

    public function doLogin($data, MemberLoginForm $form, HTTPRequest $request)
Severity: Minor
Found in src/Handlers/YubikeyLoginHandler.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

The property $url_handlers is not named in camelCase.
Open

class YubikeyLoginHandler extends BootstrapMFALoginHandler
{
    /**
     * @var array
     */
Severity: Minor
Found in src/Handlers/YubikeyLoginHandler.php by phpmd

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 $allowed_actions is not named in camelCase.
Open

class YubikeyLoginHandler extends BootstrapMFALoginHandler
{
    /**
     * @var array
     */
Severity: Minor
Found in src/Handlers/YubikeyLoginHandler.php by phpmd

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 method LoginForm is not named in camelCase.
Open

    public function LoginForm()
    {
        return YubikeyLoginForm::create(
            $this,
            get_class($this->authenticator),
Severity: Minor
Found in src/Handlers/YubikeyLoginHandler.php by phpmd

CamelCaseMethodName

Since: 0.2

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

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method MFAForm is not named in camelCase.
Wontfix

    public function MFAForm()
    {
        return $this->yubikeyForm();
    }
Severity: Minor
Found in src/Handlers/YubikeyLoginHandler.php by phpmd

CamelCaseMethodName

Since: 0.2

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

Example

class ClassName {
    public function get_name() {
    }
}

Source

There are no issues that match your filters.

Category
Status