davide-casiraghi/laravel-events-calendar

View on GitHub

Showing 65 of 65 total issues

Method run has 260 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function run()
    {
        $countries = [
            ['id' => '1', 'name' => 'Italy', 'continent_id' => '6', 'code' => 'IT'],
            ['id' => '2', 'name' => 'United States', 'continent_id' => '3', 'code' => 'US'],
Severity: Major
Found in database/seeds/CountriesTableSeeder.php - About 1 day to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            if ($searchKeywords || $searchCountry) {
                $eventVenues = DB::table('event_venues')
                    ->when($authorUserId, function ($query, $authorUserId) {
                        return $query->where('created_by', $authorUserId);
                    })
    Severity: Major
    Found in src/Http/Controllers/EventVenueController.php and 1 other location - About 6 hrs to fix
    src/Http/Controllers/TeacherController.php on lines 60..80

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 213.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            if ($searchKeywords || $searchCountry) {
                $teachers = DB::table('teachers')
                    ->when($authorUserId, function ($query, $authorUserId) {
                        return $query->where('created_by', $authorUserId);
                    })
    Severity: Major
    Found in src/Http/Controllers/TeacherController.php and 1 other location - About 6 hrs to fix
    src/Http/Controllers/EventVenueController.php on lines 41..61

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 213.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    File EventController.php has 399 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace DavideCasiraghi\LaravelEventsCalendar\Http\Controllers;
    
    use DavideCasiraghi\LaravelEventsCalendar\Facades\LaravelEventsCalendar;
    Severity: Minor
    Found in src/Http/Controllers/EventController.php - About 5 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          public function store(Request $request)
          {
              // Validate form datas
              $validator = Validator::make($request->all(), [
                  'name' => 'required',
      Severity: Major
      Found in src/Http/Controllers/EventCategoryTranslationController.php and 1 other location - About 4 hrs to fix
      src/Http/Controllers/RegionTranslationController.php on lines 50..71

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 166.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          public function store(Request $request)
          {
              // Validate form datas
              $validator = Validator::make($request->all(), [
                  'name' => 'required',
      Severity: Major
      Found in src/Http/Controllers/RegionTranslationController.php and 1 other location - About 4 hrs to fix
      src/Http/Controllers/EventCategoryTranslationController.php on lines 50..71

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 166.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      File LaravelEventsCalendar.php has 320 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      
      namespace DavideCasiraghi\LaravelEventsCalendar;
      
      use Carbon\Carbon;
      Severity: Minor
      Found in src/LaravelEventsCalendar.php - About 3 hrs to fix

        Method boot has 71 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function boot()
            {
                /*
                 * Optional methods to load your package assets
                 */
        Severity: Major
        Found in src/LaravelEventsCalendarServiceProvider.php - About 2 hrs to fix

          File CountriesTableSeeder.php has 269 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          
          use Illuminate\Database\Seeder;
          use Illuminate\Support\Facades\DB;
          
          
          Severity: Minor
          Found in database/seeds/CountriesTableSeeder.php - About 2 hrs to fix

            File Event.php has 265 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            
            namespace DavideCasiraghi\LaravelEventsCalendar\Models;
            
            use Carbon\Carbon;
            Severity: Minor
            Found in src/Models/Event.php - About 2 hrs to fix

              Method getEvents has 55 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function getEvents(array $filters, $itemPerPage)
                  {
                      if (! array_key_exists('startDate', $filters) || ! $filters['startDate']) {
                          $filters['startDate'] = Carbon::now()->format('Y-m-d');
                      }
              Severity: Major
              Found in src/Models/Event.php - About 2 hrs to fix

                EventController has 21 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class EventController extends Controller
                {
                    /***************************************************************************/
                    /* Restrict the access to this resource just to logged in users except show view */
                    public function __construct()
                Severity: Minor
                Found in src/Http/Controllers/EventController.php - About 2 hrs to fix

                  File create.blade.php has 252 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  @extends('laravel-events-calendar::events.layout')
                  
                  @section('javascript-document-ready')
                      @parent
                      {{-- End date update after start date has changed, and doesn't allow to select a date before the start --}}
                  Severity: Minor
                  Found in resources/views/events/create.blade.php - About 2 hrs to fix

                    File edit.blade.php has 251 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    @extends('laravel-events-calendar::events.layout')
                    
                    @section('content')
                        <div class="container max-w-lg px-0">
                            <div class="row py-4">
                    Severity: Minor
                    Found in resources/views/events/edit.blade.php - About 2 hrs to fix

                      Method calculateMonthlySelectOptions has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function calculateMonthlySelectOptions(Request $request)
                          {
                              $monthlySelectOptions = [];
                              $date = implode('-', array_reverse(explode('/', $request->day)));  // Our YYYY-MM-DD date string
                              $unixTimestamp = strtotime($date);  // Convert the date string into a unix timestamp.
                      Severity: Minor
                      Found in src/Http/Controllers/EventController.php - About 1 hr to fix

                        Method saveMonthlyRepeatDates has 44 lines of code (exceeds 25 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 1 hr to fix

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                              public function store(Request $request)
                              {
                                  // Validate form datas
                                  $validator = $this->teachersValidator($request);
                                  if ($validator->fails()) {
                          Severity: Major
                          Found in src/Http/Controllers/TeacherController.php and 1 other location - About 1 hr to fix
                          src/Http/Controllers/OrganizerController.php on lines 82..96

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 115.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                              public function store(Request $request)
                              {
                                  // Validate form datas
                                  $validator = $this->organizersValidator($request);
                                  if ($validator->fails()) {
                          Severity: Major
                          Found in src/Http/Controllers/OrganizerController.php and 1 other location - About 1 hr to fix
                          src/Http/Controllers/TeacherController.php on lines 119..133

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 115.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Consider simplifying this complex logical expression.
                          Open

                                  if ($filters['keywords'] || $filters['category'] || $filters['city'] || $filters['country'] || $filters['region'] || $filters['continent'] || $filters['teacher'] || $filters['venue'] || $filters['endDate']) {
                          
                                  //$start = microtime(true);
                                      //DB::enableQueryLog();
                                      $ret = self::
                          Severity: Critical
                          Found in src/Models/Event.php - About 1 hr to fix

                            Method getActiveEventsMapGeoJSON has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public static function getActiveEventsMapGeoJSON()
                                {
                                    $cacheExpireMinutes = 1440; // Set the duration time of the cache (1 day - 1440 minutes) - this cache tag get invalidates also on event save
                            
                                    $eventsMapGeoJSONArrayCached = Cache::remember('active_events_map_markers_json', $cacheExpireMinutes, function () {
                            Severity: Minor
                            Found in src/Models/Event.php - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language