Showing 134 of 525 total issues

Method SIRISituationExchangeRequestBroadcaster.buildSituation has 87 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (connector *SIRISituationExchangeRequestBroadcaster) buildSituation(delivery *siri.SIRISituationExchangeDelivery, situation model.Situation) {
    if !connector.canBroadcast(situation) {
        return
    }

Severity: Major
Found in core/siri_situation_exchange_request_broadcaster.go - About 2 hrs to fix

    File stop_visit.go has 520 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    package model
    
    import (
        "encoding/json"
        "fmt"
    Severity: Minor
    Found in model/stop_visit.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 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

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

        func (smb *SMBroadcaster) prepareSIRIStopMonitoringNotify() {
            smb.connector.mutex.Lock()
        
            events := smb.connector.toBroadcast
            smb.connector.toBroadcast = make(map[SubscriptionId][]model.StopVisitId)
        Severity: Minor
        Found in core/stop_monitoring_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

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

          type MemoryModel struct {
              lines               *MemoryLines
              vehicles            *MemoryVehicles
              stopAreas           *MemoryStopAreas
              stopVisits          *MemoryStopVisits
          Severity: Minor
          Found in model/model_interface.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

                File stop_monitoring_response.go has 508 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 SituationExchangeUpdateEventBuilder.buildSituationExchangeUpdateEvent has 76 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (builder *SituationExchangeUpdateEventBuilder) buildSituationExchangeUpdateEvent(event *[]*model.SituationUpdateEvent, 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

                        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 SIRILiteVehicleMonitoringRequestBroadcaster.RequestVehicles has 75 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (connector *SIRILiteVehicleMonitoringRequestBroadcaster) RequestVehicles(url string, filters url.Values, message *audit.BigQueryMessage) (siriLiteResponse *siri.SiriLiteResponse) {
                              lineRef := filters.Get("LineRef")
                          
                              message.RequestIdentifier = filters.Get("MessageIdentifier")
                              message.Lines = []string{lineRef}
                          Severity: Minor
                          Found in core/siri_lite_vehicle_monitoring_request_broadcaster.go - About 2 hrs to fix

                            Method UpdateManager.updateStopVisit has a Cognitive Complexity of 30 (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 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 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 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 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 SIRIStopMonitoringRequestBroadcaster.getStopMonitoringDelivery has 68 lines of code (exceeds 50 allowed). Consider refactoring.
                                Open

                                func (connector *SIRIStopMonitoringRequestBroadcaster) getStopMonitoringDelivery(request *sxml.XMLStopMonitoringRequest) siri.SIRIStopMonitoringDelivery {
                                    code := model.NewCode(connector.remoteCodeSpace, request.MonitoringRef())
                                    stopArea, ok := connector.partner.Model().StopAreas().FindByCode(code)
                                    if !ok {
                                        return siri.SIRIStopMonitoringDelivery{
                                Severity: Minor
                                Found in core/siri_stop_monitoring_request_broadcaster.go - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language