davide-casiraghi/laravel-events-calendar

View on GitHub

Showing 51 of 65 total issues

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

    public static function getMapMarkerIconColor(int $eventCategoryId)
    {
        $ret = '';
        switch ($eventCategoryId) {
            case 1: //Regular Jam
Severity: Minor
Found in src/LaravelEventsCalendar.php - About 1 hr to fix

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

        public function index(Request $request)
        {
            $countries = Country::getCountries();
            $regions = Region::listsTranslations('name')->pluck('name', 'id');
    
    
    Severity: Minor
    Found in src/Http/Controllers/EventVenueController.php - About 1 hr to fix

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

          public function index(Request $request)
          {
              $countries = Country::getCountries();
              //$countries = Country::getActiveCountries();
      
      
      Severity: Minor
      Found in src/Http/Controllers/RegionController.php - About 1 hr to fix

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

            public function eventsValidator(Request $request)
            {
                $rules = [
                    'title' => 'required',
                    'description' => 'required',
        Severity: Minor
        Found in src/Http/Controllers/EventController.php - About 1 hr to fix

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

              public function saveEventRepetitions(Request $request, int $eventId): void
              {
                  EventRepetition::deletePreviousRepetitions($eventId);
          
                  // Saving repetitions - If it's a single event will be stored with just one repetition
          Severity: Minor
          Found in src/Http/Controllers/EventController.php - About 1 hr to fix

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

                public function build()
                {
                    // Configure email parameters in .env file
                    switch ($this->report['reason']) {
            
            
            Severity: Minor
            Found in src/Mail/ReportMisuse.php - About 1 hr to fix

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

                  public static function getMapMarkerIconColor(int $eventCategoryId)
                  {
                      $ret = '';
                      switch ($eventCategoryId) {
                          case 1: //Regular Jam
              Severity: Minor
              Found in src/LaravelEventsCalendar.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 cleanString has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function cleanString(string $text)
                  {
                      // Transform whitespaces to %20 for the URL
                      $text = str_replace(' ', '%20', $text);
                      $text = str_replace('ß', '%DF', $text);
              Severity: Minor
              Found in src/LaravelEventsCalendar.php - About 1 hr to fix

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

                    public static function getActiveEventsMapMarkersDataFromDb()
                    {
                        $seconds = 86400; // One day (this cache tag get invalidates also on event save)
                
                        $ret = Cache::remember('active_events_map_markers_db_data', $seconds, function () {
                Severity: Minor
                Found in src/Models/Event.php - About 1 hr to fix

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

                      public static function saveMonthlyRepeatDates(int $eventId, array $monthRepeatDatas, string $startDate, string $repeatUntilDate, string $timeStart, string $timeEnd)
                      {
                          $month = Carbon::createFromFormat('Y-m-d', $startDate);
                          $end = Carbon::createFromFormat('Y-m-d', $repeatUntilDate);
                          $weekdayArray = [Carbon::MONDAY, Carbon::TUESDAY, Carbon::WEDNESDAY, Carbon::THURSDAY, Carbon::FRIDAY, Carbon::SATURDAY, Carbon::SUNDAY];
                  Severity: Minor
                  Found in src/Models/EventRepetition.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 preSave has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function preSave(array $requestArray, $eventPicture): void
                      {
                          $teachers = Teacher::pluck('name', 'id');
                  
                          $this->title = $requestArray['title'];
                  Severity: Minor
                  Found in src/Models/Event.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 saveWeeklyRepeatDates has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public static function saveWeeklyRepeatDates(int $eventId, array $weekDays, string $startDate, string $repeatUntilDate, string $timeStart, string $timeEnd)
                  Severity: Minor
                  Found in src/Models/EventRepetition.php - About 45 mins to fix

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

                        public static function saveMonthlyRepeatDates(int $eventId, array $monthRepeatDatas, string $startDate, string $repeatUntilDate, string $timeStart, string $timeEnd)
                    Severity: Minor
                    Found in src/Models/EventRepetition.php - About 45 mins to fix

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

                          public function setEventRepeatFields(array $requestArray)
                          {
                              // Set Repeat Until
                              $this->repeat_type = $requestArray['repeat_type'];
                              if (isset($requestArray['repeat_until']) && array_key_exists('repeat_until', $requestArray)) {
                      Severity: Minor
                      Found in src/Models/Event.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 saveMultipleRepeatDates has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          public static function saveMultipleRepeatDates(int $eventId, array $singleDaysRepeatDatas, string $startDate, string $timeStart, string $timeEnd)
                      Severity: Minor
                      Found in src/Models/EventRepetition.php - About 35 mins to fix

                        Method uploadImageOnServer has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            public static function uploadImageOnServer($imageFile, string $imageName, string $imageSubdir, int $imageWidth, int $thumbWidth): void
                        Severity: Minor
                        Found in src/LaravelEventsCalendar.php - About 35 mins to fix

                          Method saveEventRepetitionOnDB has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              public static function saveEventRepetitionOnDB(int $eventId, string $dateStart, string $dateEnd, string $timeStart, string $timeEnd)
                          Severity: Minor
                          Found in src/Models/EventRepetition.php - About 35 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                                    return $query->where('event_venues.city', 'like', '%'.$city.'%');
                            Severity: Major
                            Found in src/Models/Event.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                          return "<?php echo date('g.i a', strtotime($expression))?>";
                              Severity: Major
                              Found in src/LaravelEventsCalendarServiceProvider.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                        return view('laravel-events-calendar::events.index', compact('events'))
                                            ->with('i', (request()->input('page', 1) - 1) * 20)
                                            ->with('eventCategories', $eventCategories)
                                            ->with('countries', $countries)
                                            ->with('venues', $venues)
                                Severity: Major
                                Found in src/Http/Controllers/EventController.php - About 30 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language