widmogrod/php-functional

View on GitHub

Showing 11 of 13 total issues

The class ListtCons has 14 public methods. Consider refactoring ListtCons to keep number of public methods under 10.
Open

class ListtCons implements Listt, \IteratorAggregate
{
    public const of = 'Widmogrod\Primitive\ListtCons::of';

    /**
Severity: Minor
Found in src/Primitive/ListtCons.php by phpmd

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

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

The class ListtNil has 12 public methods. Consider refactoring ListtNil to keep number of public methods under 10.
Open

class ListtNil implements Listt, \IteratorAggregate
{
    use Common\PointedTrait;

    public const of = 'Widmogrod\Primitive\ListtConst::of';
Severity: Minor
Found in src/Primitive/ListtNil.php by phpmd

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

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

Avoid classes with short names like In. Configured minimum length is 3.
Open

class In implements DooF
{
    private $names;
    private $fn;
    private $next;
Severity: Minor
Found in src/Monad/Control/Doo/Algebra/In.php by phpmd

ShortClassName

Since: 2.9

Detects when classes or interfaces have a very short name.

Example

class Fo {

}

interface Fo {

}

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

Avoid classes with short names like IO. Configured minimum length is 3.
Open

class IO implements
    FantasyLand\Monad,
    FantasyLand\Foldable
{
    const of = 'Widmogrod\Monad\IO::of';
Severity: Minor
Found in src/Monad/IO.php by phpmd

ShortClassName

Since: 2.9

Detects when classes or interfaces have a very short name.

Example

class Fo {

}

interface Fo {

}

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

Missing class import via use statement (line '86', column '33').
Open

    $reflectionOfFunction = new \ReflectionFunction(\Closure::fromCallable($function));
Severity: Minor
Found in src/Functional/functions.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '28', column '18').
Open

        $i = new \ArrayObject($i);
Severity: Minor
Found in src/Functional/listt.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Remove error control operator '@' on line 117.
Open

function readFile($fileName)
{
    return M\IO::of(function () use ($fileName) {
        $content = @file_get_contents($fileName);
        if ($content === false) {
Severity: Minor
Found in src/Monad/IO/functions.php by phpmd

ErrorControlOperator

Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

Example

function foo($filePath) {
    $file = @fopen($filPath); // hides exceptions
    $key = @$array[$notExistingKey]; // assigns null to $key
}

Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

Missing class import via use statement (line '132', column '20').
Open

        return new \ArrayObject();
Severity: Minor
Found in src/Primitive/ListtNil.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

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

function getChar()
{
    return M\IO::of(function () {
        if (false === ($char = fgetc(STDIN))) {
            throw userError(
Severity: Minor
Found in src/Monad/IO/functions.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

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

            } else {
                return $k->bind(function ($z) use ($f, $x) {
                    return $f($z, $x);
                });
            }
Severity: Minor
Found in src/Functional/functions.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

Avoid unused local variables such as '$head'.
Open

        [$head, $tail] = $this->headTail();
Severity: Minor
Found in src/Primitive/ListtCons.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

Severity
Category
Status
Source
Language