core/broadcast_situation_exchange_builder.go

Summary

Maintainability
F
4 days
Test Coverage

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

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

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

      Method BroadcastSituationExchangeBuilder.canBroadcast has 5 return statements (exceeds 4 allowed).
      Open

      func (builder *BroadcastSituationExchangeBuilder) canBroadcast(situation model.Situation) bool {
          if situation.Origin == string(builder.partner.Slug()) {
              return false
          }
      
      
      Severity: Major
      Found in core/broadcast_situation_exchange_builder.go - About 35 mins to fix

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

        func (builder *BroadcastSituationExchangeBuilder) buildAffectedLine(affect model.Affect, delivery *siri.SIRISituationExchangeDelivery) (*siri.AffectedLine, bool) {
            affect, _ = affect.(*model.AffectedLine)
            line, ok := builder.partner.Model().Lines().Find(model.LineId(affect.GetId()))
            if !ok {
                logger.Log.Debugf("Unknown Line %s", affect.GetId())
        Severity: Major
        Found in core/broadcast_situation_exchange_builder.go and 1 other location - About 1 day to fix
        core/siri_situation_exchange_request_broadcaster.go on lines 272..338

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

        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 *BroadcastSituationExchangeBuilder) buildActionCommon(actionCommon model.ActionCommon, siriActionCommon *siri.SIRIPublishActionCommon, delivery *siri.SIRISituationExchangeDelivery) {
            siriActionCommon.Name = actionCommon.Name
            siriActionCommon.ActionType = actionCommon.ActionType
            siriActionCommon.Value = actionCommon.Value
            siriActionCommon.ScopeType = actionCommon.ScopeType
        Severity: Major
        Found in core/broadcast_situation_exchange_builder.go and 1 other location - About 4 hrs to fix
        core/siri_situation_exchange_request_broadcaster.go on lines 188..221

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

        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 *BroadcastSituationExchangeBuilder) buildAffectedStopArea(affect model.Affect, delivery *siri.SIRISituationExchangeDelivery) (*siri.AffectedStopPoint, bool) {
            affect, _ = affect.(*model.AffectedStopArea)
        
            affectedStopAreaRef, ok := builder.resolveStopAreaRef(model.StopAreaId(affect.GetId()))
            if !ok {
        Severity: Major
        Found in core/broadcast_situation_exchange_builder.go and 1 other location - About 4 hrs to fix
        core/siri_situation_exchange_request_broadcaster.go on lines 242..270

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

        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 *BroadcastSituationExchangeBuilder) canBroadcast(situation model.Situation) bool {
            if situation.Origin == string(builder.partner.Slug()) {
                return false
            }
        
        
        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 352..373

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

        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 *BroadcastSituationExchangeBuilder) buildAffects(affects model.Affects, siriAffects *siri.SIRIAffects, delivery *siri.SIRISituationExchangeDelivery) {
            for _, affect := range affects {
                switch affect.GetType() {
                case model.SituationTypeStopArea:
                    affectedStopArea, ok := builder.buildAffectedStopArea(affect, delivery)
        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 223..240

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

        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

            for _, consequence := range situation.Consequences {
                c := &siri.Consequence{
                    Periods:   consequence.Periods,
                    Severity:  consequence.Severity,
                    Condition: consequence.Condition,
        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 128..145

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

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

        func (builder *BroadcastSituationExchangeBuilder) resolveStopAreaRef(stopAreaId model.StopAreaId) (string, bool) {
            stopArea, ok := builder.partner.Model().StopAreas().Find(stopAreaId)
            if !ok {
                return "", false
            }
        Severity: Major
        Found in core/broadcast_situation_exchange_builder.go and 2 other locations - About 50 mins to fix
        core/broadcast_general_message_builder.go on lines 258..268
        core/siri_situation_exchange_request_broadcaster.go on lines 340..350

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

        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

            for _, publishToWebAction := range situation.PublishToWebActions {
                wa := &siri.PublishToWebAction{}
        
                wa.Incidents = publishToWebAction.Incidents
                wa.HomePage = publishToWebAction.HomePage
        Severity: Minor
        Found in core/broadcast_situation_exchange_builder.go and 1 other location - About 45 mins to fix
        core/siri_situation_exchange_request_broadcaster.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 116.

        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

            if present {
                situationNumber = code.Value()
            } else {
                code, present = situation.Code(model.Default)
                if !present {
        Severity: Minor
        Found in core/broadcast_situation_exchange_builder.go and 2 other locations - About 40 mins to fix
        core/gtfs_rt_service_alerts_broadcaster.go on lines 60..69
        core/siri_situation_exchange_request_broadcaster.go on lines 77..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 109.

        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

        There are no issues that match your filters.

        Category
        Status