Showing 146 of 546 total issues
Method LiteStopMonitoringUpdateEventBuilder.buildUpdateEvents
has 87 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (builder *LiteStopMonitoringUpdateEventBuilder) buildUpdateEvents(StopVisitEvent *slite.MonitoredStopVisit) {
// When Order is not defined, we should ignore the MonitoredStopVisit
// see ARA-1240 "Special cases"
if !StopVisitEvent.HasOrder() {
return
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 SituationExchangeUpdateEventBuilder.buildSituationExchangeUpdateEvent
has 86 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (builder *SituationExchangeUpdateEventBuilder) buildSituationExchangeUpdateEvent(event *CollectUpdateEvents, xmlSituation *sxml.XMLPtSituationElement, producerRef string) {
if len(xmlSituation.Affects()) == 0 {
return
}
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
MemoryStopVisits
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
type MemoryStopVisits struct {
uuid.UUIDConsumer
clock.ClockConsumer
model Model
Method GtfsRequestCollector.handleAlert
has 83 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (connector *GtfsRequestCollector) handleAlert(events *CollectUpdateEvents, a *gtfs.Alert, id string, timestamp uint64) {
entities := a.GetInformedEntity()
if len(entities) == 0 {
logger.Log.Debugf("%d affects for this Alert, skipping message", len(entities))
return
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"
Method UpdateManager.updateStopVisit
has a Cognitive Complexity of 32 (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
File stop_monitoring_response.go
has 509 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 ServiceAlertsBroadcaster.handleGtfs
has 78 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (connector *ServiceAlertsBroadcaster) handleGtfs() (entities []*gtfs.FeedEntity, err error) {
situations := connector.partner.Model().Situations().FindAll()
for _, situation := range situations {
if !connector.canBroadcast(situation) {
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 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 BroadcastGeneralMessageBuilder.BuildGeneralMessage
has 72 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (builder *BroadcastGeneralMessageBuilder) BuildGeneralMessage(situation model.Situation) *siri.SIRIGeneralMessage {
if !builder.canBroadcast(situation) {
return nil
}
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 SIRIVehicleMonitoringRequestBroadcaster.buildVehicleActivity
has 71 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (connector *SIRIVehicleMonitoringRequestBroadcaster) buildVehicleActivity(delivery *siri.SIRIVehicleMonitoringDelivery, line *model.Line, lineRef string, vehicle *model.Vehicle) {
vehicleId, ok := vehicle.CodeWithFallback(connector.vehicleRemoteCodeSpaces)
if !ok {
return
}
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 GtfsHandler.serve
has 69 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (handler *GtfsHandler) serve(response http.ResponseWriter, request *http.Request, resource string) {
// Find Partner by authorization Key
partner, ok := handler.referential.Partners().FindByCredential(handler.token)
if !ok {
http.Error(response, "Invalid Authorization Token", http.StatusUnauthorized)