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;
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
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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 = [])
- Read upRead up
- Exclude checks
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');
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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]);
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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]);
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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']);
- Read upRead up
- Exclude checks
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]);
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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));
- Read upRead up
- Exclude checks
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());
- Read upRead up
- Exclude checks
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]);
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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');
- Read upRead up
- Exclude checks
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]);
- Read upRead up
- Exclude checks
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(
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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(
- Read upRead up
- Exclude checks
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(
- Read upRead up
- Exclude checks
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();
- Read upRead up
- Exclude checks
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 {
- Read upRead up
- Exclude checks
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';
- Read upRead up
- Exclude checks
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(
[
- Read upRead up
- Exclude checks
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");
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
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');
- Read upRead up
- Exclude checks
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');
- Read upRead up
- Exclude checks
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;
- Read upRead up
- Exclude checks
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 {
- Read upRead up
- Exclude checks
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);
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}