conorH22/bike-rental

View on GitHub

Showing 5 of 18 total issues

EBike has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

@Entity
public class EBike extends Bike implements Rechargeable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)

    EScooter has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

    @Entity
    public class EScooter extends Scooter implements Rechargeable {
    
        @Id
        @GeneratedValue(strategy = GenerationType.AUTO)

      Method checkIfTwoWheelReserved has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public Reservation checkIfTwoWheelReserved(TwoWheel twoWheel, Date date){
              List<Reservation> reservations = reservationRepository.findAllByTwoWheelAndCancelledFalse(twoWheel);
      
              for(Reservation reservation: reservations) {
                  if(!date.before(reservation.getStartDate()) && !date.after(reservation.getEndDate())) {

      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 checkIfTwoWheelReserved has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public Reservation checkIfTwoWheelReserved(TwoWheel twoWheel, Date date){
              List<Reservation> reservations = reservationRepository.findAllByTwoWheelAndCancelledFalse(twoWheel);
      
              for(Reservation reservation: reservations) {
                  if(!date.before(reservation.getStartDate()) && !date.after(reservation.getEndDate())) {

        Method getStats has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            @GetMapping("api/getStats")
            public Map<String,Integer> getStats(){
                Map<String, Integer> result = new HashMap<>();
                List<Station> stations =   stationService.getStations();
                int TotalStations = stations.size();
        Severity: Minor
        Found in src/main/java/com/csharp/bikerental/controller/RestController.java - 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