Showing 146 of 546 total issues
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{
Method SIRIStopPointsDiscoveryRequestBroadcaster.StopAreas
has 67 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (connector *SIRIStopPointsDiscoveryRequestBroadcaster) StopAreas(request *sxml.XMLStopPointsDiscoveryRequest, message *audit.BigQueryMessage) (*siri.SIRIStopPointsDiscoveryResponse, error) {
response := &siri.SIRIStopPointsDiscoveryResponse{
Status: true,
ResponseTimestamp: connector.Clock().Now(),
}
Method Loader.handleStopArea
has 66 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (loader *Loader) handleStopArea(record []string) error {
if len(record) != 13 {
return fmt.Errorf("wrong number of entries, expected 13 got %v", len(record))
}
Method GMSubscriber.prepareSIRIGeneralMessageSubscriptionRequest
has 65 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (subscriber *GMSubscriber) prepareSIRIGeneralMessageSubscriptionRequest() {
collectSubscriber := NewCollectSubcriber(subscriber.connector, GeneralMessageCollect)
subscriptionRequests := collectSubscriber.GetSubscriptionRequest()
if len(subscriptionRequests) == 0 {
Method SIRIStopPointsDiscoveryRequestBroadcaster.StopAreas
has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring. Open
func (connector *SIRIStopPointsDiscoveryRequestBroadcaster) StopAreas(request *sxml.XMLStopPointsDiscoveryRequest, message *audit.BigQueryMessage) (*siri.SIRIStopPointsDiscoveryResponse, error) {
response := &siri.SIRIStopPointsDiscoveryResponse{
Status: true,
ResponseTimestamp: connector.Clock().Now(),
}
- 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 MemoryLines.Load
has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring. Open
func (manager *MemoryLines) Load(referentialSlug string) error {
var selectLines []SelectLine
modelName := manager.model.Date()
sqlQuery := fmt.Sprintf("select * from lines where referential_slug = '%s' and model_name = '%s'", referentialSlug, modelName.String())
_, err := Database.Select(&selectLines, 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 MemoryStopAreas.Load
has 63 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (manager *MemoryStopAreas) Load(referentialSlug string) error {
var selectStopAreas []SelectStopArea
modelName := manager.model.Date()
sqlQuery := fmt.Sprintf("select * from stop_areas where referential_slug = '%s' and model_name = '%s'", referentialSlug, modelName.String())
Method SXSubscriber.prepareSIRISituationExchangeSubscriptionRequest
has 62 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (subscriber *SXSubscriber) prepareSIRISituationExchangeSubscriptionRequest() {
collectSubscriber := NewCollectSubcriber(subscriber.connector, SituationExchangeCollect)
subscriptionRequests := collectSubscriber.GetSubscriptionRequest()
if len(subscriptionRequests) == 0 {
Method GMBroadcaster.prepareSIRIGeneralMessageNotify
has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring. Open
func (gmb *GMBroadcaster) prepareSIRIGeneralMessageNotify() {
gmb.connector.mutex.Lock()
events := gmb.connector.toBroadcast
gmb.connector.toBroadcast = make(map[SubscriptionId][]model.SituationId)
- 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 VehiclePositionBroadcaster.handleGtfs
has a Cognitive Complexity of 27 (exceeds 20 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)
- 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
Function AffectToProto
has 60 lines of code (exceeds 50 allowed). Consider refactoring. Open
func AffectToProto(a Affect, remoteCodeSpace string, m Model) ([]*gtfs.EntitySelector, *AffectRefs, error) {
collectedRefs := &AffectRefs{
MonitoringRefs: make(map[string]struct{}),
LineRefs: make(map[string]struct{}),
}
Method SIRISituationExchangeRequestBroadcaster.buildAffectedLine
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (connector *SIRISituationExchangeRequestBroadcaster) buildAffectedLine(affect model.Affect, 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())
Method StopVisitArchiver.Archive
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (sva *StopVisitArchiver) Archive() {
sv := sva.StopVisit
sa := sva.StopArea()
vj := sva.VehicleJourney()
longTermStopVisitEvent := &audit.BigQueryLongTermStopVisitEvent{
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())
Method SIRIStopMonitoringRequestCollector.RequestStopAreaUpdate
has 58 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (connector *SIRIStopMonitoringRequestCollector) RequestStopAreaUpdate(request *StopAreaUpdateRequest) {
stopArea, ok := connector.partner.Model().StopAreas().Find(request.StopAreaId())
if !ok {
logger.Log.Debugf("StopAreaUpdateRequest in StopMonitoringRequestCollector for unknown StopArea %v", request.StopAreaId())
return
Method SIRISubscriptionRequestDispatcher.CancelSubscription
has 58 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (connector *SIRISubscriptionRequestDispatcher) CancelSubscription(r *sxml.XMLDeleteSubscriptionRequest, message *audit.BigQueryMessage) *siri.SIRIDeleteSubscriptionResponse {
message.RequestIdentifier = r.MessageIdentifier()
currentTime := connector.Clock().Now()
resp := &siri.SIRIDeleteSubscriptionResponse{
Method Loader.Load
has 58 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (loader Loader) Load(reader io.Reader) Result {
// Config CSV reader
csvReader := csv.NewReader(reader)
csvReader.Comment = '#'
csvReader.FieldsPerRecord = -1
Method ETTSubscriber.prepareSIRIEstimatedTimetableSubscriptionRequest
has 58 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (subscriber *ETTSubscriber) prepareSIRIEstimatedTimetableSubscriptionRequest() {
collectSubscriber := NewCollectSubcriber(subscriber.connector, EstimatedTimetableCollect)
subscriptionRequests := collectSubscriber.GetSubscriptionRequest()
if len(subscriptionRequests) == 0 {
Method SIRISituationExchangeSubscriptionBroadcaster.HandleSubscriptionRequest
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (connector *SIRISituationExchangeSubscriptionBroadcaster) HandleSubscriptionRequest(request *sxml.XMLSubscriptionRequest, message *audit.BigQueryMessage) []siri.SIRIResponseStatus {
resps := []siri.SIRIResponseStatus{}
var subIds []string
Method SMSubscriber.prepareSIRIStopMonitoringSubscriptionRequest
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (subscriber *SMSubscriber) prepareSIRIStopMonitoringSubscriptionRequest() {
collectSubscriber := NewCollectSubcriber(subscriber.connector, StopMonitoringCollect)
subscriptionRequests := collectSubscriber.GetSubscriptionRequest()
if len(subscriptionRequests) == 0 {