kylekatarnls/business-day

View on GitHub

Showing 14 of 118 total issues

File HolidaysList.php has 279 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Cmixin\BusinessDay;

use Cmixin\BusinessDay\Util\Context;
Severity: Minor
Found in src/Cmixin/BusinessDay/HolidaysList.php - About 2 hrs to fix

    File HolidayCalculator.php has 261 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace Cmixin\BusinessDay\Calculator;
    
    use Cmixin\BusinessDay;
    Severity: Minor
    Found in src/Cmixin/BusinessDay/Calculator/HolidayCalculator.php - About 2 hrs to fix

      Function setHolidaysRegion has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          public function setHolidaysRegion()
          {
              $mixin = $this;
      
              /**
      Severity: Minor
      Found in src/Cmixin/BusinessDay/HolidaysList.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 matchYearCondition has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function matchYearCondition($dateTime, ?string &$condition): bool
          {
              if (!$condition || !preg_match(
                  '/^\s*year(?:\s*%\s*(?<modulo>\d+))?\s*(?<operator>>=?|<=?|={1,3}|!={1,2}|<>)\s*(?<expected>\d+)/',
                  $condition,
      Severity: Minor
      Found in src/Cmixin/BusinessDay/Util/YearCondition.php - About 1 hr to fix

        Method setHolidaysRegion has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function setHolidaysRegion()
            {
                $mixin = $this;
        
                /**
        Severity: Minor
        Found in src/Cmixin/BusinessDay/HolidaysList.php - About 1 hr to fix

          Function getHolidayDate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function getHolidayDate($key, $holiday)
              {
                  $year = $this->year;
          
                  if ($key === null) {
          Severity: Minor
          Found in src/Cmixin/BusinessDay/Calculator/HolidayCalculator.php - About 45 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 handleModifiers has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              protected function handleModifiers($dateTime, $condition, $substitute, $after, $before)
          Severity: Minor
          Found in src/Cmixin/BusinessDay/Calculator/HolidayCalculator.php - About 35 mins to fix

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

                protected function isIgnoredYear(&$holiday)
                {
                    $mode = 'since';
                    $cap = 0;
                    $every = 0;
            Severity: Minor
            Found in src/Cmixin/BusinessDay/Calculator/CalculatorBase.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 handleModifiers has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function handleModifiers($dateTime, $condition, $substitute, $after, $before)
                {
                    if ($condition && ($action = $this->getConditionalModifier(explode(' and ', $condition), $dateTime))) {
                        $dateTime = $dateTime->modify($action);
                    }
            Severity: Minor
            Found in src/Cmixin/BusinessDay/Calculator/HolidayCalculator.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

            Avoid too many return statements within this method.
            Open

                            return $value !== $expected;
            Severity: Major
            Found in src/Cmixin/BusinessDay/Util/YearCondition.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return $value === $expected;
              Severity: Major
              Found in src/Cmixin/BusinessDay/Util/YearCondition.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return $value <= $expected;
                Severity: Major
                Found in src/Cmixin/BusinessDay/Util/YearCondition.php - About 30 mins to fix

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

                      public function boot()
                      {
                          $config = $this->app->get('config')->get('carbon.holidays');
                  
                          if ($config instanceof Closure) {
                  Severity: Minor
                  Found in src/Cmixin/BusinessDay/Laravel/ServiceProvider.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

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

                      public function initializeHolidaysRegion($region = null)
                      {
                          if ($region) {
                              $region = call_user_func($this->standardizeHolidaysRegion(), $region);
                  
                  
                  Severity: Minor
                  Found in src/Cmixin/BusinessDay/HolidaysList.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