Saibamen/HotelManager

View on GitHub

Showing 279 of 279 total issues

File ReservationController.php has 525 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace App\Http\Controllers;

use App\Http\Interfaces\ManageTableInterface;
Severity: Major
Found in app/Http/Controllers/ReservationController.php - About 1 day to fix

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

        public function store(GuestRequest $request, $objectId = null)
        {
            if ($objectId === null) {
                $object = new Guest();
            } else {
    Severity: Major
    Found in app/Http/Controllers/GuestController.php and 1 other location - About 3 hrs to fix
    app/Http/Controllers/RoomController.php on lines 88..111

    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 161.

    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(RoomRequest $request, $objectId = null)
        {
            if ($objectId === null) {
                $object = new Room();
            } else {
    Severity: Major
    Found in app/Http/Controllers/RoomController.php and 1 other location - About 3 hrs to fix
    app/Http/Controllers/GuestController.php on lines 42..65

    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 161.

    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 current()
        {
            $title = trans('navigation.current_reservations');
    
            $dataset = Reservation::select('id', 'room_id', 'guest_id', 'date_start', 'date_end', 'people')
    Severity: Major
    Found in app/Http/Controllers/ReservationController.php and 1 other location - About 3 hrs to fix
    app/Http/Controllers/ReservationController.php on lines 79..102

    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 155.

    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 future()
        {
            $title = trans('navigation.future_reservations');
    
            $dataset = Reservation::select('id', 'room_id', 'guest_id', 'date_start', 'date_end', 'people')
    Severity: Major
    Found in app/Http/Controllers/ReservationController.php and 1 other location - About 3 hrs to fix
    app/Http/Controllers/ReservationController.php on lines 54..77

    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 155.

    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 free()
        {
            $title = trans('navigation.currently_free_rooms');
    
            $dataset = Room::select('id', 'number', 'floor', 'capacity', 'price', 'comment')
    Severity: Major
    Found in app/Http/Controllers/RoomController.php and 1 other location - About 3 hrs to fix
    app/Http/Controllers/RoomController.php on lines 65..86

    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 149.

    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 occupied()
        {
            $title = trans('navigation.currently_occupied_rooms');
    
            $dataset = Room::select('id', 'number', 'floor', 'capacity', 'price', 'comment')
    Severity: Major
    Found in app/Http/Controllers/RoomController.php and 1 other location - About 3 hrs to fix
    app/Http/Controllers/RoomController.php on lines 42..63

    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 149.

    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

    The class ReservationController has an overall complexity of 51 which is very high. The configured complexity threshold is 50.
    Open

    class ReservationController extends Controller implements ManageTableInterface
    {
        protected $reservationTableService;
    
        public function __construct(ReservationTableService $reservationTableService)

    The class ReservationController has 16 public methods. Consider refactoring ReservationController to keep number of public methods under 10.
    Open

    class ReservationController extends Controller implements ManageTableInterface
    {
        protected $reservationTableService;
    
        public function __construct(ReservationTableService $reservationTableService)

    TooManyPublicMethods

    Since: 0.1

    A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

    By default it ignores methods starting with 'get' or 'set'.

    Example

    Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

    Method getFields has 75 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getFields()
        {
            return [
                [
                    'id'    => 'first_name',
    Severity: Major
    Found in app/Http/Controllers/GuestController.php - About 3 hrs to fix

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

      class ReservationController extends Controller implements ManageTableInterface
      {
          protected $reservationTableService;
      
          public function __construct(ReservationTableService $reservationTableService)
      Severity: Minor
      Found in app/Http/Controllers/ReservationController.php - About 2 hrs to fix

        Method getFields has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getFields()
            {
                return [
                    [
                        'id'    => 'number',
        Severity: Major
        Found in app/Http/Controllers/RoomController.php - About 2 hrs to fix

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

              public function delete($objectId)
              {
                  try {
                      $object = Room::findOrFail($objectId);
                  } catch (ModelNotFoundException $e) {
          Severity: Major
          Found in app/Http/Controllers/RoomController.php and 1 other location - About 2 hrs to fix
          app/Http/Controllers/GuestController.php on lines 67..83

          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 123.

          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

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

              public function delete($objectId)
              {
                  try {
                      $object = Guest::findOrFail($objectId);
                  } catch (ModelNotFoundException $e) {
          Severity: Major
          Found in app/Http/Controllers/GuestController.php and 1 other location - About 2 hrs to fix
          app/Http/Controllers/RoomController.php on lines 113..129

          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 123.

          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

          Method getFields has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getFields()
              {
                  return [
                      [
                          'id'    => 'name',
          Severity: Minor
          Found in app/Http/Controllers/UserController.php - About 1 hr to fix

            Method add has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function add($guestId, $roomId)
                {
                    if (!$this->isReservationDataInSessionCorrect()) {
                        return $this->returnBack([
                            'message'     => trans('general.session_error'),
            Severity: Minor
            Found in app/Http/Controllers/ReservationController.php - About 1 hr to fix

              Avoid excessively long variable names like $reservationsIdsForDates. Keep variable name length under 20.
              Open

                      $reservationsIdsForDates = DB::table('reservations')

              LongVariable

              Since: 0.2

              Detects when a field, formal or local variable is declared with a long name.

              Example

              class Something {
                  protected $reallyLongIntName = -3; // VIOLATION - Field
                  public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                      $otherReallyLongName = -5; // VIOLATION - Local
                      for ($interestingIntIndex = 0; // VIOLATION - For
                           $interestingIntIndex < 10;
                           $interestingIntIndex++ ) {
                      }
                  }
              }

              Source https://phpmd.org/rules/naming.html#longvariable

              Avoid excessively long variable names like $reservationTableService. Keep variable name length under 20.
              Open

                  protected $reservationTableService;

              LongVariable

              Since: 0.2

              Detects when a field, formal or local variable is declared with a long name.

              Example

              class Something {
                  protected $reallyLongIntName = -3; // VIOLATION - Field
                  public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                      $otherReallyLongName = -5; // VIOLATION - Local
                      for ($interestingIntIndex = 0; // VIOLATION - For
                           $interestingIntIndex < 10;
                           $interestingIntIndex++ ) {
                      }
                  }
              }

              Source https://phpmd.org/rules/naming.html#longvariable

              Avoid excessively long variable names like $reservationTableService. Keep variable name length under 20.
              Open

                  public function __construct(ReservationTableService $reservationTableService)

              LongVariable

              Since: 0.2

              Detects when a field, formal or local variable is declared with a long name.

              Example

              class Something {
                  protected $reallyLongIntName = -3; // VIOLATION - Field
                  public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                      $otherReallyLongName = -5; // VIOLATION - Local
                      for ($interestingIntIndex = 0; // VIOLATION - For
                           $interestingIntIndex < 10;
                           $interestingIntIndex++ ) {
                      }
                  }
              }

              Source https://phpmd.org/rules/naming.html#longvariable

              Method postEdit has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function postEdit(ReservationEditRequest $request, $objectId)
                  {
                      try {
                          $object = Reservation::with('room:id,capacity')
                              ->findOrFail($objectId);
              Severity: Minor
              Found in app/Http/Controllers/ReservationController.php - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language