jaroslavtyc/drd-plus-therugist-spells

View on GitHub

Showing 20 of 142 total issues

Modifier has 51 functions (exceeds 20 allowed). Consider refactoring.
Open

class Modifier extends StrictObject
{
    use ToFlatArrayTrait;

    /** @var ModifierCode */
Severity: Major
Found in DrdPlus/Theurgist/Spells/Modifier.php - About 7 hrs to fix

    File Formula.php has 410 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    declare(strict_types=1);
    
    namespace DrdPlus\Theurgist\Spells;
    
    
    Severity: Minor
    Found in DrdPlus/Theurgist/Spells/Formula.php - About 5 hrs to fix

      File Modifier.php has 375 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      declare(strict_types=1);
      
      namespace DrdPlus\Theurgist\Spells;
      
      
      Severity: Minor
      Found in DrdPlus/Theurgist/Spells/Modifier.php - About 5 hrs to fix

        Formula has 32 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Formula extends StrictObject
        {
            use ToFlatArrayTrait;
        
            /** @var FormulaCode */
        Severity: Minor
        Found in DrdPlus/Theurgist/Spells/Formula.php - About 4 hrs to fix

          File ModifiersTable.php has 303 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          declare(strict_types = 1);
          
          namespace DrdPlus\Theurgist\Spells;
          
          
          Severity: Minor
          Found in DrdPlus/Theurgist/Spells/ModifiersTable.php - About 3 hrs to fix

            ModifiersTable has 27 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class ModifiersTable extends AbstractFileTable
            {
                use ToFlatArrayTrait;
            
                /**
            Severity: Minor
            Found in DrdPlus/Theurgist/Spells/ModifiersTable.php - About 3 hrs to fix

              FormulasTable has 21 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class FormulasTable extends AbstractFileTable
              {
                  protected function getDataFileName(): string
                  {
                      return __DIR__ . '/data/formulas.csv';
              Severity: Minor
              Found in DrdPlus/Theurgist/Spells/FormulasTable.php - About 2 hrs to fix

                Function getParameterBonusFromModifiers has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function getParameterBonusFromModifiers(string $parameterName)
                    {
                        $bonusParts = [];
                        foreach ($this->modifiers as $modifier) {
                            if ($modifier->getModifierCode()->getValue() === ModifierCode::GATE) {
                Severity: Minor
                Found in DrdPlus/Theurgist/Spells/Formula.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

                Method getCurrentDifficulty has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function getCurrentDifficulty(): FormulaDifficulty
                    {
                        $formulaParameters = [
                            $this->getAttackWithAddition(),
                            $this->getBrightnessWithAddition(),
                Severity: Minor
                Found in DrdPlus/Theurgist/Spells/Formula.php - About 1 hr to fix

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

                      private function sanitizeSpellParameterChanges(array $spellParameterValues): array
                      {
                          $sanitizedChanges = [];
                          foreach (ModifierMutableSpellParameterCode::getPossibleValues() as $mutableSpellParameter) {
                              if (!array_key_exists($mutableSpellParameter, $spellParameterValues)) {
                  Severity: Minor
                  Found in DrdPlus/Theurgist/Spells/Modifier.php - About 1 hr to fix

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

                        private function sanitizeSpellParameterChanges(array $spellParameterValues): array
                        {
                            $sanitizedChanges = [];
                            foreach (FormulaMutableSpellParameterCode::getPossibleValues() as $mutableSpellParameter) {
                                if (!\array_key_exists($mutableSpellParameter, $spellParameterValues)) {
                    Severity: Minor
                    Found in DrdPlus/Theurgist/Spells/Formula.php - About 1 hr to fix

                      Method getDifficultyChange has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function getDifficultyChange(): DifficultyChange
                          {
                              $modifierParameters = [
                                  $this->getAttackWithAddition(),
                                  $this->getNumberOfConditionsWithAddition(),
                      Severity: Minor
                      Found in DrdPlus/Theurgist/Spells/Modifier.php - About 1 hr to fix

                        Method getParameterBonusFromModifiers has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private function getParameterBonusFromModifiers(string $parameterName)
                            {
                                $bonusParts = [];
                                foreach ($this->modifiers as $modifier) {
                                    if ($modifier->getModifierCode()->getValue() === ModifierCode::GATE) {
                        Severity: Minor
                        Found in DrdPlus/Theurgist/Spells/Formula.php - About 1 hr to fix

                          Method __construct has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function __construct(array $values)
                              {
                                  try {
                                      $this->minimal = ToInteger::toPositiveInteger($values[0] ?? null);
                                  } catch (\Granam\Integer\Tools\Exceptions\Exception $exception) {
                          Severity: Minor
                          Found in DrdPlus/Theurgist/Spells/SpellParameters/FormulaDifficulty.php - About 1 hr to fix

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

                                protected function getExpectedDataHeaderNamesToTypes(): array
                                {
                                    return [
                                        self::REALM => self::POSITIVE_INTEGER,
                                        self::REALMS_AFFECTION => self::ARRAY,
                            Severity: Minor
                            Found in DrdPlus/Theurgist/Spells/ModifiersTable.php - About 1 hr to fix

                              Function sanitizeSpellParameterChanges has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  private function sanitizeSpellParameterChanges(array $spellParameterValues): array
                                  {
                                      $sanitizedChanges = [];
                                      foreach (ModifierMutableSpellParameterCode::getPossibleValues() as $mutableSpellParameter) {
                                          if (!array_key_exists($mutableSpellParameter, $spellParameterValues)) {
                              Severity: Minor
                              Found in DrdPlus/Theurgist/Spells/Modifier.php - About 55 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 sanitizeSpellParameterChanges has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  private function sanitizeSpellParameterChanges(array $spellParameterValues): array
                                  {
                                      $sanitizedChanges = [];
                                      foreach (FormulaMutableSpellParameterCode::getPossibleValues() as $mutableSpellParameter) {
                                          if (!\array_key_exists($mutableSpellParameter, $spellParameterValues)) {
                              Severity: Minor
                              Found in DrdPlus/Theurgist/Spells/Formula.php - About 55 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

                              Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                      FormulaCode $formulaCode,
                                      FormulasTable $formulasTable,
                                      DistanceTable $distanceTable,
                                      array $formulaSpellParameterValues = [],
                                      array $modifiers = [],
                              Severity: Minor
                              Found in DrdPlus/Theurgist/Spells/Formula.php - About 45 mins to fix

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

                                    protected function toFlatArray(array $items): array
                                    {
                                        $flat = [];
                                        foreach ($items as $item) {
                                            if (\is_array($item)) {
                                Severity: Minor
                                Found in DrdPlus/Theurgist/Spells/ToFlatArrayTrait.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 getRealmsAffectionsSum has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    private function getRealmsAffectionsSum(): array
                                    {
                                        $baseRealmsAffection = $this->formulasTable->getRealmsAffection($this->getFormulaCode());
                                        $realmsAffectionsSum = [
                                            // like daily => -2
                                Severity: Minor
                                Found in DrdPlus/Theurgist/Spells/Formula.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