madbob/GASdottoNG

View on GitHub
code/app/Singletons/ModifierEngine.php

Summary

Maintainability
D
2 days
Test Coverage

Function apply has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    public function apply($modifier, $booking, $aggregate_data)
    {
        if ($modifier->active == false) {
            Log::debug('Modificatore non attivo, ignoro applicazione');
            return null;
Severity: Minor
Found in code/app/Singletons/ModifierEngine.php - About 5 hrs 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 apply has 97 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function apply($modifier, $booking, $aggregate_data)
    {
        if ($modifier->active == false) {
            Log::debug('Modificatore non attivo, ignoro applicazione');
            return null;
Severity: Major
Found in code/app/Singletons/ModifierEngine.php - About 3 hrs to fix

    Function handlingAttributes has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        private function handlingAttributes($booking, $modifier, $attribute)
        {
            /*
                Se l'ordine è chiuso (ma non consegnato e archiviato) attingo dai
                valori relativi, che includono sia il consegnato che il prenotato ma
    Severity: Minor
    Found in code/app/Singletons/ModifierEngine.php - About 2 hrs 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

    File ModifierEngine.php has 260 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace App\Singletons;
    
    use Illuminate\Support\Facades\Log;
    Severity: Minor
    Found in code/app/Singletons/ModifierEngine.php - About 2 hrs to fix

      Function targetDefinition has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          private function targetDefinition($modifier, $value)
          {
              if ($modifier->scale == 'minor') {
                  foreach($modifier->definitions as $def) {
                      if ($value < $def->threshold) {
      Severity: Minor
      Found in code/app/Singletons/ModifierEngine.php - About 2 hrs 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 handlingAttributes has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function handlingAttributes($booking, $modifier, $attribute)
          {
              /*
                  Se l'ordine è chiuso (ma non consegnato e archiviato) attingo dai
                  valori relativi, che includono sia il consegnato che il prenotato ma
      Severity: Minor
      Found in code/app/Singletons/ModifierEngine.php - About 1 hr to fix

        Function applyDefinition has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            private function applyDefinition($booking, $modifier, $amount, $definition, $target)
            {
                list($quantity_attribute, $price_attribute, $weight_attribute) = $this->applicationOffsets($booking);
                $reference_quantity = 1;
        
        
        Severity: Minor
        Found in code/app/Singletons/ModifierEngine.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 applyDefinition has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            private function applyDefinition($booking, $modifier, $amount, $definition, $target)
        Severity: Minor
        Found in code/app/Singletons/ModifierEngine.php - About 35 mins to fix

          Avoid too many return statements within this method.
          Open

                          return null;
          Severity: Major
          Found in code/app/Singletons/ModifierEngine.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return $this->saveValue($modifier, $obj_mod_target, $altered_amount);
            Severity: Major
            Found in code/app/Singletons/ModifierEngine.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return null;
              Severity: Major
              Found in code/app/Singletons/ModifierEngine.php - About 30 mins to fix

                Function saveValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function saveValue($modifier, $obj_mod_target, $altered_amount)
                    {
                        $modifier_value = $this->retrieveExistingValue($modifier, $obj_mod_target);
                
                        /*
                Severity: Minor
                Found in code/app/Singletons/ModifierEngine.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

                There are no issues that match your filters.

                Category
                Status