Showing 24 of 669 total issues
File HealthTest.php
has 1250 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php declare(strict_types=1);
namespace DrdPlus\Tests\Health;
use DrdPlus\Codes\Body\OrdinaryWoundOriginCode;
File Health.php
has 560 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php declare(strict_types=1);
namespace DrdPlus\Health;
use DrdPlus\BaseProperties\Will;
HealthTest
has 64 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class HealthTest extends TestWithMockery
{
/**
* @test
*/
Health
has 61 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class Health extends StrictObject
{
/**
* @var array|Wound[]
*/
Method I_can_be_wounded_both_ordinary_and_seriously
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function I_can_be_wounded_both_ordinary_and_seriously(): void
{
$ordinaryWoundsSize = 0;
$seriousWoundsSize = 0;
$health = $this->createHealthToTest($woundBoundary = $this->createWoundBoundary(10));
Method I_can_get_calculated_filled_half_rows_for_given_wound_value
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function I_can_get_calculated_filled_half_rows_for_given_wound_value(): void
{
// limit of wounds divisible by two (odd)
$gridOfWounds = new GridOfWounds($this->createHealth([] /* no wounds*/));
self::assertSame(
Method I_can_be_seriously_wounded
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function I_can_be_seriously_wounded(): void
{
$health = $this->createHealthToTest($woundBoundary = $this->createWoundBoundary(6));
$seriousWoundByStab = $health->addWound(
Method I_can_get_healed_serious_wounds
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function I_can_get_healed_serious_wounds(): void
{
$health = $this->createHealthToTest($woundBoundary = $this->createWoundBoundary(6));
$seriousWoundByStab = $health->addWound(
Method I_can_be_ordinary_wounded
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function I_can_be_ordinary_wounded(): void
{
$health = $this->createHealthToTest($woundBoundary = $this->createWoundBoundary(5));
$ordinaryWound = $health->addWound(
$this->createWoundSize(2),
Method I_can_ask_it_if_may_suffer_from_wounds
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function I_can_ask_it_if_may_suffer_from_wounds(): void
{
$woundBoundary = $this->createWoundBoundary(5);
$health = $this->createHealthToTest($woundBoundary);
self::assertFalse($health->maySufferFromWounds($woundBoundary));
Method I_can_ask_it_if_I_am_suffering_from_wounds
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function I_can_ask_it_if_I_am_suffering_from_wounds(): void
{
$woundBoundary = $this->createWoundBoundary(5);
$health = $this->createHealthToTest($woundBoundary);
self::assertFalse($health->mayHaveMalusFromWounds($woundBoundary));
Method Malus_can_increase_on_fresh_wound
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function Malus_can_increase_on_fresh_wound(int $willValue, int $rollValue, int $expectedMalus): void
{
$health = $this->createHealthToTest($woundBoundary = $this->createWoundBoundary(5));
$health->addWound(
Method Malus_can_not_decrease_on_fresh_wound
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function Malus_can_not_decrease_on_fresh_wound(int $willValue, int $rollValue, int $expectedMalus): void
{
$health = $this->createHealthToTest($woundBoundary = $this->createWoundBoundary(5));
$health->addWound($this->createWoundSize(5),
Function setGettingUsedToForTime
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
public function setGettingUsedToForTime(Time $gettingUsedToFor)
{
$inRounds = $gettingUsedToFor->findRounds();
if ($inRounds === null) {
// it can not be expressed by rounds, so definitely get used to it - malus zeroed
- Read upRead up
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 calculateFilledHalfRowsFor
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
public function calculateFilledHalfRowsFor(WoundSize $woundSize, WoundBoundary $woundBoundary): int
{
if ($this->getWoundsPerRowMaximum($woundBoundary) % 2 === 0) { // odd
$filledHalfRows = SumAndRound::floor($woundSize->getValue() / ($this->getWoundsPerRowMaximum($woundBoundary) / 2));
} else {
- Read upRead up
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 I_can_be_ordinary_healed
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function I_can_be_ordinary_healed(): void
{
$health = $this->createHealthToTest($woundBoundary = $this->createWoundBoundary(7));
$health->addWound($this->createWoundSize(1),
Method __construct
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
SeriousWound $seriousWound, // wound can be healed, but never disappears - just stays healed
AfflictionProperty $property,
AfflictionDangerousness $dangerousness,
AfflictionDomain $domain,
AfflictionVirulence $virulence,
Method __construct
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
Health $health,
AfflictionProperty $property,
AfflictionDangerousness $dangerousness,
AfflictionDomain $domain,
AfflictionVirulence $virulence,
Method It_is_linked_with_health_immediately
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function It_is_linked_with_health_immediately()
{
$woundBoundary = $this->mockery(WoundBoundary::class);
$woundBoundary->shouldReceive('getValue')
->andReturn(5);
Method I_should_roll_against_malus_from_wounds_because_of_heal_of_ordinary_wound
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function I_should_roll_against_malus_from_wounds_because_of_heal_of_ordinary_wound($willValue, $rollValue, $expectedMalus): void
{
$health = $this->createHealthToTest($woundBoundary = $this->createWoundBoundary(10));
$health->addWound($this->createWoundSize(4),
SeriousWoundOriginCode::getElementalWoundOrigin(),