lancew/DojoList

Summary

A
2 hrs

Method `recaptcha_check_answer` has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open

``````function recaptcha_check_answer(\$privkey, \$remoteip, \$challenge, \$response, \$extra_params = array())
{
if (\$privkey == null || \$privkey == '') {
}``````

Method `recaptcha_check_answer` has 5 arguments (exceeds 4 allowed). Consider refactoring. Open

``function recaptcha_check_answer(\$privkey, \$remoteip, \$challenge, \$response, \$extra_params = array())``

Function `recaptcha_check_answer` has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open

``````function recaptcha_check_answer(\$privkey, \$remoteip, \$challenge, \$response, \$extra_params = array())
{
if (\$privkey == null || \$privkey == '') {
}``````

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"

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

``````function recaptcha_check_answer(\$privkey, \$remoteip, \$challenge, \$response, \$extra_params = array())
{
if (\$privkey == null || \$privkey == '') {
}``````

Since: PHPMD 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;
}
}
}
}``````

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

``function recaptcha_get_html(\$pubkey, \$error = null, \$use_ssl = false)``

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 recaptcha_get_html uses an else expression. Else is never necessary and you can simplify the code to work without else. Open

``````    } else {
}``````

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
}
}
}``````

The method recaptcha_check_answer uses an else expression. Else is never necessary and you can simplify the code to work without else. Open

``````    else {
}``````

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
}
}
}``````

The method _recaptcha_mailhide_email_parts uses an else expression. Else is never necessary and you can simplify the code to work without else. Open

``````    } else {
\$arr[0] = substr(\$arr[0], 0, 4);
}``````

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 local variables such as '\$errno'. Open

``    if(false == ( \$fs = @fsockopen(\$host, \$port, \$errno, \$errstr, 10) ) ) {``

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
}
}``````

The function _recaptcha_http_post() contains an exit expression. Open

``        die('Could not open socket');``

Since: PHPMD 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);
}
}
}``````

``        die("For security reasons, you must pass the remote ip to reCAPTCHA");``

Since: PHPMD 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);
}
}
}``````

The function recaptcha_get_html() 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>");``

Since: PHPMD 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);
}
}
}``````

The function _recaptcha_aes_encrypt() contains an exit expression. Open

``        die("To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed.");``

Since: PHPMD 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);
}
}
}``````

Avoid unused local variables such as '\$errstr'. Open

``    if(false == ( \$fs = @fsockopen(\$host, \$port, \$errno, \$errstr, 10) ) ) {``

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
}
}``````

``        die("To use reCAPTCHA you must get an API key from <a href='http://recaptcha.net/api/getkey'>http://recaptcha.net/api/getkey</a>");``

Since: PHPMD 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);
}
}
}``````

The function recaptcha_mailhide_url() contains an exit expression. Open

``````        die(
"To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " .
);``````

Since: PHPMD 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);
}
}
}``````

The parameter \$extra_params is not named in camelCase. Open

``````function recaptcha_check_answer(\$privkey, \$remoteip, \$challenge, \$response, \$extra_params = array())
{
if (\$privkey == null || \$privkey == '') {
}``````

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) {
}
}``````

Avoid variables with short names like \$ky. Configured minimum length is 3. Open

``function _recaptcha_aes_encrypt(\$val,\$ky) ``

Since: PHPMD 0.2

Detects when a field, local, or parameter has a very short name.

Example:

``````class Something {
private \$q = 15; // VIOLATION - Field
public static function main( array \$as ) { // VIOLATION - Formal
\$r = 20 + \$this->q; // VIOLATION - Local
for (int \$i = 0; \$i < 10; \$i++) { // Not a Violation (inside FOR)
\$r += \$this->q;
}
}
}``````

The property \$is_valid is not named in camelCase. Open

``````class ReCaptchaResponse
{
var \$is_valid;
var \$error;
}``````

Since: PHPMD 0.2

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

Example:

``````class ClassName {
protected \$property_name;
}``````

Avoid variables with short names like \$fs. Configured minimum length is 3. Open

``    if(false == ( \$fs = @fsockopen(\$host, \$port, \$errno, \$errstr, 10) ) ) {``

Since: PHPMD 0.2

Detects when a field, local, or parameter has a very short name.

Example:

``````class Something {
private \$q = 15; // VIOLATION - Field
public static function main( array \$as ) { // VIOLATION - Formal
\$r = 20 + \$this->q; // VIOLATION - Local
for (int \$i = 0; \$i < 10; \$i++) { // Not a Violation (inside FOR)
\$r += \$this->q;
}
}
}``````

The parameter \$use_ssl is not named in camelCase. Open

``````function recaptcha_get_html(\$pubkey, \$error = null, \$use_ssl = false)
{
if (\$pubkey == null || \$pubkey == '') {
}``````

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) {
}
}``````

Avoid variables with short names like \$x. Configured minimum length is 3. Open

``function _recaptcha_mailhide_urlbase64(\$x) ``

Since: PHPMD 0.2

Detects when a field, local, or parameter has a very short name.

Example:

``````class Something {
private \$q = 15; // VIOLATION - Field
public static function main( array \$as ) { // VIOLATION - Formal
\$r = 20 + \$this->q; // VIOLATION - Local
for (int \$i = 0; \$i < 10; \$i++) { // Not a Violation (inside FOR)
\$r += \$this->q;
}
}
}``````

Avoid variables with short names like \$ky. Configured minimum length is 3. Open

``    \$ky = pack('H*', \$privkey);``

Since: PHPMD 0.2

Detects when a field, local, or parameter has a very short name.

Example:

``````class Something {
private \$q = 15; // VIOLATION - Field
public static function main( array \$as ) { // VIOLATION - Formal
\$r = 20 + \$this->q; // VIOLATION - Local
for (int \$i = 0; \$i < 10; \$i++) { // Not a Violation (inside FOR)
\$r += \$this->q;
}
}
}``````

The variable \$http_request is not named in camelCase. Open

``````function _recaptcha_http_post(\$host, \$path, \$data, \$port = 80)
{

``````

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

``````function recaptcha_get_html(\$pubkey, \$error = null, \$use_ssl = false)
{
if (\$pubkey == null || \$pubkey == '') {
}``````

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

``````function _recaptcha_aes_pad(\$val)
{
\$block_size = 16;
\$numpad = \$block_size - (strlen(\$val) % \$block_size);

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

``````function _recaptcha_http_post(\$host, \$path, \$data, \$port = 80)
{

``````

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

``````function recaptcha_check_answer(\$privkey, \$remoteip, \$challenge, \$response, \$extra_params = array())
{
if (\$privkey == null || \$privkey == '') {
}``````

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

``````function _recaptcha_http_post(\$host, \$path, \$data, \$port = 80)
{

``````

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

``````function _recaptcha_aes_pad(\$val)
{
\$block_size = 16;
\$numpad = \$block_size - (strlen(\$val) % \$block_size);

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

``````function _recaptcha_http_post(\$host, \$path, \$data, \$port = 80)
{

``````

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

``````function _recaptcha_http_post(\$host, \$path, \$data, \$port = 80)
{

``````

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

``````function recaptcha_check_answer(\$privkey, \$remoteip, \$challenge, \$response, \$extra_params = array())
{
if (\$privkey == null || \$privkey == '') {
}``````

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

``````function _recaptcha_http_post(\$host, \$path, \$data, \$port = 80)
{

``````

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

``````function recaptcha_check_answer(\$privkey, \$remoteip, \$challenge, \$response, \$extra_params = array())
{
if (\$privkey == null || \$privkey == '') {
}``````

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

``````function recaptcha_check_answer(\$privkey, \$remoteip, \$challenge, \$response, \$extra_params = array())
{
if (\$privkey == null || \$privkey == '') {
}``````

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

``````function recaptcha_check_answer(\$privkey, \$remoteip, \$challenge, \$response, \$extra_params = array())
{
if (\$privkey == null || \$privkey == '') {
}``````

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

``````function recaptcha_check_answer(\$privkey, \$remoteip, \$challenge, \$response, \$extra_params = array())
{
if (\$privkey == null || \$privkey == '') {
}``````

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

``````function _recaptcha_aes_pad(\$val)
{
\$block_size = 16;
\$numpad = \$block_size - (strlen(\$val) % \$block_size);

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

``````function recaptcha_check_answer(\$privkey, \$remoteip, \$challenge, \$response, \$extra_params = array())
{
if (\$privkey == null || \$privkey == '') {
}``````

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

``````function _recaptcha_http_post(\$host, \$path, \$data, \$port = 80)
{

``````

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

``````function recaptcha_check_answer(\$privkey, \$remoteip, \$challenge, \$response, \$extra_params = array())
{
if (\$privkey == null || \$privkey == '') {
}``````

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

``````function _recaptcha_http_post(\$host, \$path, \$data, \$port = 80)
{

``````

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

``````function recaptcha_check_answer(\$privkey, \$remoteip, \$challenge, \$response, \$extra_params = array())
{
if (\$privkey == null || \$privkey == '') {
}``````

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

``````function recaptcha_check_answer(\$privkey, \$remoteip, \$challenge, \$response, \$extra_params = array())
{
if (\$privkey == null || \$privkey == '') {
}``````

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();
}
}``````