JordanRL/Fermat

View on GitHub

Showing 50 of 52 total issues

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

    protected function sechScale(int $scale = null): string
    {

        $scale = $scale ?? $this->getScale();

src/Samsara/Fermat/Core/Types/Base/Traits/TrigonometryScaleTrait.php on lines 159..171

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 97.

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

<?php

namespace Samsara\Fermat\Core\Provider\RoundingModeAdapters\Modes;

/**
src/Samsara/Fermat/Core/Provider/RoundingModeAdapters/Modes/HalfEvenAdapter.php on lines 1..25

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 97.

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

    protected function cschScale(int $scale = null): string
    {

        $scale = $scale ?? $this->getScale();

src/Samsara/Fermat/Core/Types/Base/Traits/TrigonometryScaleTrait.php on lines 208..220

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 97.

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 5 locations. Consider refactoring.
Open

        if ($this instanceof Decimal) {
            $value = Numbers::makeOrDont(Numbers::IMMUTABLE, $value, $this->getScale());

            if ($this->compare($value) > -1) {
                return true;
Severity: Major
Found in src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php and 4 other locations - About 40 mins to fix
src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php on lines 28..44
src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php on lines 58..78
src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php on lines 144..164
src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php on lines 178..199

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 94.

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 5 locations. Consider refactoring.
Open

        if ($this instanceof Decimal) {
            $value = Numbers::makeOrDont(Numbers::IMMUTABLE, $value, $this->getScale());

            if ($this->compare($value) === -1) {
                return true;
Severity: Major
Found in src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php and 4 other locations - About 40 mins to fix
src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php on lines 28..44
src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php on lines 58..78
src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php on lines 92..112
src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php on lines 178..199

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 94.

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 5 locations. Consider refactoring.
Open

        if ($this instanceof Decimal) {
            $value = Numbers::makeOrDont(Numbers::IMMUTABLE, $value, $this->getScale());

            if ($this->compare($value) === 1) {
                return true;
Severity: Major
Found in src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php and 4 other locations - About 40 mins to fix
src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php on lines 28..44
src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php on lines 92..112
src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php on lines 144..164
src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php on lines 178..199

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 94.

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 5 locations. Consider refactoring.
Open

        if ($this instanceof Decimal) {
            $value = Numbers::makeOrDont(Numbers::IMMUTABLE, $value, $this->getScale());

            return $this->isEqualDecimal($value);
        } else {
Severity: Major
Found in src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php and 4 other locations - About 40 mins to fix
src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php on lines 58..78
src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php on lines 92..112
src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php on lines 144..164
src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php on lines 178..199

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 94.

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 5 locations. Consider refactoring.
Open

        if ($this instanceof Decimal) {
            /** @var ImmutableDecimal $value */
            $value = Numbers::makeOrDont(Numbers::IMMUTABLE, $value, $this->getScale());

            if ($this->compare($value) < 1) {
Severity: Major
Found in src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php and 4 other locations - About 40 mins to fix
src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php on lines 28..44
src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php on lines 58..78
src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php on lines 92..112
src/Samsara/Fermat/Core/Types/Traits/ComparisonTrait.php on lines 144..164

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 94.

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

            $realPart = match (true) {
                $partThis instanceof Fraction => match (true) {
                    $compareTo instanceof Fraction => self::normalizeObject($partThis, $mode, $scale),
                    default => self::normalizeObject($partThis->asDecimal(), $mode, $scale)
                },
src/Samsara/Fermat/Core/Types/Traits/NumberNormalizationTrait.php on lines 164..170

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 94.

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

            $imaginaryPart = match (true) {
                $partThis instanceof Fraction => match (true) {
                    $compareTo instanceof Fraction => self::normalizeObject($partThis, $mode, $scale),
                    default => self::normalizeObject($partThis->asDecimal(), $mode, $scale)
                },
src/Samsara/Fermat/Core/Types/Traits/NumberNormalizationTrait.php on lines 122..128

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 94.

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

Consider simplifying this complex logical expression.
Open

        if (
            is_string($num) ||
            is_float($num) ||
            is_int($num) ||
            $num instanceof MutableDecimal ||
Severity: Major
Found in src/Samsara/Fermat/Core/Types/Traits/SimpleArithmeticTrait.php - About 40 mins to fix

Consider simplifying this complex logical expression.
Open

        if (
            is_string($num) ||
            is_float($num) ||
            is_int($num) ||
            $num instanceof MutableDecimal ||
Severity: Major
Found in src/Samsara/Fermat/Core/Types/Traits/SimpleArithmeticTrait.php - About 40 mins to fix

Consider simplifying this complex logical expression.
Open

        if (
            is_string($num) ||
            is_float($num) ||
            is_int($num) ||
            $num instanceof MutableDecimal ||
Severity: Major
Found in src/Samsara/Fermat/Core/Types/Traits/SimpleArithmeticTrait.php - About 40 mins to fix

The class ModeAdapterFactory has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13.
Open

class ModeAdapterFactory
{
    /** @var BaseAdapter[] */
    private static array $modeAdapters = [];

CouplingBetweenObjects

Since: 1.1.0

A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

Example

class Foo {
    /**
     * @var \foo\bar\X
     */
    private $x = null;

    /**
     * @var \foo\bar\Y
     */
    private $y = null;

    /**
     * @var \foo\bar\Z
     */
    private $z = null;

    public function setFoo(\Foo $foo) {}
    public function setBar(\Bar $bar) {}
    public function setBaz(\Baz $baz) {}

    /**
     * @return \SplObjectStorage
     * @throws \OutOfRangeException
     * @throws \InvalidArgumentException
     * @throws \ErrorException
     */
    public function process(\Iterator $it) {}

    // ...
}

Source https://phpmd.org/rules/design.html#couplingbetweenobjects

Consider simplifying this complex logical expression.
Open

        if (
            is_string($num) ||
            is_float($num) ||
            is_int($num) ||
            $num instanceof MutableDecimal ||
Severity: Major
Found in src/Samsara/Fermat/Core/Types/Traits/SimpleArithmeticTrait.php - About 40 mins to fix

The class RandomProvider has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13.
Open

class RandomProvider
{

    /**
     * @param int        $scale

CouplingBetweenObjects

Since: 1.1.0

A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

Example

class Foo {
    /**
     * @var \foo\bar\X
     */
    private $x = null;

    /**
     * @var \foo\bar\Y
     */
    private $y = null;

    /**
     * @var \foo\bar\Z
     */
    private $z = null;

    public function setFoo(\Foo $foo) {}
    public function setBar(\Bar $bar) {}
    public function setBaz(\Baz $baz) {}

    /**
     * @return \SplObjectStorage
     * @throws \OutOfRangeException
     * @throws \InvalidArgumentException
     * @throws \ErrorException
     */
    public function process(\Iterator $it) {}

    // ...
}

Source https://phpmd.org/rules/design.html#couplingbetweenobjects

The class NumberCollection has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13.
Open

class NumberCollection implements NumberCollectionInterface, ArrayAccess, IteratorAggregate
{

    /**
     * @var Vector

CouplingBetweenObjects

Since: 1.1.0

A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

Example

class Foo {
    /**
     * @var \foo\bar\X
     */
    private $x = null;

    /**
     * @var \foo\bar\Y
     */
    private $y = null;

    /**
     * @var \foo\bar\Z
     */
    private $z = null;

    public function setFoo(\Foo $foo) {}
    public function setBar(\Bar $bar) {}
    public function setBaz(\Baz $baz) {}

    /**
     * @return \SplObjectStorage
     * @throws \OutOfRangeException
     * @throws \InvalidArgumentException
     * @throws \ErrorException
     */
    public function process(\Iterator $it) {}

    // ...
}

Source https://phpmd.org/rules/design.html#couplingbetweenobjects

The class Matrix has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13.
Open

abstract class Matrix implements MatrixInterface
{
    public const MODE_ROWS_INPUT = 'rows';
    public const MODE_COLUMNS_INPUT = 'columns';

CouplingBetweenObjects

Since: 1.1.0

A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

Example

class Foo {
    /**
     * @var \foo\bar\X
     */
    private $x = null;

    /**
     * @var \foo\bar\Y
     */
    private $y = null;

    /**
     * @var \foo\bar\Z
     */
    private $z = null;

    public function setFoo(\Foo $foo) {}
    public function setBar(\Bar $bar) {}
    public function setBaz(\Baz $baz) {}

    /**
     * @return \SplObjectStorage
     * @throws \OutOfRangeException
     * @throws \InvalidArgumentException
     * @throws \ErrorException
     */
    public function process(\Iterator $it) {}

    // ...
}

Source https://phpmd.org/rules/design.html#couplingbetweenobjects

The method tanScale() has an NPath complexity of 1920. The configured NPath complexity threshold is 200.
Open

    protected function tanScale(int $scale = null): string
    {
        $scale = $scale ?? $this->getScale();
        $intScale = $scale + 4;
        $intScale = $intScale + $this->numberOfIntDigits() + $this->numberOfLeadingZeros();

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

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

The method lnScale() has an NPath complexity of 216. The configured NPath complexity threshold is 200.
Open

    protected function lnScale(int $scale = null): string
    {
        $internalScale = $scale ?? $this->getScale();
        $internalScale += 3 + $this->numberOfLeadingZeros();

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

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

Severity
Category
Status
Source
Language