kylekatarnls/business-time

View on GitHub

Showing 13 of 228 total issues

Function parseMethodDoc has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
Open

    private function parseMethodDoc(
        string $name,
        int $length,
        string $className,
        string $defaultClass,
Severity: Minor
Found in types.php - About 7 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 getScheduleDoc has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getScheduleDoc($defaultClass, $source, $boot)
    {
        $methods = [];
        $source = str_replace('\\', '/', realpath($source));
        $sourceLength = strlen($source);
Severity: Major
Found in types.php - About 2 hrs to fix

    Function getScheduleDoc has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getScheduleDoc($defaultClass, $source, $boot)
        {
            $methods = [];
            $source = str_replace('\\', '/', realpath($source));
            $sourceLength = strlen($source);
    Severity: Minor
    Found in types.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 parseMethodDoc has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function parseMethodDoc(
            string $name,
            int $length,
            string $className,
            string $defaultClass,
    Severity: Minor
    Found in types.php - About 1 hr to fix

      Method enable has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function enable($carbonClass = null, $defaultOpeningHours = null)
          {
              if ($carbonClass === null) {
                  return static function () {
                      return true;
      Severity: Minor
      Found in src/BusinessTime/MixinBase.php - About 1 hr to fix

        Method create has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function create(array $openingHours): self
            {
                $businessTime = new self();
                $parser = new DefinitionParser($businessTime, $openingHours, function ($date) use ($businessTime) {
                    if ($date instanceof CarbonInterface) {
        Severity: Minor
        Found in src/BusinessTime/BusinessTimeWrapper.php - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                              if ((
                                  (!$mode || $mode === $mixin::LOCAL_MODE) &&
                                  ($date = end(static::$macroContextStack)) &&
                                  ($hours = $mixin->getOpeningHours($mixin::LOCAL_MODE, $date))
                              ) ||
          Severity: Major
          Found in src/BusinessTime/MixinBase.php - About 1 hr to fix

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

                public static function create(array $openingHours): self
                {
                    $businessTime = new self();
                    $parser = new DefinitionParser($businessTime, $openingHours, function ($date) use ($businessTime) {
                        if ($date instanceof CarbonInterface) {
            Severity: Minor
            Found in src/BusinessTime/BusinessTimeWrapper.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 enable has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function enable($carbonClass = null, $defaultOpeningHours = null)
                {
                    if ($carbonClass === null) {
                        return static function () {
                            return true;
            Severity: Minor
            Found in src/BusinessTime/MixinBase.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

            Avoid deeply nested control flow statements.
            Open

                                    if (preg_match('/^(public|protected)\s+function\s+(\S+)\(.*\)(\s*\{)?$/', trim($code[$i]), $match)) {
                                        break;
                                    }
            Severity: Major
            Found in types.php - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      for ($i = $length - 2; $i >= max(0, $length - 42); $i--) {
                                          $doc = $lines[$i].$doc;
              
                                          if (preg_match('/\s*\/\*{2,}\s*/', $lines[$i])) {
                                              $methodDocBlock = trim($doc) ?: $methodDocBlock;
              Severity: Major
              Found in types.php - About 45 mins to fix

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

                        string $name,
                        int $length,
                        string $className,
                        string $defaultClass,
                        array $code,
                Severity: Minor
                Found in types.php - About 45 mins to fix

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

                      public function getOpeningHours($mode = null, $context = null)
                      {
                          switch ($mode) {
                              case static::GLOBAL_MODE:
                                  return $this->openingHours;
                  Severity: Minor
                  Found in src/BusinessTime/MixinBase.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