Showing 134 of 525 total issues
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
}
File stop_visit.go
has 520 lines of code (exceeds 500 allowed). Consider refactoring. Open
package model
import (
"encoding/json"
"fmt"
Method BroadcastStopMonitoringBuilder.BuildMonitoredStopVisit
has 86 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (builder *BroadcastStopMonitoringBuilder) BuildMonitoredStopVisit(stopVisit *model.StopVisit) *siri.SIRIMonitoredStopVisit {
stopPointRef, stopPointRefCode, ok := builder.stopPointRef(stopVisit.StopAreaId)
if !ok {
logger.Log.Printf("Ignore StopVisit %v without StopArea or with StopArea without correct Code", stopVisit.Id())
return nil
Method TripUpdatesBroadcaster.handleGtfs
has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring. Open
func (connector *TripUpdatesBroadcaster) handleGtfs() (entities []*gtfs.FeedEntity, err error) {
stopVisits := connector.partner.Model().StopVisits().FindAllAfter(connector.Clock().Now().Add(PAST_STOP_VISITS_MAX_TIME))
linesCode := make(map[model.VehicleJourneyId]model.Code)
feedEntities := make(map[model.VehicleJourneyId]*gtfs.FeedEntity)
- Read upRead up
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 SMBroadcaster.prepareSIRIStopMonitoringNotify
has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring. Open
func (smb *SMBroadcaster) prepareSIRIStopMonitoringNotify() {
smb.connector.mutex.Lock()
events := smb.connector.toBroadcast
smb.connector.toBroadcast = make(map[SubscriptionId][]model.StopVisitId)
- Read upRead up
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
MemoryStopVisits
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
type MemoryStopVisits struct {
uuid.UUIDConsumer
clock.ClockConsumer
model Model
MemoryModel
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
type MemoryModel struct {
lines *MemoryLines
vehicles *MemoryVehicles
stopAreas *MemoryStopAreas
stopVisits *MemoryStopVisits
Method TripUpdatesBroadcaster.handleGtfs
has 83 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (connector *TripUpdatesBroadcaster) handleGtfs() (entities []*gtfs.FeedEntity, err error) {
stopVisits := connector.partner.Model().StopVisits().FindAllAfter(connector.Clock().Now().Add(PAST_STOP_VISITS_MAX_TIME))
linesCode := make(map[model.VehicleJourneyId]model.Code)
feedEntities := make(map[model.VehicleJourneyId]*gtfs.FeedEntity)
File load_from_csv.go
has 512 lines of code (exceeds 500 allowed). Consider refactoring. Open
package model
import (
"encoding/csv"
"fmt"
File stop_monitoring_response.go
has 508 lines of code (exceeds 500 allowed). Consider refactoring. Open
package sxml
import (
"time"
PartnerManager
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
type PartnerManager struct {
uuid.UUIDConsumer
mutex *sync.RWMutex
Method StopMonitoringUpdateEventBuilder.buildUpdateEvents
has 79 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (builder *StopMonitoringUpdateEventBuilder) buildUpdateEvents(xmlStopVisitEvent *sxml.XMLMonitoredStopVisit) {
origin := string(builder.partner.Slug())
// StopAreas
stopAreaCode := model.NewCode(builder.remoteCodeSpace, xmlStopVisitEvent.StopPointRef())
Method SituationExchangeUpdateEventBuilder.buildSituationExchangeUpdateEvent
has 76 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (builder *SituationExchangeUpdateEventBuilder) buildSituationExchangeUpdateEvent(event *[]*model.SituationUpdateEvent, xmlSituation *sxml.XMLPtSituationElement, producerRef string) {
if len(xmlSituation.Affects()) == 0 {
return
}
Function deepValueEqual
has 22 return statements (exceeds 4 allowed). Open
func deepValueEqual(v1, v2 reflect.Value, visited map[visit]bool) bool {
if !v1.IsValid() || !v2.IsValid() {
return v1.IsValid() == v2.IsValid()
}
if v1.Type() != v2.Type() {
Method SIRILiteVehicleMonitoringRequestBroadcaster.RequestVehicles
has 75 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (connector *SIRILiteVehicleMonitoringRequestBroadcaster) RequestVehicles(url string, filters url.Values, message *audit.BigQueryMessage) (siriLiteResponse *siri.SiriLiteResponse) {
lineRef := filters.Get("LineRef")
message.RequestIdentifier = filters.Get("MessageIdentifier")
message.Lines = []string{lineRef}
Method UpdateManager.updateStopVisit
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. Open
func (manager *UpdateManager) updateStopVisit(event *StopVisitUpdateEvent) {
if event.Code.Value() == "" { // Avoid creating a StopVisit with an empty code
return
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method MemoryVehicleJourneys.Load
has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring. Open
func (manager *MemoryVehicleJourneys) Load(referentialSlug string) error {
var selectVehicleJourneys []SelectVehicleJourney
modelName := manager.model.Date()
sqlQuery := fmt.Sprintf("select * from vehicle_journeys where referential_slug = '%s' and model_name = '%s'", referentialSlug, modelName.String())
_, err := Database.Select(&selectVehicleJourneys, sqlQuery)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method VehicleMonitoringUpdateEventBuilder.buildUpdateEvents
has 71 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (builder *VehicleMonitoringUpdateEventBuilder) buildUpdateEvents(xmlVehicleActivity *sxml.XMLVehicleActivity) {
origin := string(builder.partner.Slug())
// StopAreas
stopAreaCode := model.NewCode(builder.remoteCodeSpace, xmlVehicleActivity.StopPointRef())
Method VehiclePositionBroadcaster.handleGtfs
has 70 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (connector *VehiclePositionBroadcaster) handleGtfs() (entities []*gtfs.FeedEntity, err error) {
vehicles := connector.partner.Model().Vehicles().FindAll()
linesCode := make(map[model.VehicleJourneyId]model.Code)
trips := make(map[model.VehicleJourneyId]*gtfs.TripDescriptor)
Method SIRIStopMonitoringRequestBroadcaster.getStopMonitoringDelivery
has 68 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (connector *SIRIStopMonitoringRequestBroadcaster) getStopMonitoringDelivery(request *sxml.XMLStopMonitoringRequest) siri.SIRIStopMonitoringDelivery {
code := model.NewCode(connector.remoteCodeSpace, request.MonitoringRef())
stopArea, ok := connector.partner.Model().StopAreas().FindByCode(code)
if !ok {
return siri.SIRIStopMonitoringDelivery{