Showing 146 of 546 total issues

Method BroadcastStopMonitoringBuilder.BuildMonitoredStopVisit has 6 return statements (exceeds 4 allowed).
Open

func (builder *BroadcastStopMonitoringBuilder) BuildMonitoredStopVisit(stopVisit *model.StopVisit) *siri.SIRIMonitoredStopVisit {
    stopPointRef, stopPointRefCode, ok := builder.stopPointRef(stopVisit.StopAreaId)
    if !ok {
        logger.Log.Printf("Ignore StopVisit %v without StopArea or with StopArea without correct Code", stopVisit.Id())
        return nil
Severity: Major
Found in core/broadcast_stop_monitoring_builder.go - About 40 mins to fix

    Method VehicleMonitoringUpdateEventBuilder.handleCoordinates has 6 return statements (exceeds 4 allowed).
    Open

    func (builder *VehicleMonitoringUpdateEventBuilder) handleCoordinates(xmlVehicleActivity *sxml.XMLVehicleActivity) (lon, lat float64, e error) {
        longitude, _ := strconv.ParseFloat(xmlVehicleActivity.Longitude(), 64)
        latitude, _ := strconv.ParseFloat(xmlVehicleActivity.Latitude(), 64)
    
        if latitude != 0 || longitude != 0 {
    Severity: Major
    Found in core/vehicle_monitoring_update_event_builder.go - About 40 mins to fix

      Method MemoryStopAreas.Load has 6 return statements (exceeds 4 allowed).
      Open

      func (manager *MemoryStopAreas) Load(referentialSlug string) error {
          var selectStopAreas []SelectStopArea
          modelName := manager.model.Date()
      
          sqlQuery := fmt.Sprintf("select * from stop_areas where referential_slug = '%s' and model_name = '%s'", referentialSlug, modelName.String())
      Severity: Major
      Found in model/stop_area.go - About 40 mins to fix

        Method Controller.serve has 6 return statements (exceeds 4 allowed).
        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: Major
        Found in api/controller.go - About 40 mins to fix

          Method SIRIEstimatedTimetableSubscriptionBroadcaster.stopPointRef has 6 return statements (exceeds 4 allowed).
          Open

          func (connector *SIRIEstimatedTimetableSubscriptionBroadcaster) 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/estimated_timetable_broadcaster.go - About 40 mins to fix

            Method MemoryStopVisits.Load has 6 return statements (exceeds 4 allowed).
            Open

            func (manager *MemoryStopVisits) Load(referentialSlug string) error {
                var selectStopVisits []SelectStopVisit
                modelName := manager.model.Date()
            
                sqlQuery := fmt.Sprintf("select * from stop_visits where referential_slug = '%s' and model_name = '%s'", referentialSlug, modelName.String())
            Severity: Major
            Found in model/stop_visit.go - About 40 mins to fix

              Method BroadcastGeneralMessageBuilder.BuildGeneralMessage has 6 return statements (exceeds 4 allowed).
              Open

              func (builder *BroadcastGeneralMessageBuilder) BuildGeneralMessage(situation model.Situation) *siri.SIRIGeneralMessage {
                  if !builder.canBroadcast(situation) {
                      return nil
                  }
              
              
              Severity: Major
              Found in core/broadcast_general_message_builder.go - About 40 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 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 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 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

                        Function AffectFromProto has 5 return statements (exceeds 4 allowed).
                        Open

                        func AffectFromProto(value interface{}, remoteCodeSpace string, m Model) (Affect, *AffectRefs, error) {
                            collectedRefs := &AffectRefs{
                                MonitoringRefs: make(map[string]struct{}),
                                LineRefs:       make(map[string]struct{}),
                            }
                        Severity: Major
                        Found in model/situation.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 SituationExchangeUpdateEventBuilder.buildSituationExchangeUpdateEvent has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                            Open

                            func (builder *SituationExchangeUpdateEventBuilder) buildSituationExchangeUpdateEvent(event *CollectUpdateEvents, xmlSituation *sxml.XMLPtSituationElement, producerRef string) {
                                if len(xmlSituation.Affects()) == 0 {
                                    return
                                }
                            
                            
                            Severity: Minor
                            Found in core/situation_exchange_update_event_builder.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 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 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 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 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 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
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language