nishimura/laiz-monad

View on GitHub

Showing 13 of 13 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

function mappend(...$args) {
    $f = function($m1, $m2){
        if ($m1 instanceof Any &&
            !($m2 instanceof Any))
            $m1 = $m1->cast($m2);
Severity: Major
Found in src/Laiz/Func/Monoid.php and 2 other locations - About 3 hrs to fix
src/Laiz/Func/Alternative.php on lines 21..35
src/Laiz/Func/MonadPlus.php on lines 17..31

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 158.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

function mplus(...$args) {
    $f = function($m1, $m2){
        if ($m1 instanceof Any &&
            !($m2 instanceof Any))
            $m1 = $m1->cast($m2);
Severity: Major
Found in src/Laiz/Func/MonadPlus.php and 2 other locations - About 3 hrs to fix
src/Laiz/Func/Alternative.php on lines 21..35
src/Laiz/Func/Monoid.php on lines 18..32

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 158.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

function aor(...$args){
    $f = function($m1, $m2){
        if ($m1 instanceof Any &&
            !($m2 instanceof Any))
            $m1 = $m1->cast($m2);
Severity: Major
Found in src/Laiz/Func/Alternative.php and 2 other locations - About 3 hrs to fix
src/Laiz/Func/MonadPlus.php on lines 17..31
src/Laiz/Func/Monoid.php on lines 18..32

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 158.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function curry has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public static function curry(callable $f)
    {
        $ref = self::getReflection($f);
        $count = $ref->getNumberOfParameters();

Severity: Minor
Found in src/Laiz/Func/CurryTrait.php - About 2 hrs 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

Method curry has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function curry(callable $f)
    {
        $ref = self::getReflection($f);
        $count = $ref->getNumberOfParameters();

Severity: Minor
Found in src/Laiz/Func/CurryTrait.php - About 1 hr to fix

    Function __invoke has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public function __invoke($a)
        {
            if ($this->value instanceof Curry){
                $count = 1;
            }else if (is_object($this->value) && is_callable($this->value)){
    Severity: Minor
    Found in src/Laiz/Func/CurryTrait.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

    Function aor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function aor(...$args){
        $f = function($m1, $m2){
            if ($m1 instanceof Any &&
                !($m2 instanceof Any))
                $m1 = $m1->cast($m2);
    Severity: Minor
    Found in src/Laiz/Func/Alternative.php - About 45 mins 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

    Function mappend has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function mappend(...$args) {
        $f = function($m1, $m2){
            if ($m1 instanceof Any &&
                !($m2 instanceof Any))
                $m1 = $m1->cast($m2);
    Severity: Minor
    Found in src/Laiz/Func/Monoid.php - About 45 mins 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

    Function mplus has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function mplus(...$args) {
        $f = function($m1, $m2){
            if ($m1 instanceof Any &&
                !($m2 instanceof Any))
                $m1 = $m1->cast($m2);
    Severity: Minor
    Found in src/Laiz/Func/MonadPlus.php - About 45 mins 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    function const2(...$args)
    {
        $f = function($a1, $a2){
            return ap(fconst(id(), $a1), $a2);
        };
    Severity: Minor
    Found in src/Laiz/Func/Applicative.php and 1 other location - About 45 mins to fix
    src/Laiz/Func/Applicative.php on lines 59..68

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 95.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    function const1(...$args)
    {
        $f = function($a, $b){
            return ap(fmap(cnst(), $a), $b);
        };
    Severity: Minor
    Found in src/Laiz/Func/Applicative.php and 1 other location - About 45 mins to fix
    src/Laiz/Func/Applicative.php on lines 71..80

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 95.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function load has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function load($name = null)
        {
            static $loaded;
    
            if ($loaded)
    Severity: Minor
    Found in src/Laiz/Func/Loader.php - About 35 mins 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

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

        private static function getReflection(callable $f)
        {
            if (is_array($f)){
                return new \ReflectionMethod($f[0], $f[1]);
            }else if (is_string($f) &&
    Severity: Minor
    Found in src/Laiz/Func/CurryTrait.php - About 25 mins 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

    Severity
    Category
    Status
    Source
    Language