Showing 525 of 525 total issues

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

func (server *Server) handleGraphql(response http.ResponseWriter, request *http.Request, referential string) {
    foundReferential := server.CurrentReferentials().FindBySlug(core.ReferentialSlug(referential))
    if foundReferential == nil {
        http.Error(response, "Referential not found", http.StatusNotFound)
        return
Severity: Major
Found in api/server.go and 1 other location - About 1 hr to fix
api/server.go on lines 261..272

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 147.

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 (server *Server) handlePush(response http.ResponseWriter, request *http.Request, referential string) {
    foundReferential := server.CurrentReferentials().FindBySlug(core.ReferentialSlug(referential))
    if foundReferential == nil {
        http.Error(response, "Referential not found", http.StatusNotFound)
        return
Severity: Major
Found in api/server.go and 1 other location - About 1 hr to fix
api/server.go on lines 287..298

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 147.

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 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

      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 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

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

              for _, message := range response.GeneralMessages {
                  for _, affectedRef := range message.AffectedRefs {
                      switch affectedRef.Kind {
                      case "LineRef":
                          lineRefs[affectedRef.Id] = struct{}{}
          Severity: Major
          Found in core/general_message_broadcaster.go and 1 other location - About 1 hr to fix
          core/siri_general_message_request_broadcaster.go on lines 42..56

          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 146.

          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

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

              for _, message := range response.GeneralMessages {
                  for _, affectedRef := range message.AffectedRefs {
                      switch affectedRef.Kind {
                      case "LineRef":
                          lineRefs[affectedRef.Id] = struct{}{}
          Severity: Major
          Found in core/siri_general_message_request_broadcaster.go and 1 other location - About 1 hr to fix
          core/general_message_broadcaster.go on lines 166..180

          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 146.

          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 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 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

            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

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

              func (code *Code) UnmarshalJSON(data []byte) error {
                  var aux map[string]string
              
                  err := json.Unmarshal(data, &aux)
                  if err != nil {
              Severity: Major
              Found in model/code.go and 1 other location - About 1 hr to fix
              model/code.go on lines 94..116

              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 145.

              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 (schedules *StopVisitSchedules) SetDepartureTimeIfNotDefined(kind StopVisitScheduleType, departureTime time.Time) {
                  schedules.Lock()
                  defer schedules.Unlock()
              
                  _, ok := schedules.byType[kind]
              Severity: Major
              Found in model/stop_visit_schedule.go and 1 other location - About 1 hr to fix
              model/stop_visit_schedule.go on lines 208..219

              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 145.

              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 (schedules *StopVisitSchedules) SetArrivalTimeIfNotDefined(kind StopVisitScheduleType, arrivalTime time.Time) {
                  schedules.Lock()
                  defer schedules.Unlock()
              
                  _, ok := schedules.byType[kind]
              Severity: Major
              Found in model/stop_visit_schedule.go and 1 other location - About 1 hr to fix
              model/stop_visit_schedule.go on lines 185..196

              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 145.

              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 (objectId *ObjectId) UnmarshalJSON(data []byte) error {
                  var aux map[string]string
              
                  err := json.Unmarshal(data, &aux)
                  if err != nil {
              Severity: Major
              Found in model/code.go and 1 other location - About 1 hr to fix
              model/code.go on lines 118..140

              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 145.

              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 *SIRIVehicleMonitoringRequestCollector) broadcastUpdateEvents(events *VehicleMonitoringUpdateEvents) {
                  if connector.updateSubscriber == nil {
                      return
                  }
                  for _, e := range events.StopAreas {
              Severity: Major
              Found in core/siri_vehicle_monitoring_request_collector.go and 1 other location - About 1 hr to fix
              core/siri_vehicle_monitoring_subscription_collector.go on lines 153..169

              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 143.

              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 *SIRIVehicleMonitoringSubscriptionCollector) broadcastUpdateEvents(events *VehicleMonitoringUpdateEvents) {
                  if connector.updateSubscriber == nil {
                      return
                  }
                  for _, e := range events.StopAreas {
              Severity: Major
              Found in core/siri_vehicle_monitoring_subscription_collector.go and 1 other location - About 1 hr to fix
              core/siri_vehicle_monitoring_request_collector.go on lines 100..116

              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 143.

              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 6 locations. Consider refactoring.
              Open

              func (smb *StopMonitoringBroadcaster) run() {
                  c := smb.Clock().After(5 * time.Second)
              
                  for {
                      select {
              Severity: Major
              Found in core/stop_monitoring_broadcaster.go and 5 other locations - About 1 hr to fix
              core/estimated_timetable_broadcaster.go on lines 63..80
              core/general_message_broadcaster.go on lines 64..81
              core/production_timetable_broadcaster.go on lines 69..86
              core/situation_exchange_broadcaster.go on lines 64..81
              core/vehicle_monitoring_broadcaster.go on lines 70..87

              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 142.

              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 6 locations. Consider refactoring.
              Open

              func (gmb *GeneralMessageBroadcaster) run() {
                  c := gmb.Clock().After(5 * time.Second)
              
                  for {
                      select {
              Severity: Major
              Found in core/general_message_broadcaster.go and 5 other locations - About 1 hr to fix
              core/estimated_timetable_broadcaster.go on lines 63..80
              core/production_timetable_broadcaster.go on lines 69..86
              core/situation_exchange_broadcaster.go on lines 64..81
              core/stop_monitoring_broadcaster.go on lines 69..86
              core/vehicle_monitoring_broadcaster.go on lines 70..87

              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 142.

              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 6 locations. Consider refactoring.
              Open

              func (sxb *SituationExchangeBroadcaster) run() {
                  c := sxb.Clock().After(5 * time.Second)
              
                  for {
                      select {
              Severity: Major
              Found in core/situation_exchange_broadcaster.go and 5 other locations - About 1 hr to fix
              core/estimated_timetable_broadcaster.go on lines 63..80
              core/general_message_broadcaster.go on lines 64..81
              core/production_timetable_broadcaster.go on lines 69..86
              core/stop_monitoring_broadcaster.go on lines 69..86
              core/vehicle_monitoring_broadcaster.go on lines 70..87

              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 142.

              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

              Severity
              Category
              Status
              Source
              Language