t1k3/laravel-calendar-event

View on GitHub

Showing 12 of 12 total issues

Method handle has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function handle()
    {
        $date                   = $this->option('date') ? Carbon::parse($this->option('date')) : Carbon::now();
        $templateCalendarEvents = $this->templateCalendarEvent
            ->where('is_recurring', true)
Severity: Major
Found in src/Console/Commands/GenerateCalendarEvent.php - About 2 hrs to fix

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

        function arrayIsEqualWithDB(array $array, \Illuminate\Database\Eloquent\Model $model, array $skippable = []): bool
        {
            $columns = $model->getFillable();
            foreach ($columns as $column) {
                if (in_array($column, $skippable)) continue;
    Severity: Minor
    Found in src/Support/helpers.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

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

        public function handle()
        {
            $date                   = $this->option('date') ? Carbon::parse($this->option('date')) : Carbon::now();
            $templateCalendarEvents = $this->templateCalendarEvent
                ->where('is_recurring', true)
    Severity: Minor
    Found in src/Console/Commands/GenerateCalendarEvent.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 getNextDateFromTemplate has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static function getNextDateFromTemplate(TemplateCalendarEvent $templateCalendarEvent, CalendarEvent $calendarEventTmpLast, \DateTimeInterface $date)
        {
            $dateNext = null;
            // TODO Refactor: OCP, Strategy
            if ($calendarEventTmpLast) {
    Severity: Minor
    Found in src/Models/CalendarEvent.php - About 1 hr to fix

      Method getNextCalendarEventStartDateTime has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getNextCalendarEventStartDateTime(\DateTimeInterface $startDateTime)
          {
              if (!$this->is_recurring) {
                  return null;
              }
      Severity: Minor
      Found in src/Models/TemplateCalendarEvent.php - About 1 hr to fix

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

            public function updateCalendarEvent(array $attributes, UserInterface $user = null, PlaceInterface $place = null)
            {
                DB::transaction(function () use ($attributes, $user, $place, &$calendarEventNew) {
                    $calendarEventNew = $this->createCalendarEvent(
                        array_merge(
        Severity: Minor
        Found in src/Models/CalendarEvent.php - About 1 hr to fix

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

              public static function showPotentialCalendarEventsOfMonth(\DateTimeInterface $date)
              {
                  $endOfRecurring = $date->lastOfMonth()->hour(23)->minute(59)->second(59);
                  $month = str_pad($endOfRecurring->month, 2, '0', STR_PAD_LEFT);
                  $templateCalendarEvents = self::getMonthlyEvents($endOfRecurring);
          Severity: Minor
          Found in src/Models/CalendarEvent.php - About 1 hr to fix

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

                public function getNextCalendarEventStartDateTime(\DateTimeInterface $startDateTime)
                {
                    if (!$this->is_recurring) {
                        return null;
                    }
            Severity: Minor
            Found in src/Models/TemplateCalendarEvent.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

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

                public function deleteCalendarEvent(bool $isRecurring = null)
                {
                    DB::transaction(function () use ($isRecurring, &$isDeleted) {
                        if ($isRecurring === null) {
                            $isRecurring = $this->template->is_recurring;
            Severity: Minor
            Found in src/Models/CalendarEvent.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

            Consider simplifying this complex logical expression.
            Open

                        if ($dateNext !== null
                            && ($templateCalendarEvent->end_of_recurring === null
                                || $dateNext <= $templateCalendarEvent->end_of_recurring
                            )
                            && $dateNext >= $date
            Severity: Major
            Found in src/Console/Commands/GenerateCalendarEvent.php - About 40 mins to fix

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

                  private static function getNextDateFromTemplate(TemplateCalendarEvent $templateCalendarEvent, CalendarEvent $calendarEventTmpLast, \DateTimeInterface $date)
                  {
                      $dateNext = null;
                      // TODO Refactor: OCP, Strategy
                      if ($calendarEventTmpLast) {
              Severity: Minor
              Found in src/Models/CalendarEvent.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 showPotentialCalendarEventsOfMonth has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function showPotentialCalendarEventsOfMonth(\DateTimeInterface $date)
                  {
                      $endOfRecurring = $date->lastOfMonth()->hour(23)->minute(59)->second(59);
                      $month = str_pad($endOfRecurring->month, 2, '0', STR_PAD_LEFT);
                      $templateCalendarEvents = self::getMonthlyEvents($endOfRecurring);
              Severity: Minor
              Found in src/Models/CalendarEvent.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

              Severity
              Category
              Status
              Source
              Language