end_test_case accesses the super-global variable $GLOBALS. Open
function end_test_case()
{
$name = $GLOBALS["limonade"]["test_case_current"];
echo "## ".strtoupper($name)."\n";
- Read upRead up
- Exclude checks
Since: PHPMD 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'];
}
}
end_test_case accesses the super-global variable $GLOBALS. Open
function end_test_case()
{
$name = $GLOBALS["limonade"]["test_case_current"];
echo "## ".strtoupper($name)."\n";
- Read upRead up
- Exclude checks
Since: PHPMD 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'];
}
}
test_assert_failure accesses the super-global variable $GLOBALS. Open
function test_assert_failure($script, $line, $message)
{
// Using the stack trace, find the outermost assert*() call
$stacktrace = array_slice(debug_backtrace(), 1); // skip self
$assertion = reset($stacktrace);
- Read upRead up
- Exclude checks
Since: PHPMD 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'];
}
}
end_test_suite accesses the super-global variable $GLOBALS. Open
function end_test_suite()
{
$name = $GLOBALS["limonade"]["test_suites"];
$failures = 0;
$tests = 0;
- Read upRead up
- Exclude checks
Since: PHPMD 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'];
}
}
test_case accesses the super-global variable $GLOBALS. Open
function test_case($name)
{
$name = strtolower($name); // TODO: normalize name
if(!array_key_exists($name, $GLOBALS["limonade"]["test_cases"]))
- Read upRead up
- Exclude checks
Since: PHPMD 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'];
}
}
end_test_suite accesses the super-global variable $GLOBALS. Open
function end_test_suite()
{
$name = $GLOBALS["limonade"]["test_suites"];
$failures = 0;
$tests = 0;
- Read upRead up
- Exclude checks
Since: PHPMD 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'];
}
}
test_case_all_func accesses the super-global variable $GLOBALS. Open
function test_case_all_func()
{
$functions = get_defined_functions();
$functions = $functions['user'];
$tests = array();
- Read upRead up
- Exclude checks
Since: PHPMD 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'];
}
}
test_run_assertion accesses the super-global variable $GLOBALS. Open
function test_run_assertion()
{
$name = $GLOBALS["limonade"]["test_case_current"];
$GLOBALS["limonade"]["test_cases"][$name]['assertions']++;
test_call_func(test_before_assert_func_name());
- Read upRead up
- Exclude checks
Since: PHPMD 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'];
}
}
test_assert_failure accesses the super-global variable $GLOBALS. Open
function test_assert_failure($script, $line, $message)
{
// Using the stack trace, find the outermost assert*() call
$stacktrace = array_slice(debug_backtrace(), 1); // skip self
$assertion = reset($stacktrace);
- Read upRead up
- Exclude checks
Since: PHPMD 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'];
}
}
test_case accesses the super-global variable $GLOBALS. Open
function test_case($name)
{
$name = strtolower($name); // TODO: normalize name
if(!array_key_exists($name, $GLOBALS["limonade"]["test_cases"]))
- Read upRead up
- Exclude checks
Since: PHPMD 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'];
}
}
test_case_current accesses the super-global variable $GLOBALS. Open
function &test_case_current()
{
$name = $GLOBALS["limonade"]["test_case_current"];
return $GLOBALS["limonade"]["test_cases"][$name];
}
- Read upRead up
- Exclude checks
Since: PHPMD 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'];
}
}
test_run_assertion accesses the super-global variable $GLOBALS. Open
function test_run_assertion()
{
$name = $GLOBALS["limonade"]["test_case_current"];
$GLOBALS["limonade"]["test_cases"][$name]['assertions']++;
test_call_func(test_before_assert_func_name());
- Read upRead up
- Exclude checks
Since: PHPMD 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'];
}
}
test_case_current accesses the super-global variable $GLOBALS. Open
function &test_case_current()
{
$name = $GLOBALS["limonade"]["test_case_current"];
return $GLOBALS["limonade"]["test_cases"][$name];
}
- Read upRead up
- Exclude checks
Since: PHPMD 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'];
}
}
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');
- Read upRead up
- Exclude checks
Since: PHPMD 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'];
}
}
end_test_case accesses the super-global variable $GLOBALS. Open
function end_test_case()
{
$name = $GLOBALS["limonade"]["test_case_current"];
echo "## ".strtoupper($name)."\n";
- Read upRead up
- Exclude checks
Since: PHPMD 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'];
}
}
test_error_handler accesses the super-global variable $GLOBALS. Open
function test_error_handler($errno, $errstr, $errfile, $errline)
{
if($errno < E_USER_ERROR || $errno > E_USER_NOTICE)
echo test_cli_format("!!! ERROR", "red") . " [$errno], $errstr in $errfile at line $errline\n";
$GLOBALS["limonade"]["test_errors"][] = array($errno, $errstr, $errfile, $errline);
- Read upRead up
- Exclude checks
Since: PHPMD 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'];
}
}
test_case accesses the super-global variable $GLOBALS. Open
function test_case($name)
{
$name = strtolower($name); // TODO: normalize name
if(!array_key_exists($name, $GLOBALS["limonade"]["test_cases"]))
- Read upRead up
- Exclude checks
Since: PHPMD 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'];
}
}
Method test_request
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function test_request($url, $method="GET", $include_header=false, $post_data=array(), $http_header=array()) {
Function test_case_all_func
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function test_case_all_func()
{
$functions = get_defined_functions();
$functions = $functions['user'];
$tests = array();
- Read upRead up
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 test_request has a boolean flag argument $include_header, which is a certain sign of a Single Responsibility Principle violation. Open
function test_request($url, $method="GET", $include_header=false, $post_data=array(), $http_header=array()) {
- Read upRead up
- Exclude checks
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) {
}
}
The method test_case uses an else expression. Else is never necessary and you can simplify the code to work without else. Open
{
}
- Read upRead up
- Exclude checks
Since: PHPMD 1.4.0
An if expression with an else branch is never necessary. You can rewrite the conditions in a way that the else is not necessary and the code becomes simpler to read. To achieve this use early return statements. To achieve this 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
}
}
}
Avoid unused parameters such as '$script'. Open
function test_assert_failure($script, $line, $message)
- Read upRead up
- Exclude checks
Since: PHPMD 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
}
}
Avoid unused local variables such as '$name'. Open
$func = "before_each_assert_in_$name".$test["name"];
- Read upRead up
- Exclude checks
Since: PHPMD 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example:
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Avoid unused parameters such as '$line'. Open
function test_assert_failure($script, $line, $message)
- Read upRead up
- Exclude checks
Since: PHPMD 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
}
}
Avoid unused local variables such as '$assert_code'. Open
list($assert_code, $message) = explode("//", $message);
- Read upRead up
- Exclude checks
Since: PHPMD 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example:
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
TODO found Open
# TODO: clean results output
- Exclude checks
TODO found Open
$name = strtolower($name); // TODO: normalize name
- Exclude checks
TODO found Open
// TODO: adding break for all test api methods
- Exclude checks
TODO found Open
# TODO: add all tests results
- Exclude checks
TODO found Open
# TODO: separate display from logic
- Exclude checks
The parameter $include_header is not named in camelCase. Open
function test_request($url, $method="GET", $include_header=false, $post_data=array(), $http_header=array()) {
$method = strtoupper($method);
$allowed_methods = array("GET", "PUT", "POST", "DELETE", "HEAD");
if(!in_array($method, $allowed_methods))
{
- Read upRead up
- Exclude checks
Since: PHPMD 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example:
class ClassName {
public function doSomething($user_name) {
}
}
The parameter $http_header is not named in camelCase. Open
function test_request($url, $method="GET", $include_header=false, $post_data=array(), $http_header=array()) {
$method = strtoupper($method);
$allowed_methods = array("GET", "PUT", "POST", "DELETE", "HEAD");
if(!in_array($method, $allowed_methods))
{
- Read upRead up
- Exclude checks
Since: PHPMD 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example:
class ClassName {
public function doSomething($user_name) {
}
}
The parameter $post_data is not named in camelCase. Open
function test_request($url, $method="GET", $include_header=false, $post_data=array(), $http_header=array()) {
$method = strtoupper($method);
$allowed_methods = array("GET", "PUT", "POST", "DELETE", "HEAD");
if(!in_array($method, $allowed_methods))
{
- Read upRead up
- Exclude checks
Since: PHPMD 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example:
class ClassName {
public function doSomething($user_name) {
}
}
The variable $assert_line is not named in camelCase. Open
function test_assert_failure($script, $line, $message)
{
// Using the stack trace, find the outermost assert*() call
$stacktrace = array_slice(debug_backtrace(), 1); // skip self
$assertion = reset($stacktrace);
- Read upRead up
- Exclude checks
Since: PHPMD 0.2
It is considered best practice to use the camelCase notation to name variables.
Example:
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
The variable $post_data is not named in camelCase. Open
function test_request($url, $method="GET", $include_header=false, $post_data=array(), $http_header=array()) {
$method = strtoupper($method);
$allowed_methods = array("GET", "PUT", "POST", "DELETE", "HEAD");
if(!in_array($method, $allowed_methods))
{
- Read upRead up
- Exclude checks
Since: PHPMD 0.2
It is considered best practice to use the camelCase notation to name variables.
Example:
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
The variable $assert_code is not named in camelCase. Open
function test_assert_failure($script, $line, $message)
{
// Using the stack trace, find the outermost assert*() call
$stacktrace = array_slice(debug_backtrace(), 1); // skip self
$assertion = reset($stacktrace);
- Read upRead up
- Exclude checks
Since: PHPMD 0.2
It is considered best practice to use the camelCase notation to name variables.
Example:
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
The variable $passed_tests is not named in camelCase. Open
function end_test_suite()
{
$name = $GLOBALS["limonade"]["test_suites"];
$failures = 0;
$tests = 0;
- Read upRead up
- Exclude checks
Since: PHPMD 0.2
It is considered best practice to use the camelCase notation to name variables.
Example:
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
The variable $passed_tests is not named in camelCase. Open
function end_test_suite()
{
$name = $GLOBALS["limonade"]["test_suites"];
$failures = 0;
$tests = 0;
- Read upRead up
- Exclude checks
Since: PHPMD 0.2
It is considered best practice to use the camelCase notation to name variables.
Example:
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
The variable $assert_file is not named in camelCase. Open
function test_assert_failure($script, $line, $message)
{
// Using the stack trace, find the outermost assert*() call
$stacktrace = array_slice(debug_backtrace(), 1); // skip self
$assertion = reset($stacktrace);
- Read upRead up
- Exclude checks
Since: PHPMD 0.2
It is considered best practice to use the camelCase notation to name variables.
Example:
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
The variable $passed_tests is not named in camelCase. Open
function end_test_suite()
{
$name = $GLOBALS["limonade"]["test_suites"];
$failures = 0;
$tests = 0;
- Read upRead up
- Exclude checks
Since: PHPMD 0.2
It is considered best practice to use the camelCase notation to name variables.
Example:
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
The variable $allowed_methods is not named in camelCase. Open
function test_request($url, $method="GET", $include_header=false, $post_data=array(), $http_header=array()) {
$method = strtoupper($method);
$allowed_methods = array("GET", "PUT", "POST", "DELETE", "HEAD");
if(!in_array($method, $allowed_methods))
{
- Read upRead up
- Exclude checks
Since: PHPMD 0.2
It is considered best practice to use the camelCase notation to name variables.
Example:
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
The variable $allowed_methods is not named in camelCase. Open
function test_request($url, $method="GET", $include_header=false, $post_data=array(), $http_header=array()) {
$method = strtoupper($method);
$allowed_methods = array("GET", "PUT", "POST", "DELETE", "HEAD");
if(!in_array($method, $allowed_methods))
{
- Read upRead up
- Exclude checks
Since: PHPMD 0.2
It is considered best practice to use the camelCase notation to name variables.
Example:
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
The variable $assert_line is not named in camelCase. Open
function test_assert_failure($script, $line, $message)
{
// Using the stack trace, find the outermost assert*() call
$stacktrace = array_slice(debug_backtrace(), 1); // skip self
$assertion = reset($stacktrace);
- Read upRead up
- Exclude checks
Since: PHPMD 0.2
It is considered best practice to use the camelCase notation to name variables.
Example:
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
The variable $assert_file is not named in camelCase. Open
function test_assert_failure($script, $line, $message)
{
// Using the stack trace, find the outermost assert*() call
$stacktrace = array_slice(debug_backtrace(), 1); // skip self
$assertion = reset($stacktrace);
- Read upRead up
- Exclude checks
Since: PHPMD 0.2
It is considered best practice to use the camelCase notation to name variables.
Example:
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
The variable $http_header is not named in camelCase. Open
function test_request($url, $method="GET", $include_header=false, $post_data=array(), $http_header=array()) {
$method = strtoupper($method);
$allowed_methods = array("GET", "PUT", "POST", "DELETE", "HEAD");
if(!in_array($method, $allowed_methods))
{
- Read upRead up
- Exclude checks
Since: PHPMD 0.2
It is considered best practice to use the camelCase notation to name variables.
Example:
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
The variable $include_header is not named in camelCase. Open
function test_request($url, $method="GET", $include_header=false, $post_data=array(), $http_header=array()) {
$method = strtoupper($method);
$allowed_methods = array("GET", "PUT", "POST", "DELETE", "HEAD");
if(!in_array($method, $allowed_methods))
{
- Read upRead up
- Exclude checks
Since: PHPMD 0.2
It is considered best practice to use the camelCase notation to name variables.
Example:
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}