core/siri_situation_exchange_request_broadcaster.go

Summary

Maintainability
F
3 days
Test Coverage

Method SIRISituationExchangeRequestBroadcaster.buildSituation has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring.
Open

func (connector *SIRISituationExchangeRequestBroadcaster) buildSituation(delivery *siri.SIRISituationExchangeDelivery, situation model.Situation) {
    if !connector.canBroadcast(situation) {
        return
    }

Severity: Minor
Found in core/siri_situation_exchange_request_broadcaster.go - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method SIRISituationExchangeRequestBroadcaster.buildSituation has 87 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (connector *SIRISituationExchangeRequestBroadcaster) buildSituation(delivery *siri.SIRISituationExchangeDelivery, situation model.Situation) {
    if !connector.canBroadcast(situation) {
        return
    }

Severity: Major
Found in core/siri_situation_exchange_request_broadcaster.go - About 2 hrs to fix

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

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

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

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

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

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

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

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

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

        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,
                }
        Severity: Major
        Found in core/siri_situation_exchange_request_broadcaster.go and 1 other location - About 3 hrs to fix
        core/broadcast_situation_exchange_builder.go on lines 106..134

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

        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 *SIRISituationExchangeRequestBroadcaster) canBroadcast(situation model.Situation) bool {
            if situation.Origin == string(connector.partner.Slug()) {
                return false
            }
        
        
        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 253..274

        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

            for _, affect := range situation.Affects {
                switch affect.GetType() {
                case model.SituationTypeStopArea:
                    affectedStopArea, ok := connector.buildAffectedStopArea(affect, ptSituationElement, delivery)
                    if ok {
        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 82..104

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

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

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

        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

        There are no issues that match your filters.

        Category
        Status