Showing 146 of 546 total issues

Function main has a Cognitive Complexity of 45 (exceeds 20 allowed). Consider refactoring.
Open

func main() {
    cpuProfile := flag.String("cpuprofile", "", "Write cpu profile to file")
    memProfile := flag.String("memprofile", "", "Write memory profile to this file")

    uuidPtr := flag.Bool("testuuid", false, "Use the test uuid generator")
Severity: Minor
Found in ara.go - About 4 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 VMBroadcaster.prepareSIRIVehicleMonitoring has 128 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (vm *VMBroadcaster) prepareSIRIVehicleMonitoring() {
    vm.connector.mutex.Lock()
    defer vm.connector.mutex.Unlock()

    events := vm.connector.toBroadcast
Severity: Major
Found in core/vehicle_monitoring_broadcaster.go - About 4 hrs to fix

    Method MemoryStopAreas.Load has a Cognitive Complexity of 43 (exceeds 20 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 4 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 ETTBroadcaster.prepareSIRIEstimatedTimetable has 119 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (ett *ETTBroadcaster) prepareSIRIEstimatedTimetable() {
        ett.connector.mutex.Lock()
    
        events := ett.connector.toBroadcast
        ett.connector.toBroadcast = make(map[SubscriptionId][]model.StopVisitId)
    Severity: Major
    Found in core/estimated_timetable_broadcaster.go - About 3 hrs to fix

      Method SIRIEstimatedTimetableRequestBroadcaster.getEstimatedTimetableDelivery has 118 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (connector *SIRIEstimatedTimetableRequestBroadcaster) getEstimatedTimetableDelivery(request *sxml.XMLEstimatedTimetableRequest) siri.SIRIEstimatedTimetableDelivery {
          currentTime := connector.Clock().Now()
      
          delivery := siri.SIRIEstimatedTimetableDelivery{
              RequestMessageRef:  request.MessageIdentifier(),
      Severity: Major
      Found in core/siri_estimated_timetable_request_broadcaster.go - About 3 hrs to fix

        Method ServiceAlertsBroadcaster.handleGtfs has a Cognitive Complexity of 39 (exceeds 20 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: Minor
        Found in core/gtfs_rt_service_alerts_broadcaster.go - About 3 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 SIRIHandler.serve has 108 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (handler *SIRIHandler) serve(response http.ResponseWriter, request *http.Request) {
            response.Header().Set("Content-Type", "text/xml; charset=utf-8")
        
            m := &audit.BigQueryMessage{
                Protocol:    "siri",
        Severity: Major
        Found in api/siri_handler.go - About 3 hrs to fix

          Method PTTBroadcaster.prepareSIRIProductionTimetable has 107 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (ptt *PTTBroadcaster) prepareSIRIProductionTimetable() {
              ptt.connector.mutex.Lock()
          
              events := ptt.connector.toBroadcast
              ptt.connector.toBroadcast = make(map[SubscriptionId][]model.StopVisitId)
          Severity: Major
          Found in core/production_timetable_broadcaster.go - About 3 hrs to fix

            Method UpdateManager.updateStopVisit has 103 lines of code (exceeds 50 allowed). Consider refactoring.
            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 3 hrs to fix

              Method SituationCondition.FromString has 99 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (condition *SituationCondition) FromString(c string) error {
                  switch SituationCondition(c) {
                  case SituationConditionAdditionalRide:
                      fallthrough
                  case SituationConditionAdditionalService:
              Severity: Major
              Found in model/situation_attributes.go - About 2 hrs to fix

                Method SIRILiteVehicleMonitoringRequestBroadcaster.RequestVehicles has 98 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: Major
                Found in core/siri_lite_vehicle_monitoring_request_broadcaster.go - About 2 hrs to fix

                  Method MemoryStopVisits.Load has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
                  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: Minor
                  Found in model/stop_visit.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

                  Function deepValueEqual has 93 lines of code (exceeds 50 allowed). Consider refactoring.
                  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 SIRIHandler.requestHandler has 93 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (handler *SIRIHandler) requestHandler(envelope *remote.SIRIEnvelope) SIRIRequestHandler {
                        switch envelope.BodyType() {
                        case "CheckStatus":
                            return &SIRICheckStatusRequestHandler{
                                xmlRequest:  sxml.NewXMLCheckStatusRequest(envelope.Body()),
                    Severity: Major
                    Found in api/siri_handler.go - About 2 hrs to fix

                      Function NewConnectorFactory has 92 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func NewConnectorFactory(connectorType string) ConnectorFactory {
                          switch connectorType {
                          case GRAPHQL_SERVER:
                              return &GraphqlServerFactory{}
                          case PUSH_COLLECTOR:
                      Severity: Major
                      Found in core/connector.go - About 2 hrs to fix

                        MemoryModel has 24 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 SIRISituationExchangeRequestBroadcaster.buildSituation has 91 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

                            Method BroadcastSituationExchangeBuilder.BuildSituationExchange has 91 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func (builder *BroadcastSituationExchangeBuilder) BuildSituationExchange(situation model.Situation, delivery *siri.SIRISituationExchangeDelivery) {
                                if !builder.canBroadcast(situation) {
                                    return
                                }
                            
                            
                            Severity: Major
                            Found in core/broadcast_situation_exchange_builder.go - About 2 hrs to fix

                              File stop_visit.go has 521 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

                                SIRIClient has 23 methods (exceeds 20 allowed). Consider refactoring.
                                Open

                                type SIRIClient struct {
                                    httpClient       *HTTPClient
                                    siriEnvelopeType string
                                }
                                Severity: Minor
                                Found in remote/siri_client.go - About 2 hrs to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language