eustasy/authenticatron

View on GitHub

Showing 98 of 101 total issues

File documentation.php has 453 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

include __DIR__.'/assets/header.php';

require_once __DIR__.'/authenticatron.php';
Severity: Minor
Found in documentation.php - About 6 hrs to fix

    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

    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

    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

    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

    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

    Blank line found at end of control structure
    Open

    
    
    Severity: Minor
    Found in authenticatron.php by phpcodesniffer

    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

    Line exceeds 120 characters; contains 165 characters
    Open

                                echo '<p class="color-pomegranate">Incorrect Code: The code you entered was not valid at this time. Codes are valid for 30 seconds.</p>';
    Severity: Minor
    Found in index.php by phpcodesniffer

    Line exceeds 120 characters; contains 147 characters
    Open

                <p class="subtitle">Use <code>Authenticatron_New</code> to create a new secret for a member, and fetch a secure image for scanning.</p>
    Severity: Minor
    Found in index.php by phpcodesniffer
    Severity
    Category
    Status
    Source
    Language