eustasy/authenticatron

View on GitHub
authenticatron.php

Summary

Maintainability
A
3 hrs
Test Coverage

Function Authenticatron_Secret has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

function Authenticatron_Secret($Length = 16) {

    global $Base32_Chars;

    if (
Severity: Minor
Found in authenticatron.php - About 2 hrs 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 Base32_Decode has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

function Base32_Decode($Secret) {

    global $Base32_Chars;

    // If there is no secret or it is too small.
Severity: Minor
Found in authenticatron.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

The method Authenticatron_Code has a boolean flag argument $Timestamp, which is a certain sign of a Single Responsibility Principle violation.
Open

function Authenticatron_Code($Secret, $Timestamp = false, $CodeLength = 6) {
Severity: Minor
Found in authenticatron.php by phpmd

Since: PHPMD 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example:

class Foo {
      public function bar($flag = true) {
      }
  }

Source: http://phpmd.org/rules/cleancode.txt

Avoid using static access to class 'QRCode' in method 'Authenticatron_QR'.
Open

    QRCode::png($URL, null, constant('QR_ECLEVEL_'.$Level), $Size, $Margin);
Severity: Minor
Found in authenticatron.php by phpmd

Since: PHPMD 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: http://phpmd.org/rules/cleancode.txt

A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 41 and the first side effect is on line 9.
Open

<?php
Severity: Minor
Found in authenticatron.php by phpcodesniffer

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

}
Severity: Minor
Found in authenticatron.php by phpcodesniffer

Blank line found at end of control structure
Open


Severity: Minor
Found in authenticatron.php by phpcodesniffer

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

}
Severity: Minor
Found in authenticatron.php by phpcodesniffer

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

}
Severity: Minor
Found in authenticatron.php by phpcodesniffer

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

}
Severity: Minor
Found in authenticatron.php by phpcodesniffer

Blank line found at end of control structure
Open


Severity: Minor
Found in authenticatron.php by phpcodesniffer

Blank line found at start of control structure
Open

    for ($i = 0; $i < $Secret_Count; $i = $i+8) {
Severity: Minor
Found in authenticatron.php by phpcodesniffer

Blank line found at end of control structure
Open


Severity: Minor
Found in authenticatron.php by phpcodesniffer

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

}
Severity: Minor
Found in authenticatron.php by phpcodesniffer

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

}
Severity: Minor
Found in authenticatron.php by phpcodesniffer

Blank line found at end of control structure
Open


Severity: Minor
Found in authenticatron.php by phpcodesniffer

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

}
Severity: Minor
Found in authenticatron.php by phpcodesniffer

Line exceeds 120 characters; contains 126 characters
Open

            $Secret_Decoded .= ( ($Convert = chr(base_convert($eightBits[$z], 2, 10))) || ord($Convert) == 48 ) ? $Convert:'';
Severity: Minor
Found in authenticatron.php by phpcodesniffer

Usage of ELSE IF is discouraged; use ELSEIF instead
Open

    } else if (function_exists('random_bytes')) {
Severity: Minor
Found in authenticatron.php by phpcodesniffer

Usage of ELSE IF is discouraged; use ELSEIF instead
Open

    } else if ( function_exists('mcrypt_create_iv') ) {
Severity: Minor
Found in authenticatron.php by phpcodesniffer

Usage of ELSE IF is discouraged; use ELSEIF instead
Open

    } else if ( function_exists('openssl_random_pseudo_bytes') ) {
Severity: Minor
Found in authenticatron.php by phpcodesniffer

Space before opening parenthesis of function call prohibited
Open

    $Account = str_replace (':', '', $Account);
Severity: Minor
Found in authenticatron.php by phpcodesniffer

Space before opening parenthesis of function call prohibited
Open

    $Issuer = str_replace (':', '', $Issuer);
Severity: Minor
Found in authenticatron.php by phpcodesniffer

There are no issues that match your filters.

Category
Status