Showing 134 of 525 total issues

Method Partner.CanCollectLines has 5 return statements (exceeds 4 allowed).
Open

func (partner *Partner) CanCollectLines(lineIds map[string]struct{}) s.CollectStatus {
    if len(lineIds) == 0 {
        return s.COLLECT_UNKNOWN
    }

Severity: Major
Found in core/partner.go - About 35 mins to fix

    Method MemoryLines.Load has 5 return statements (exceeds 4 allowed).
    Open

    func (manager *MemoryLines) Load(referentialSlug string) error {
        var selectLines []SelectLine
        modelName := manager.model.Date()
        sqlQuery := fmt.Sprintf("select * from lines where referential_slug = '%s' and model_name = '%s'", referentialSlug, modelName.String())
        _, err := Database.Select(&selectLines, sqlQuery)
    Severity: Major
    Found in model/lines.go - About 35 mins to fix

      Method MemoryVehicleJourneys.Load has 5 return statements (exceeds 4 allowed).
      Open

      func (manager *MemoryVehicleJourneys) Load(referentialSlug string) error {
          var selectVehicleJourneys []SelectVehicleJourney
          modelName := manager.model.Date()
          sqlQuery := fmt.Sprintf("select * from vehicle_journeys where referential_slug = '%s' and model_name = '%s'", referentialSlug, modelName.String())
          _, err := Database.Select(&selectVehicleJourneys, sqlQuery)
      Severity: Major
      Found in model/vehicle_journey.go - About 35 mins to fix

        Method UpdateManager.updateStopVisit has 5 return statements (exceeds 4 allowed).
        Open

        func (manager *UpdateManager) updateStopVisit(event *StopVisitUpdateEvent) {
            if event.Code.Value() == "" { // Avoid creating a StopVisit with an empty code
                return
            }
        
        
        Severity: Major
        Found in model/update_manager.go - About 35 mins to fix

          Method SIRIProductionTimetableSubscriptionBroadcaster.stopPointRef has 5 return statements (exceeds 4 allowed).
          Open

          func (connector *SIRIProductionTimetableSubscriptionBroadcaster) stopPointRef(stopAreaId model.StopAreaId) (*model.StopArea, string, bool) {
              stopPointRef, ok := connector.Partner().Model().StopAreas().Find(stopAreaId)
              if !ok {
                  return &model.StopArea{}, "", false
              }
          Severity: Major
          Found in core/production_timetable_broadcaster.go - About 35 mins to fix

            Method SIRILiteHandler.serve has 5 return statements (exceeds 4 allowed).
            Open

            func (handler *SIRILiteHandler) serve(response http.ResponseWriter, request *http.Request, requestData *SIRIRequestData) {
                if handler.token == "" {
                    http.Error(response, "No Authorization Token", http.StatusUnauthorized)
                    return
                }
            Severity: Major
            Found in api/siri_lite_handler.go - About 35 mins to fix

              Method BroadcastGeneralMessageBuilder.canBroadcast has 5 return statements (exceeds 4 allowed).
              Open

              func (builder *BroadcastGeneralMessageBuilder) canBroadcast(situation model.Situation) bool {
                  if situation.Origin == string(builder.partner.Slug()) {
                      return false
                  }
              
              
              Severity: Major
              Found in core/broadcast_general_message_builder.go - About 35 mins to fix

                Method BroadcastSituationExchangeBuilder.canBroadcast has 5 return statements (exceeds 4 allowed).
                Open

                func (builder *BroadcastSituationExchangeBuilder) canBroadcast(situation model.Situation) bool {
                    if situation.Origin == string(builder.partner.Slug()) {
                        return false
                    }
                
                
                Severity: Major
                Found in core/broadcast_situation_exchange_builder.go - About 35 mins to fix

                  Method TimeController.serve has 5 return statements (exceeds 4 allowed).
                  Open

                  func (controller *TimeController) serve(response http.ResponseWriter, request *http.Request, requestData *RequestData) {
                      switch {
                      case request.Method == "GET":
                          if requestData.Resource != "" {
                              http.Error(response, "Invalid request", http.StatusBadRequest)
                  Severity: Major
                  Found in api/time_controller.go - About 35 mins to fix

                    Method StopMonitoringLastChange.Haschanged has 5 return statements (exceeds 4 allowed).
                    Open

                    func (smlc *StopMonitoringLastChange) Haschanged(stopVisit *model.StopVisit) bool {
                        // Don't send info on cancelled or departed SV
                        if smlc.departureStatus == model.STOP_VISIT_DEPARTURE_DEPARTED || smlc.departureStatus == model.STOP_VISIT_DEPARTURE_CANCELLED || smlc.arrivalStatuts == model.STOP_VISIT_ARRIVAL_CANCELLED {
                            return false
                        }
                    Severity: Major
                    Found in core/ls/stop_monitoring_lc.go - About 35 mins to fix

                      Method Loader.Load has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                      Open

                      func (loader Loader) Load(reader io.Reader) Result {
                          // Config CSV reader
                          csvReader := csv.NewReader(reader)
                          csvReader.Comment = '#'
                          csvReader.FieldsPerRecord = -1
                      Severity: Minor
                      Found in model/load_from_csv.go - 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

                      Method SIRIEstimatedTimetableRequestBroadcaster.stopPointRef has 5 return statements (exceeds 4 allowed).
                      Open

                      func (connector *SIRIEstimatedTimetableRequestBroadcaster) stopPointRef(stopAreaId model.StopAreaId) (*model.StopArea, string, bool) {
                          stopPointRef, ok := connector.partner.Model().StopAreas().Find(stopAreaId)
                          if !ok {
                              return &model.StopArea{}, "", false
                          }
                      Severity: Major
                      Found in core/siri_estimated_timetable_request_broadcaster.go - About 35 mins to fix

                        Method Controller.serve has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func (controller *Controller) serve(response http.ResponseWriter, request *http.Request, requestData *RequestData) {
                            // Check request body
                            if requestData.Method == "PUT" || (requestData.Method == "POST" && requestData.Id != "save" && requestData.Action != "reload") {
                                requestData.Body = getRequestBody(response, request)
                                if requestData.Body == nil {
                        Severity: Minor
                        Found in api/controller.go - 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

                        Method SMSubscriber.prepareSIRIStopMonitoringSubscriptionRequest has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                        Open

                        func (subscriber *SMSubscriber) prepareSIRIStopMonitoringSubscriptionRequest() {
                            subscriptions := subscriber.connector.partner.Subscriptions().FindSubscriptionsByKind(StopMonitoringCollect)
                            if len(subscriptions) == 0 {
                                logger.Log.Debugf("StopMonitoringSubscriber visit without StopMonitoringCollect subscriptions")
                                return
                        Severity: Minor
                        Found in core/siri_stop_monitoring_subscriber.go - 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