Showing 134 of 525 total issues

Method Loader.handleStopArea has 66 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (loader *Loader) handleStopArea(record []string) error {
    if len(record) != 13 {
        return fmt.Errorf("wrong number of entries, expected 13 got %v", len(record))
    }

Severity: Minor
Found in model/load_from_csv.go - About 1 hr to fix

    Method MemoryLines.Load has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
    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: Minor
    Found in model/lines.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 GtfsHandler.serve has 64 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

      Method BroadcastGeneralMessageBuilder.BuildGeneralMessage has 64 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 MemoryStopAreas.Load has 63 lines of code (exceeds 50 allowed). Consider refactoring.
        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: Minor
        Found in model/stop_area.go - About 1 hr to fix

          Method VehiclePositionBroadcaster.handleGtfs has a Cognitive Complexity of 27 (exceeds 20 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

          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 SIRISituationExchangeRequestBroadcaster.buildAffectedLine has 59 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (connector *SIRISituationExchangeRequestBroadcaster) buildAffectedLine(affect model.Affect, ptSituationElement *siri.SIRIPtSituationElement, delivery *siri.SIRISituationExchangeDelivery) (*siri.AffectedLine, bool) {
              affect, _ = affect.(*model.AffectedLine)
              line, ok := connector.partner.Model().Lines().Find(model.LineId(affect.GetId()))
              if !ok {
                  logger.Log.Debugf("Unknown Line %s", affect.GetId())
          Severity: Minor
          Found in core/siri_situation_exchange_request_broadcaster.go - About 1 hr to fix

            Method StopVisitArchiver.Archive has 59 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (sva *StopVisitArchiver) Archive() {
                sv := sva.StopVisit
                sa := sva.StopArea()
                vj := sva.VehicleJourney()
                longTermStopVisitEvent := &audit.BigQueryLongTermStopVisitEvent{
            Severity: Minor
            Found in model/stop_visit_archiver.go - About 1 hr to fix

              Method BroadcastSituationExchangeBuilder.buildAffectedLine has 59 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (builder *BroadcastSituationExchangeBuilder) buildAffectedLine(affect model.Affect, ptSituationElement *siri.SIRIPtSituationElement, delivery *siri.SIRISituationExchangeDelivery) (*siri.AffectedLine, bool) {
                  affect, _ = affect.(*model.AffectedLine)
                  line, ok := builder.partner.Model().Lines().Find(model.LineId(affect.GetId()))
                  if !ok {
                      logger.Log.Debugf("Unknown Line %s", affect.GetId())
              Severity: Minor
              Found in core/broadcast_situation_exchange_builder.go - About 1 hr to fix

                Method Loader.Load has 58 lines of code (exceeds 50 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 1 hr to fix

                  Method SIRIStopMonitoringRequestCollector.RequestStopAreaUpdate has 58 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (connector *SIRIStopMonitoringRequestCollector) RequestStopAreaUpdate(request *StopAreaUpdateRequest) {
                      stopArea, ok := connector.partner.Model().StopAreas().Find(request.StopAreaId())
                      if !ok {
                          logger.Log.Debugf("StopAreaUpdateRequest in StopMonitoringRequestCollector for unknown StopArea %v", request.StopAreaId())
                          return
                  Severity: Minor
                  Found in core/siri_stop_monitoring_request_collector.go - About 1 hr to fix

                    Method SIRISubscriptionRequestDispatcher.CancelSubscription has 58 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (connector *SIRISubscriptionRequestDispatcher) CancelSubscription(r *sxml.XMLDeleteSubscriptionRequest, message *audit.BigQueryMessage) *siri.SIRIDeleteSubscriptionResponse {
                        message.RequestIdentifier = r.MessageIdentifier()
                    
                        currentTime := connector.Clock().Now()
                        resp := &siri.SIRIDeleteSubscriptionResponse{
                    Severity: Minor
                    Found in core/siri_subscription_request_dispatcher.go - About 1 hr to fix

                      Method PushHandler.serve has 57 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (handler *PushHandler) serve(response http.ResponseWriter, request *http.Request) {
                          // Check if request header is protobuf or return an error
                          if request.Header.Get("Content-Type") != "application/x-protobuf" {
                              http.Error(response, "Expected application/x-protobuf content", http.StatusUnsupportedMediaType)
                              return
                      Severity: Minor
                      Found in api/push_handler.go - About 1 hr to fix

                        Method SIRISubscriptionRequestDispatcher.Dispatch has 57 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (connector *SIRISubscriptionRequestDispatcher) Dispatch(request *sxml.XMLSubscriptionRequest, message *audit.BigQueryMessage) (*siri.SIRISubscriptionResponse, error) {
                            response := siri.SIRISubscriptionResponse{
                                Address:            connector.Partner().Address(),
                                ResponderRef:       connector.Partner().RequestorRef(),
                                ResponseTimestamp:  connector.Clock().Now(),
                        Severity: Minor
                        Found in core/siri_subscription_request_dispatcher.go - About 1 hr to fix

                          Method SIRISituationExchangeSubscriptionBroadcaster.HandleSubscriptionRequest has 57 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (connector *SIRISituationExchangeSubscriptionBroadcaster) HandleSubscriptionRequest(request *sxml.XMLSubscriptionRequest, message *audit.BigQueryMessage) []siri.SIRIResponseStatus {
                              resps := []siri.SIRIResponseStatus{}
                          
                              var subIds []string
                          
                          
                          Severity: Minor
                          Found in core/siri_situation_exchange_subscription_broadcaster.go - About 1 hr to fix

                            Method SIRIStopMonitoringSubscriptionBroadcaster.HandleSubscriptionRequest has 57 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func (connector *SIRIStopMonitoringSubscriptionBroadcaster) HandleSubscriptionRequest(request *sxml.XMLSubscriptionRequest, message *audit.BigQueryMessage) (resps []siri.SIRIResponseStatus) {
                                var monitoringRefs, subIds []string
                            
                                for _, sm := range request.XMLSubscriptionSMEntries() {
                                    rs := siri.SIRIResponseStatus{
                            Severity: Minor
                            Found in core/siri_stop_monitoring_subscription_broadcaster.go - About 1 hr to fix

                              Function NewSIRICheckStatusResponse has 10 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  address string,
                                  producerRef string,
                                  requestMessageRef string,
                                  responseMessageIdentifier string,
                                  status bool,
                              Severity: Major
                              Found in siri/siri/check_status_response.go - About 1 hr to fix

                                Method CollectManager.UpdateStopArea has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                                Open

                                func (manager *CollectManager) UpdateStopArea(request *StopAreaUpdateRequest) {
                                    stopArea, ok := manager.referential.Model().StopAreas().Find(request.StopAreaId())
                                    localLogger := NewStopAreaLogger(manager.referential, stopArea)
                                
                                    if !ok {
                                Severity: Minor
                                Found in core/collect_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 SIRISubscriptionRequestDispatcher.Dispatch has 13 return statements (exceeds 4 allowed).
                                Open

                                func (connector *SIRISubscriptionRequestDispatcher) Dispatch(request *sxml.XMLSubscriptionRequest, message *audit.BigQueryMessage) (*siri.SIRISubscriptionResponse, error) {
                                    response := siri.SIRISubscriptionResponse{
                                        Address:            connector.Partner().Address(),
                                        ResponderRef:       connector.Partner().RequestorRef(),
                                        ResponseTimestamp:  connector.Clock().Now(),
                                Severity: Major
                                Found in core/siri_subscription_request_dispatcher.go - About 1 hr to fix

                                  Method SMBroadcaster.prepareSIRIStopMonitoringNotify has 54 lines of code (exceeds 50 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 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language