Showing 525 of 525 total issues

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

func (ett *SIRIEstimatedTimetableBroadcaster) run() {
    c := ett.Clock().After(5 * time.Second)

    for {
        select {
Severity: Major
Found in core/estimated_timetable_broadcaster.go and 5 other locations - About 1 hr to fix
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/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 (ptt *ProductionTimetableBroadcaster) run() {
    c := ptt.Clock().After(5 * time.Second)

    for {
        select {
Severity: Major
Found in core/production_timetable_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/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 (vm *SIRIVehicleMonitoringBroadcaster) run() {
    c := vm.Clock().After(5 * time.Second)

    for {
        select {
Severity: Major
Found in core/vehicle_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/stop_monitoring_broadcaster.go on lines 69..86

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

func (controller *PartnerController) Save(response http.ResponseWriter) {
    logger.Log.Debugf("Saving partners to database")

    status, err := controller.referential.Partners().SaveToDatabase()

Severity: Major
Found in api/partner_controller.go and 1 other location - About 1 hr to fix
api/referential_controller.go on lines 132..144

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

func (controller *ReferentialController) Save(response http.ResponseWriter) {
    logger.Log.Debugf("Saving referentials to database")

    status, err := controller.server.CurrentReferentials().SaveToDatabase()

Severity: Major
Found in api/referential_controller.go and 1 other location - About 1 hr to fix
api/partner_controller.go on lines 236..248

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

func (partner *APIPartner) UnmarshalJSON(data []byte) error {
    type Alias APIPartner
    aux := &struct {
        Settings map[string]string
        *Alias
Severity: Major
Found in core/api_partner.go and 1 other location - About 1 hr to fix
core/referential.go on lines 78..96

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

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 (apiReferential *APIReferential) UnmarshalJSON(data []byte) error {
    type Alias APIReferential
    aux := &struct {
        Settings map[string]string
        *Alias
Severity: Major
Found in core/referential.go and 1 other location - About 1 hr to fix
core/api_partner.go on lines 117..135

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

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

    Method SIRIProductionTimetableSubscriptionBroadcaster.HandleSubscriptionRequest has 53 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

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

      Method CollectManager.UpdateStopArea has 53 lines of code (exceeds 50 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

        Method SIRIVehicleMonitoringSubscriptionBroadcaster.HandleSubscriptionRequest has 53 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

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

          Method SIRIEstimatedTimetableSubscriptionBroadcaster.HandleSubscriptionRequest has 53 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

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

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

            func (schedules *StopVisitSchedules) ArrivalTimeFromKind(kinds []StopVisitScheduleType) time.Time {
                if kinds == nil {
                    kinds = []StopVisitScheduleType{"actual", "expected", "aimed"}
                }
                schedules.RLock()
            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 260..273

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

            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) DepartureTimeFromKind(kinds []StopVisitScheduleType) time.Time {
                if kinds == nil {
                    kinds = []StopVisitScheduleType{"actual", "expected", "aimed"}
                }
                schedules.RLock()
            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 245..258

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

            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

                ptSituationElement := &siri.SIRIPtSituationElement{
                    SituationNumber:    situationNumber,
                    CreationTime:       situation.RecordedAt,
                    Version:            situation.Version,
                    ValidityPeriods:    situation.ValidityPeriods,
            Severity: Major
            Found in core/broadcast_situation_exchange_builder.go and 1 other location - About 1 hr to fix
            core/siri_situation_exchange_request_broadcaster.go on lines 88..102

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

            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 (ar *XMLAffectedRoute) AffectedStopPoints() []*XMLAffectedStopPoint {
                if len(ar.affectedStopPoints) == 0 {
                    stopPointsNodes := ar.findDirectChildrenNodes("StopPoints")
                    if stopPointsNodes != nil {
                        xmlStopPoints := NewXMLAffectedStopPoint(stopPointsNodes[0])
            Severity: Major
            Found in siri/sxml/situation_exchange_reponse.go and 1 other location - About 1 hr to fix
            siri/sxml/situation_exchange_reponse.go on lines 512..525

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

            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

                ptSituationElement := &siri.SIRIPtSituationElement{
                    SituationNumber:    situationNumber,
                    CreationTime:       situation.RecordedAt,
                    Version:            situation.Version,
                    ValidityPeriods:    situation.ValidityPeriods,
            Severity: Major
            Found in core/siri_situation_exchange_request_broadcaster.go and 1 other location - About 1 hr to fix
            core/broadcast_situation_exchange_builder.go on lines 52..66

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

            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 (a *XMLAffect) AffectedStopPoints() []*XMLAffectedStopPoint {
                if len(a.affectedStopPoints) == 0 {
                    stopPointsNodes := a.findDirectChildrenNodes("StopPoints")
                    if stopPointsNodes != nil {
                        xmlStopPoints := NewXMLAffectedStopPoint(stopPointsNodes[0])
            Severity: Major
            Found in siri/sxml/situation_exchange_reponse.go and 1 other location - About 1 hr to fix
            siri/sxml/situation_exchange_reponse.go on lines 463..476

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

            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 CollectManager.requestStopAreaFilteredSituation has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
            Open

            func (manager *CollectManager) requestStopAreaFilteredSituation(requestedId string) {
                stopArea, ok := manager.referential.Model().StopAreas().Find(model.StopAreaId(requestedId))
                if !ok {
                    logger.Log.Debugf("Can't find StopArea to request %v", requestedId)
                    return
            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 GMSubscriber.prepareSIRIGeneralMessageSubscriptionRequest has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
            Open

            func (subscriber *GMSubscriber) prepareSIRIGeneralMessageSubscriptionRequest() {
                subscriptions := subscriber.connector.partner.Subscriptions().FindSubscriptionsByKind(GeneralMessageCollect)
                if len(subscriptions) == 0 {
                    logger.Log.Debugf("GeneralMessageSubscriber visit without GeneralMessageCollect subscriptions")
                    return
            Severity: Minor
            Found in core/siri_general_message_subscriber.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

            Severity
            Category
            Status
            Source
            Language