lancew/DojoList

View on GitHub

Showing 1,940 of 1,940 total issues

The function mime_type() has 169 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

function mime_type($ext = null)
{
  $types = array(
    'ai'      => 'application/postscript',
    'aif'     => 'audio/x-aiff',
Severity: Minor
Found in lib/limonade.php by phpmd

The function recaptcha_check_answer() contains an exit expression.
Open

        die("To use reCAPTCHA you must get an API key from <a href='http://recaptcha.net/api/getkey'>http://recaptcha.net/api/getkey</a>");
Severity: Minor
Found in lib/recaptchalib.php by phpmd

ExitExpression

Since: 0.2

An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

Example

class Foo {
    public function bar($param)  {
        if ($param === 42) {
            exit(23);
        }
    }
}

Source https://phpmd.org/rules/design.html#exitexpression

The function run() has an NPath complexity of 16704. The configured NPath complexity threshold is 200.
Open

function run($env = null)
{
  if(is_null($env)) $env = env();
   
  # 0. Set default configuration
Severity: Minor
Found in lib/limonade.php by phpmd

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

Source https://phpmd.org/rules/codesize.html#npathcomplexity

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

  {
    $app_file = app_file();
    $path_info = isset($env['SERVER']['PATH_INFO']) ? $env['SERVER']['PATH_INFO'] : @getenv('PATH_INFO');
    $query_string =  isset($env['SERVER']['QUERY_STRING']) ? $env['SERVER']['QUERY_STRING'] : @getenv('QUERY_STRING');

Severity: Minor
Found in lib/limonade.php by phpmd

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

The function recaptcha_check_answer() contains an exit expression.
Open

        die("For security reasons, you must pass the remote ip to reCAPTCHA");
Severity: Minor
Found in lib/recaptchalib.php by phpmd

ExitExpression

Since: 0.2

An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

Example

class Foo {
    public function bar($param)  {
        if ($param === 42) {
            exit(23);
        }
    }
}

Source https://phpmd.org/rules/design.html#exitexpression

Avoid unused parameters such as '$errfile'.
Open

    function not_found($errno, $errstr, $errfile=null, $errline=null)
Severity: Minor
Found in lib/limonade.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 local variables such as '$options'.
Open

  $options = array( "options" => array("regexp" => $regexp ));
Severity: Minor
Found in lib/limonade.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

The function run() has 122 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

function run($env = null)
{
  if(is_null($env)) $env = env();
   
  # 0. Set default configuration
Severity: Minor
Found in lib/limonade.php by phpmd

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

function file_is_text($filename)
{
  if($mime = file_mime_content_type($filename)) return substr($mime,0,5) == "text/";
  return null;
}
Severity: Minor
Found in lib/limonade.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 assigning values to variables in if clauses and the like (line '2464', column '6').
Open

function file_mime_content_type($filename)
{
  $ext = file_extension($filename); /* strtolower isn't necessary */
  if($mime = mime_type($ext)) return $mime;
  elseif (function_exists('finfo_open'))
Severity: Minor
Found in lib/limonade.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 local variables such as '$errno'.
Open

    if(false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
Severity: Minor
Found in lib/recaptchalib.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

The function Dojo_Editform_end() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
Open

function Dojo_Editform_end() 
{
    if (!Validate_form($_POST) ) {
        $resp = recaptcha_check_answer(
            option('recaptcha_private_key'),
Severity: Minor
Found in controllers/dojo.php by phpmd

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

The function Create_dojo() has a Cyclomatic Complexity of 23. The configured cyclomatic complexity threshold is 10.
Open

function Create_dojo($dojo, $file = null)
{
    Backup_data();
    
    $xml = Load_Xml_data();
Severity: Minor
Found in lib/dojo.model.php by phpmd

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

Dojo_Create_add accesses the super-global variable $_POST.
Open

function Dojo_Create_add() 
{
    if (!Validate_form($_POST) ) {
        $resp = recaptcha_check_answer(
            option('recaptcha_private_key'),
Severity: Minor
Found in controllers/dojo.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Dojo_Editform_end accesses the super-global variable $_POST.
Open

function Dojo_Editform_end() 
{
    if (!Validate_form($_POST) ) {
        $resp = recaptcha_check_answer(
            option('recaptcha_private_key'),
Severity: Minor
Found in controllers/dojo.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Dojo_Editform_end accesses the super-global variable $_POST.
Open

function Dojo_Editform_end() 
{
    if (!Validate_form($_POST) ) {
        $resp = recaptcha_check_answer(
            option('recaptcha_private_key'),
Severity: Minor
Found in controllers/dojo.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

end_test_case accesses the super-global variable $GLOBALS.
Open

function end_test_case()
{
   $name = $GLOBALS["limonade"]["test_case_current"];
   echo "## ".strtoupper($name)."\n";
      
Severity: Minor
Found in lib/limonade/tests.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

unregister_globals accesses the super-global variable $GLOBALS.
Open

function unregister_globals()
{
  $args = func_get_args();
  foreach($args as $k => $v)
    if(array_key_exists($k, $GLOBALS)) unset($GLOBALS[$k]);
Severity: Minor
Found in lib/limonade.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

test_suite accesses the super-global variable $GLOBALS.
Open

function test_suite($name)
{
  $GLOBALS["limonade"]["test_suites"] = $name;
  echo test_cli_format("===========================================================\n", 'white');
  echo test_cli_format(">>>> START $name tests suites\n", 'white');
Severity: Minor
Found in lib/limonade/tests.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

end_test_suite accesses the super-global variable $GLOBALS.
Open

function end_test_suite()
{
  $name         = $GLOBALS["limonade"]["test_suites"];
  $failures     = 0;
  $tests        = 0;
Severity: Minor
Found in lib/limonade/tests.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Severity
Category
Status
Source
Language