Showing 525 of 525 total issues

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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func (connector *SIRIStopMonitoringSubscriptionCollector) broadcastUpdateEvents(events *CollectUpdateEvents) {
          if connector.updateSubscriber == nil {
              return
          }
          for _, e := range events.StopAreas {
      Severity: Major
      Found in core/siri_stop_monitoring_subscription_collector.go and 1 other location - About 1 hr to fix
      core/gtfs_rt_request_collector.go on lines 242..263

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 178.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func (connector *GtfsRequestCollector) broadcastUpdateEvents(events *CollectUpdateEvents) {
          if connector.subscriber == nil {
              return
          }
          for _, e := range events.StopAreas {
      Severity: Major
      Found in core/gtfs_rt_request_collector.go and 1 other location - About 1 hr to fix
      core/siri_stop_monitoring_subscription_collector.go on lines 160..181

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 178.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        func (vm *VMBroadcaster) sendDelivery(delivery *siri.SIRINotifyVehicleMonitoring) {
            message := vm.newBQEvent()
        
            vm.logSIRIVehicleMonitoring(message, delivery)
        
        
        Severity: Major
        Found in core/vehicle_monitoring_broadcaster.go and 1 other location - About 1 hr to fix
        core/estimated_timetable_broadcaster.go on lines 426..437

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 173.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        func (ett *ETTBroadcaster) sendDelivery(delivery *siri.SIRINotifyEstimatedTimetable) {
            message := ett.newBQEvent()
        
            ett.logSIRIEstimatedTimetableNotify(message, delivery)
        
        
        Severity: Major
        Found in core/estimated_timetable_broadcaster.go and 1 other location - About 1 hr to fix
        core/vehicle_monitoring_broadcaster.go on lines 296..307

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 173.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        package core
        
        import (
            "time"
        
        
        Severity: Major
        Found in core/stop_area_update_request.go and 2 other locations - About 1 hr to fix
        core/line_update_request.go on lines 1..28
        core/vehicle_update_request.go on lines 1..28

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 172.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        package core
        
        import (
            "time"
        
        
        Severity: Major
        Found in core/vehicle_update_request.go and 2 other locations - About 1 hr to fix
        core/line_update_request.go on lines 1..28
        core/stop_area_update_request.go on lines 1..28

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 172.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        package core
        
        import (
            "time"
        
        
        Severity: Major
        Found in core/line_update_request.go and 2 other locations - About 1 hr to fix
        core/stop_area_update_request.go on lines 1..28
        core/vehicle_update_request.go on lines 1..28

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 172.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              if aux.Affects != nil {
                  for _, v := range aux.Affects {
                      var affectedSubtype = struct {
                          Type SituationType
                      }{}
          Severity: Major
          Found in model/situation.go and 1 other location - About 1 hr to fix
          model/situation.go on lines 209..229

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 168.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              if aux.Affects != nil {
                  for _, v := range aux.Affects {
                      var affectedSubtype = struct {
                          Type SituationType
                      }{}
          Severity: Major
          Found in model/situation.go and 1 other location - About 1 hr to fix
          model/situation.go on lines 170..190

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 168.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          func (builder *SituationExchangeUpdateEventBuilder) buildAffectedLine(lineRef string, affectedLines map[model.LineId]*model.AffectedLine) {
              LineRefCode := model.NewCode(builder.remoteCodeSpace, lineRef)
              line, ok := builder.partner.Model().Lines().FindByCode(LineRefCode)
              if !ok {
                  return
          Severity: Major
          Found in core/situation_exchange_update_event_builder.go and 1 other location - About 1 hr to fix
          core/general_message_update_event_builder.go on lines 147..157

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 164.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          func (builder *GeneralMessageUpdateEventBuilder) setAffectedLine(lineRef string, affectedLines map[model.LineId]*model.AffectedLine) {
              LineRefCode := model.NewCode(builder.remoteCodeSpace, lineRef)
              line, ok := builder.partner.Model().Lines().FindByCode(LineRefCode)
              if !ok {
                  return
          Severity: Major
          Found in core/general_message_update_event_builder.go and 1 other location - About 1 hr to fix
          core/situation_exchange_update_event_builder.go on lines 212..222

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 164.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          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 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
              Severity
              Category
              Status
              Source
              Language