jaroslavtyc/drd-plus-tables

View on GitHub
tests/Tables/Measurements/Parts/AbstractMeasurementFileTableTest.php

Summary

Maintainability
C
7 hrs
Test Coverage

File AbstractMeasurementFileTableTest.php has 354 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php declare(strict_types = 1);

namespace DrdPlus\Tests\Tables\Measurements\Partials;

use DrdPlus\Tables\Measurements\Bonus;
Severity: Minor
Found in tests/Tables/Measurements/Parts/AbstractMeasurementFileTableTest.php - About 4 hrs to fix

    The class AbstractMeasurementFileTableTest has 13 public methods. Consider refactoring AbstractMeasurementFileTableTest to keep number of public methods under 10.
    Open

    class AbstractMeasurementFileTableTest extends TestWithMockery
    {
    
        /**
         * @var string

    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

    Method I_can_use_same_value_for_more_bonuses_and_get_lowest_bonus_by_closest_value has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function I_can_use_same_value_for_more_bonuses_and_get_lowest_bonus_by_closest_value()
        {
            $filename = $this->createTempFilename();
            $unit = 'bar';
            $lowerValue = 123;

      Method I_can_get_measurement_with_auto_chosen_unit_by_bonus has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function I_can_get_measurement_with_auto_chosen_unit_by_bonus()
          {
              $filename = $this->createTempFilename();
              $bonusValue1 = 123;
              $bonusValue2 = 456;

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

        class AbstractMeasurementFileTableTest extends TestWithMockery
        {
        
            /**
             * @var string

        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 __construct has a boolean flag argument $dataFileName, which is a certain sign of a Single Responsibility Principle violation.
        Open

            public function __construct(EvaluatorInterface $evaluator, $dataFileName = false, $units = [])

        BooleanArgumentFlag

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

        Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

        Missing class import via use statement (line '460', column '19').
        Open

                throw new \LogicException('Should not be called at all');

        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 using static access to class 'DrdPlus\Tests\Tables\Measurements\Partials\TestOfAbstractTable' in method 'I_can_not_create_table_without_data'.
        Open

                $table = TestOfAbstractTable::getIt($filename);

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid using static access to class 'DrdPlus\Tests\Tables\Measurements\Partials\TestOfAbstractTable' in method 'I_can_use_same_value_for_more_bonuses_and_get_lowest_bonus_by_closest_value'.
        Open

                $table = TestOfAbstractTable::getIt($filename, [$unit]);

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid using static access to class 'DrdPlus\Tests\Tables\Measurements\Partials\TestOfAbstractTable' in method 'I_can_not_create_table_with_corrupted_data'.
        Open

                $table = TestOfAbstractTable::getIt($filename);

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid using static access to class 'DrdPlus\Tests\Tables\Measurements\Partials\TestOfAbstractTable' in method 'I_can_not_use_same_bonus_for_more_values'.
        Open

                $table = TestOfAbstractTable::getIt($filename, [$unit]);

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid using static access to class '\Mockery' in method 'toBonus'.
        Open

                $measurement = \Mockery::mock(MeasurementWithBonus::class);

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid using static access to class 'DrdPlus\Tests\Tables\Measurements\Partials\TestOfAbstractTable' in method 'I_am_stopped_if_bonus_contains_non_numeric_value'.
        Open

                $table = TestOfAbstractTable::getIt($filename, ['foo']);

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid using static access to class 'DrdPlus\Tests\Tables\Measurements\Partials\TestOfAbstractTable' in method 'I_am_stopped_by_an_exception_if_can_not_convert_bonus_to_value'.
        Open

                $table = TestOfAbstractTable::getIt($filename, [$unit]);

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid using static access to class 'DrdPlus\Tests\Tables\Measurements\Partials\TestOfAbstractTable' in method 'I_can_not_convert_bonus_to_unknown_unit'.
        Open

                $table = TestOfAbstractTable::getIt($filename);

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid using static access to class 'DrdPlus\Tests\Tables\Measurements\Partials\TestOfAbstractTable' in method 'I_got_chance_evaluated_properly'.
        Open

                $table = TestOfAbstractTable::getIt($filename, [$unit], $this->createOneToOneEvaluator($valuesToEvaluate));

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid using static access to class 'DrdPlus\Tests\Tables\Measurements\Partials\TestOfAbstractTable' in method 'I_can_not_create_table_with_empty_source_file'.
        Open

                $table = TestOfAbstractTable::getIt($this->createTempFilename());

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid using static access to class 'DrdPlus\Tests\Tables\Measurements\Partials\TestOfAbstractTable' in method 'I_can_get_measurement_with_auto_chosen_unit_by_bonus'.
        Open

                $table = TestOfAbstractTable::getIt($filename, [$unit1, $unit2]);

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid using static access to class '\Mockery' in method 'getIt'.
        Open

                $evaluator = $evaluator ?: \Mockery::mock(EvaluatorInterface::class);

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid using static access to class 'DrdPlus\Tests\Tables\Measurements\Partials\TestOfAbstractTable' in method 'I_can_not_create_table_without_source_file'.
        Open

                    $table = TestOfAbstractTable::getIt('non-existing-file');

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid using static access to class 'DrdPlus\Tests\Tables\Measurements\Partials\TestOfAbstractTable' in method 'I_can_not_convert_bonus_to_invalid_value_change'.
        Open

                $table = TestOfAbstractTable::getIt($filename, [$unit]);

        StaticAccess

        Since: 1.4.0

        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

        Example

        class Foo
        {
            public function bar()
            {
                Bar::baz();
            }
        }

        Source https://phpmd.org/rules/cleancode.html#staticaccess

        Avoid excessively long variable names like $bonusesOfClosestValue. Keep variable name length under 20.
        Open

                $bonusesOfClosestValue = array_filter(array_map(

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

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

        Avoid excessively long variable names like $withLessColumnHeaderRowsThenRowHeader. Keep variable name length under 20.
        Open

                $withLessColumnHeaderRowsThenRowHeader = new WithLessColumnHeaderRowsThenRowHeader();

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

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

        Avoid excessively long variable names like $measurementFromSecondRow. Keep variable name length under 20.
        Open

                $measurementFromSecondRow = $table->toMeasurement(

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

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

        Avoid excessively long variable names like $measurementFromThirdRow. Keep variable name length under 20.
        Open

                $measurementFromThirdRow = $table->toMeasurement(

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

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

        Avoid excessively long variable names like $originalErrorReporting. Keep variable name length under 20.
        Open

                $originalErrorReporting = error_reporting();

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

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

        The method I_can_not_create_table_without_source_file is not named in camelCase.
        Open

            public function I_can_not_create_table_without_source_file()
            {
                $this->expectException(\DrdPlus\Tables\Measurements\Exceptions\FileCanNotBeRead::class);
                $originalErrorReporting = error_reporting();
                try {

        CamelCaseMethodName

        Since: 0.2

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

        Example

        class ClassName {
            public function get_name() {
            }
        }

        Source

        The method I_got_chance_evaluated_properly is not named in camelCase.
        Open

            public function I_got_chance_evaluated_properly()
            {
                $filename = $this->createTempFilename();
                $chances = range(0, 6);
                $unit = 'bar';

        CamelCaseMethodName

        Since: 0.2

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

        Example

        class ClassName {
            public function get_name() {
            }
        }

        Source

        The method I_can_get_simplified_header_with_more_row_header_rows_then_column_header is not named in camelCase.
        Open

            public function I_can_get_simplified_header_with_more_row_header_rows_then_column_header()
            {
                $withLessColumnHeaderRowsThenRowHeader = new WithLessColumnHeaderRowsThenRowHeader();
                self::assertEquals(
                    [

        CamelCaseMethodName

        Since: 0.2

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

        Example

        class ClassName {
            public function get_name() {
            }
        }

        Source

        The method I_am_stopped_if_bonus_contains_non_numeric_value is not named in camelCase.
        Open

            public function I_am_stopped_if_bonus_contains_non_numeric_value()
            {
                $this->expectException(\DrdPlus\Tables\Measurements\Partials\Exceptions\LoadingDataFailed::class);
                $filename = $this->createTempFilename();
                file_put_contents($filename, "bonus,foo\nSonOfSun,123456");

        CamelCaseMethodName

        Since: 0.2

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

        Example

        class ClassName {
            public function get_name() {
            }
        }

        Source

        The method I_am_stopped_by_an_exception_if_can_not_convert_bonus_to_value is not named in camelCase.
        Open

            public function I_am_stopped_by_an_exception_if_can_not_convert_bonus_to_value()
            {
                $this->expectException(\DrdPlus\Tables\Measurements\Partials\Exceptions\RequestedDataOutOfTableRange::class);
                $filename = $this->createTempFilename();
                $bonus = new BonusForTestOfAbstractTable(123);

        CamelCaseMethodName

        Since: 0.2

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

        Example

        class ClassName {
            public function get_name() {
            }
        }

        Source

        The method I_can_get_measurement_with_auto_chosen_unit_by_bonus is not named in camelCase.
        Open

            public function I_can_get_measurement_with_auto_chosen_unit_by_bonus()
            {
                $filename = $this->createTempFilename();
                $bonusValue1 = 123;
                $bonusValue2 = 456;

        CamelCaseMethodName

        Since: 0.2

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

        Example

        class ClassName {
            public function get_name() {
            }
        }

        Source

        The method I_can_use_same_value_for_more_bonuses_and_get_lowest_bonus_by_closest_value is not named in camelCase.
        Open

            public function I_can_use_same_value_for_more_bonuses_and_get_lowest_bonus_by_closest_value()
            {
                $filename = $this->createTempFilename();
                $unit = 'bar';
                $lowerValue = 123;

        CamelCaseMethodName

        Since: 0.2

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

        Example

        class ClassName {
            public function get_name() {
            }
        }

        Source

        The method I_can_not_convert_bonus_to_unknown_unit is not named in camelCase.
        Open

            public function I_can_not_convert_bonus_to_unknown_unit()
            {
                $this->expectException(\DrdPlus\Tables\Measurements\Exceptions\UnknownUnit::class);
                $filename = $this->createTempFilename();
                $bonus = new BonusForTestOfAbstractTable(123);

        CamelCaseMethodName

        Since: 0.2

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

        Example

        class ClassName {
            public function get_name() {
            }
        }

        Source

        The method I_can_not_create_table_with_corrupted_data is not named in camelCase.
        Open

            public function I_can_not_create_table_with_corrupted_data()
            {
                $this->expectException(\DrdPlus\Tables\Measurements\Exceptions\DataFromFileAreCorrupted::class);
                $filename = $this->createTempFilename();
                file_put_contents($filename, 'bar');

        CamelCaseMethodName

        Since: 0.2

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

        Example

        class ClassName {
            public function get_name() {
            }
        }

        Source

        The method I_can_not_create_table_without_data is not named in camelCase.
        Open

            public function I_can_not_create_table_without_data()
            {
                $this->expectException(\DrdPlus\Tables\Measurements\Exceptions\DataRowsAreMissingInFile::class);
                $filename = $this->createTempFilename();
                file_put_contents($filename, 'bonus');

        CamelCaseMethodName

        Since: 0.2

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

        Example

        class ClassName {
            public function get_name() {
            }
        }

        Source

        The method I_can_not_use_same_bonus_for_more_values is not named in camelCase.
        Open

            public function I_can_not_use_same_bonus_for_more_values()
            {
                $this->expectException(\DrdPlus\Tables\Measurements\Exceptions\BonusAlreadyPaired::class);
                $filename = $this->createTempFilename();
                $bonus = 123;

        CamelCaseMethodName

        Since: 0.2

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

        Example

        class ClassName {
            public function get_name() {
            }
        }

        Source

        The method I_can_not_create_table_with_empty_source_file is not named in camelCase.
        Open

            public function I_can_not_create_table_with_empty_source_file()
            {
                $this->expectException(\DrdPlus\Tables\Measurements\Exceptions\FileIsEmpty::class);
                $table = TestOfAbstractTable::getIt($this->createTempFilename());
                try {

        CamelCaseMethodName

        Since: 0.2

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

        Example

        class ClassName {
            public function get_name() {
            }
        }

        Source

        The method I_can_not_convert_bonus_to_invalid_value_change is not named in camelCase.
        Open

            public function I_can_not_convert_bonus_to_invalid_value_change()
            {
                $this->expectException(\DrdPlus\Tables\Measurements\Exceptions\UnexpectedChanceNotation::class);
                $filename = $this->createTempFilename();
                $bonus = new BonusForTestOfAbstractTable(123);

        CamelCaseMethodName

        Since: 0.2

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

        Example

        class ClassName {
            public function get_name() {
            }
        }

        Source

        There are no issues that match your filters.

        Category
        Status