boehm-s/fun-php

View on GitHub
src/internals/_curry2.php

Summary

Maintainability
A
0 mins
Test Coverage

Function _curry2 has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Invalid

function _curry2($fn) {
    return function($a = null, $b = null) use ($fn) {
        $a__  = _isPlaceholder($a);
        $b__  = _isPlaceholder($b);
        $args = func_get_args();
Severity: Minor
Found in src/internals/_curry2.php - About 1 hr 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 6 and the first side effect is on line 3.
Open

<?php
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

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

function _curry2($fn) {
Severity: Minor
Found in src/internals/_curry2.php by phpmd

ShortVariable

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

Source https://phpmd.org/rules/naming.html#shortvariable

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

            return $a__ ? $fn : _curry1(function ($_b) use ($fn, $a) {
Severity: Minor
Found in src/internals/_curry2.php by phpmd

ShortVariable

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

Source https://phpmd.org/rules/naming.html#shortvariable

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

                return _curry1(function ($_a) use($fn, $b) { return $fn($_a, $b); });
Severity: Minor
Found in src/internals/_curry2.php by phpmd

ShortVariable

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

Source https://phpmd.org/rules/naming.html#shortvariable

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

    return function($a = null, $b = null) use ($fn) {
Severity: Minor
Found in src/internals/_curry2.php by phpmd

ShortVariable

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

Source https://phpmd.org/rules/naming.html#shortvariable

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

    return function($a = null, $b = null) use ($fn) {
Severity: Minor
Found in src/internals/_curry2.php by phpmd

ShortVariable

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

Source https://phpmd.org/rules/naming.html#shortvariable

Expected 1 space after FUNCTION keyword; 0 found
Open

            return function(...$args) use ($fn) { return _curry2($fn)(...$args); };
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Each PHP statement must be on a line by itself
Open

                return _curry1(function ($_b) use($fn, $a) { return $fn($a, $_b); });
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Each PHP statement must be on a line by itself
Open

            return function(...$args) use ($fn) { return _curry2($fn)(...$args); };
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Terminating statement must be indented to the same level as the CASE body
Open

            return $a__ ? $fn : _curry1(function ($_b) use ($fn, $a) {
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Each PHP statement must be on a line by itself
Open

                return _curry1(function ($_a) use($fn, $b) { return $fn($_a, $b); });
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Expected 1 space after USE keyword; found 0
Open

                return _curry1(function ($_a) use($fn, $b) { return $fn($_a, $b); });
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Expected 1 space after USE keyword; found 0
Open

                return _curry1(function ($_b) use($fn, $a) { return $fn($a, $_b); });
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Terminating statement must be indented to the same level as the CASE body
Open

            return function(...$args) use ($fn) { return _curry2($fn)(...$args); };
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Expected 1 space after FUNCTION keyword; 0 found
Open

    return function($a = null, $b = null) use ($fn) {
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Inline control structures are not allowed
Open

            } else
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Line indented incorrectly; expected 16 spaces, found 12
Open

            if ($a__ && $b__) {
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Expected 1 space after ELSE keyword; newline found
Open

            } else
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Opening brace should be on a new line
Open

function _curry2($fn) {
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Usage of ELSE IF is discouraged; use ELSEIF instead
Open

            } else if ($a__) {
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Line indented incorrectly; expected 16 spaces, found 12
Open

            } else if($b__) {
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Line indented incorrectly; expected at least 20 spaces, found 16
Open

                return _curry1(function ($_a) use($fn, $b) { return $fn($_a, $b); });
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Usage of ELSE IF is discouraged; use ELSEIF instead
Open

            } else if($b__) {
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Expected 1 space after IF keyword; 0 found
Open

            } else if($b__) {
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Line indented incorrectly; expected 12 spaces, found 8
Open

        default:
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Opening brace must be the last content on the line
Open

            return function(...$args) use ($fn) { return _curry2($fn)(...$args); };
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Line indented incorrectly; expected at least 20 spaces, found 16
Open

                return $fn;
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Line indented incorrectly; expected 12 spaces, found 8
Open

        case 1:
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Closing brace must be on a line by itself
Open

                return _curry1(function ($_a) use($fn, $b) { return $fn($_a, $b); });
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Opening brace must be the last content on the line
Open

                return _curry1(function ($_b) use($fn, $a) { return $fn($a, $_b); });
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Closing brace must be on a line by itself
Open

                return _curry1(function ($_b) use($fn, $a) { return $fn($a, $_b); });
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Line indented incorrectly; expected 16 spaces, found 12
Open

            } else if ($a__) {
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Line indented incorrectly; expected 12 spaces, found 8
Open

        case 0:
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Closing brace must be on a line by itself
Open

            return function(...$args) use ($fn) { return _curry2($fn)(...$args); };
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Line indented incorrectly; expected at least 20 spaces, found 16
Open

                return _curry1(function ($_b) use($fn, $a) { return $fn($a, $_b); });
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Line indented incorrectly; expected 16 spaces, found 12
Open

            } else
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

Opening brace must be the last content on the line
Open

                return _curry1(function ($_a) use($fn, $b) { return $fn($_a, $b); });
Severity: Minor
Found in src/internals/_curry2.php by phpcodesniffer

The variable $_a is not named in camelCase.
Open

function _curry2($fn) {
    return function($a = null, $b = null) use ($fn) {
        $a__  = _isPlaceholder($a);
        $b__  = _isPlaceholder($b);
        $args = func_get_args();
Severity: Minor
Found in src/internals/_curry2.php by phpmd

CamelCaseVariableName

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

Source

The variable $a__ is not named in camelCase.
Open

function _curry2($fn) {
    return function($a = null, $b = null) use ($fn) {
        $a__  = _isPlaceholder($a);
        $b__  = _isPlaceholder($b);
        $args = func_get_args();
Severity: Minor
Found in src/internals/_curry2.php by phpmd

CamelCaseVariableName

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

Source

The variable $b__ is not named in camelCase.
Open

function _curry2($fn) {
    return function($a = null, $b = null) use ($fn) {
        $a__  = _isPlaceholder($a);
        $b__  = _isPlaceholder($b);
        $args = func_get_args();
Severity: Minor
Found in src/internals/_curry2.php by phpmd

CamelCaseVariableName

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

Source

The variable $a__ is not named in camelCase.
Open

function _curry2($fn) {
    return function($a = null, $b = null) use ($fn) {
        $a__  = _isPlaceholder($a);
        $b__  = _isPlaceholder($b);
        $args = func_get_args();
Severity: Minor
Found in src/internals/_curry2.php by phpmd

CamelCaseVariableName

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

Source

The variable $a__ is not named in camelCase.
Open

function _curry2($fn) {
    return function($a = null, $b = null) use ($fn) {
        $a__  = _isPlaceholder($a);
        $b__  = _isPlaceholder($b);
        $args = func_get_args();
Severity: Minor
Found in src/internals/_curry2.php by phpmd

CamelCaseVariableName

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

Source

The variable $b__ is not named in camelCase.
Open

function _curry2($fn) {
    return function($a = null, $b = null) use ($fn) {
        $a__  = _isPlaceholder($a);
        $b__  = _isPlaceholder($b);
        $args = func_get_args();
Severity: Minor
Found in src/internals/_curry2.php by phpmd

CamelCaseVariableName

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

Source

The variable $a__ is not named in camelCase.
Open

function _curry2($fn) {
    return function($a = null, $b = null) use ($fn) {
        $a__  = _isPlaceholder($a);
        $b__  = _isPlaceholder($b);
        $args = func_get_args();
Severity: Minor
Found in src/internals/_curry2.php by phpmd

CamelCaseVariableName

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

Source

The variable $_b is not named in camelCase.
Open

function _curry2($fn) {
    return function($a = null, $b = null) use ($fn) {
        $a__  = _isPlaceholder($a);
        $b__  = _isPlaceholder($b);
        $args = func_get_args();
Severity: Minor
Found in src/internals/_curry2.php by phpmd

CamelCaseVariableName

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

Source

The variable $_b is not named in camelCase.
Open

function _curry2($fn) {
    return function($a = null, $b = null) use ($fn) {
        $a__  = _isPlaceholder($a);
        $b__  = _isPlaceholder($b);
        $args = func_get_args();
Severity: Minor
Found in src/internals/_curry2.php by phpmd

CamelCaseVariableName

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

Source

The variable $b__ is not named in camelCase.
Open

function _curry2($fn) {
    return function($a = null, $b = null) use ($fn) {
        $a__  = _isPlaceholder($a);
        $b__  = _isPlaceholder($b);
        $args = func_get_args();
Severity: Minor
Found in src/internals/_curry2.php by phpmd

CamelCaseVariableName

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

Source

There are no issues that match your filters.

Category
Status