Showing 146 of 546 total issues

Method LiteStopMonitoringUpdateEventBuilder.buildUpdateEvents has 87 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (builder *LiteStopMonitoringUpdateEventBuilder) buildUpdateEvents(StopVisitEvent *slite.MonitoredStopVisit) {
    // When Order is not defined, we should ignore the MonitoredStopVisit
    // see ARA-1240 "Special cases"
    if !StopVisitEvent.HasOrder() {
        return
Severity: Major
Found in core/lite_stop_monitoring_update_event_builder.go - About 2 hrs to fix

    Method BroadcastStopMonitoringBuilder.BuildMonitoredStopVisit has 86 lines of code (exceeds 50 allowed). Consider refactoring.
    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 2 hrs to fix

      Method SituationExchangeUpdateEventBuilder.buildSituationExchangeUpdateEvent has 86 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (builder *SituationExchangeUpdateEventBuilder) buildSituationExchangeUpdateEvent(event *CollectUpdateEvents, xmlSituation *sxml.XMLPtSituationElement, producerRef string) {
          if len(xmlSituation.Affects()) == 0 {
              return
          }
      
      
      Severity: Major
      Found in core/situation_exchange_update_event_builder.go - About 2 hrs to fix

        Method TripUpdatesBroadcaster.handleGtfs has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
        Open

        func (connector *TripUpdatesBroadcaster) handleGtfs() (entities []*gtfs.FeedEntity, err error) {
            stopVisits := connector.partner.Model().StopVisits().FindAllAfter(connector.Clock().Now().Add(PAST_STOP_VISITS_MAX_TIME))
            linesCode := make(map[model.VehicleJourneyId]model.Code)
            feedEntities := make(map[model.VehicleJourneyId]*gtfs.FeedEntity)
        
        
        Severity: Minor
        Found in core/gtfs_rt_trip_updates_broadcaster.go - About 2 hrs 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

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

        type MemoryStopVisits struct {
            uuid.UUIDConsumer
            clock.ClockConsumer
        
            model Model
        Severity: Minor
        Found in model/stop_visit.go - About 2 hrs to fix

          Method GtfsRequestCollector.handleAlert has 83 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (connector *GtfsRequestCollector) handleAlert(events *CollectUpdateEvents, a *gtfs.Alert, id string, timestamp uint64) {
              entities := a.GetInformedEntity()
              if len(entities) == 0 {
                  logger.Log.Debugf("%d affects for this Alert, skipping message", len(entities))
                  return
          Severity: Major
          Found in core/gtfs_rt_request_collector.go - About 2 hrs to fix

            Method TripUpdatesBroadcaster.handleGtfs has 83 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (connector *TripUpdatesBroadcaster) handleGtfs() (entities []*gtfs.FeedEntity, err error) {
                stopVisits := connector.partner.Model().StopVisits().FindAllAfter(connector.Clock().Now().Add(PAST_STOP_VISITS_MAX_TIME))
                linesCode := make(map[model.VehicleJourneyId]model.Code)
                feedEntities := make(map[model.VehicleJourneyId]*gtfs.FeedEntity)
            
            
            Severity: Major
            Found in core/gtfs_rt_trip_updates_broadcaster.go - About 2 hrs to fix

              File load_from_csv.go has 512 lines of code (exceeds 500 allowed). Consider refactoring.
              Open

              package model
              
              import (
                  "encoding/csv"
                  "fmt"
              Severity: Minor
              Found in model/load_from_csv.go - About 2 hrs to fix

                Method UpdateManager.updateStopVisit has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
                Open

                func (manager *UpdateManager) updateStopVisit(event *StopVisitUpdateEvent) {
                    if event.Code.Value() == "" { // Avoid creating a StopVisit with an empty code
                        return
                    }
                
                
                Severity: Minor
                Found in model/update_manager.go - About 2 hrs 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

                File stop_monitoring_response.go has 509 lines of code (exceeds 500 allowed). Consider refactoring.
                Open

                package sxml
                
                import (
                    "time"
                
                
                Severity: Minor
                Found in siri/sxml/stop_monitoring_response.go - About 2 hrs to fix

                  PartnerManager has 21 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  type PartnerManager struct {
                      uuid.UUIDConsumer
                  
                      mutex *sync.RWMutex
                  
                  
                  Severity: Minor
                  Found in core/partner.go - About 2 hrs to fix

                    Method StopMonitoringUpdateEventBuilder.buildUpdateEvents has 79 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (builder *StopMonitoringUpdateEventBuilder) buildUpdateEvents(xmlStopVisitEvent *sxml.XMLMonitoredStopVisit) {
                        origin := string(builder.partner.Slug())
                    
                        // StopAreas
                        stopAreaCode := model.NewCode(builder.remoteCodeSpace, xmlStopVisitEvent.StopPointRef())
                    Severity: Major
                    Found in core/stop_monitoring_update_event_builder.go - About 2 hrs to fix

                      Method ServiceAlertsBroadcaster.handleGtfs has 78 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (connector *ServiceAlertsBroadcaster) handleGtfs() (entities []*gtfs.FeedEntity, err error) {
                          situations := connector.partner.Model().Situations().FindAll()
                      
                          for _, situation := range situations {
                              if !connector.canBroadcast(situation) {
                      Severity: Major
                      Found in core/gtfs_rt_service_alerts_broadcaster.go - About 2 hrs to fix

                        Function deepValueEqual has 22 return statements (exceeds 4 allowed).
                        Open

                        func deepValueEqual(v1, v2 reflect.Value, visited map[visit]bool) bool {
                            if !v1.IsValid() || !v2.IsValid() {
                                return v1.IsValid() == v2.IsValid()
                            }
                            if v1.Type() != v2.Type() {
                        Severity: Major
                        Found in model/diff.go - About 2 hrs to fix

                          Method MemoryVehicleJourneys.Load has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
                          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: Minor
                          Found in model/vehicle_journey.go - About 1 hr 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 BroadcastGeneralMessageBuilder.BuildGeneralMessage has 72 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (builder *BroadcastGeneralMessageBuilder) BuildGeneralMessage(situation model.Situation) *siri.SIRIGeneralMessage {
                              if !builder.canBroadcast(situation) {
                                  return nil
                              }
                          
                          
                          Severity: Minor
                          Found in core/broadcast_general_message_builder.go - About 1 hr to fix

                            Method VehicleMonitoringUpdateEventBuilder.buildUpdateEvents has 71 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func (builder *VehicleMonitoringUpdateEventBuilder) buildUpdateEvents(xmlVehicleActivity *sxml.XMLVehicleActivity) {
                                origin := string(builder.partner.Slug())
                            
                                // StopAreas
                                stopAreaCode := model.NewCode(builder.remoteCodeSpace, xmlVehicleActivity.StopPointRef())
                            Severity: Minor
                            Found in core/vehicle_monitoring_update_event_builder.go - About 1 hr to fix

                              Method SIRIVehicleMonitoringRequestBroadcaster.buildVehicleActivity has 71 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

                              func (connector *SIRIVehicleMonitoringRequestBroadcaster) buildVehicleActivity(delivery *siri.SIRIVehicleMonitoringDelivery, line *model.Line, lineRef string, vehicle *model.Vehicle) {
                                  vehicleId, ok := vehicle.CodeWithFallback(connector.vehicleRemoteCodeSpaces)
                                  if !ok {
                                      return
                                  }
                              Severity: Minor
                              Found in core/siri_vehicle_monitoring_request_broadcaster.go - About 1 hr to fix

                                Method VehiclePositionBroadcaster.handleGtfs has 70 lines of code (exceeds 50 allowed). Consider refactoring.
                                Open

                                func (connector *VehiclePositionBroadcaster) handleGtfs() (entities []*gtfs.FeedEntity, err error) {
                                    vehicles := connector.partner.Model().Vehicles().FindAll()
                                    linesCode := make(map[model.VehicleJourneyId]model.Code)
                                    trips := make(map[model.VehicleJourneyId]*gtfs.TripDescriptor)
                                
                                
                                Severity: Minor
                                Found in core/gtfs_rt_vehicle_positions_broadcaster.go - About 1 hr to fix

                                  Method GtfsHandler.serve has 69 lines of code (exceeds 50 allowed). Consider refactoring.
                                  Open

                                  func (handler *GtfsHandler) serve(response http.ResponseWriter, request *http.Request, resource string) {
                                      // Find Partner by authorization Key
                                      partner, ok := handler.referential.Partners().FindByCredential(handler.token)
                                      if !ok {
                                          http.Error(response, "Invalid Authorization Token", http.StatusUnauthorized)
                                  Severity: Minor
                                  Found in api/gtfs_handler.go - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language