Showing 134 of 525 total issues
Method CollectManager.UpdateStopArea
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (manager *CollectManager) UpdateStopArea(request *StopAreaUpdateRequest) {
stopArea, ok := manager.referential.Model().StopAreas().Find(request.StopAreaId())
localLogger := NewStopAreaLogger(manager.referential, stopArea)
if !ok {
Method SIRIVehicleMonitoringSubscriptionBroadcaster.HandleSubscriptionRequest
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (connector *SIRIVehicleMonitoringSubscriptionBroadcaster) HandleSubscriptionRequest(request *sxml.XMLSubscriptionRequest, message *audit.BigQueryMessage) (resps []siri.SIRIResponseStatus) {
var lineIds, subIds []string
for _, vm := range request.XMLSubscriptionVMEntries() {
rs := siri.SIRIResponseStatus{
Method SIRIEstimatedTimetableSubscriptionBroadcaster.HandleSubscriptionRequest
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (connector *SIRIEstimatedTimetableSubscriptionBroadcaster) HandleSubscriptionRequest(request *sxml.XMLSubscriptionRequest, message *audit.BigQueryMessage) (resps []siri.SIRIResponseStatus) {
var lineIds, subIds []string
for _, ett := range request.XMLSubscriptionETTEntries() {
rs := siri.SIRIResponseStatus{
Method SIRIProductionTimetableSubscriptionBroadcaster.HandleSubscriptionRequest
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (connector *SIRIProductionTimetableSubscriptionBroadcaster) HandleSubscriptionRequest(request *sxml.XMLSubscriptionRequest, message *audit.BigQueryMessage) (resps []siri.SIRIResponseStatus) {
var lineIds, subIds []string
for _, ptt := range request.XMLSubscriptionPTTEntries() {
rs := siri.SIRIResponseStatus{
Method CollectManager.requestStopAreaFilteredSituation
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
func (manager *CollectManager) requestStopAreaFilteredSituation(requestedId string) {
stopArea, ok := manager.referential.Model().StopAreas().Find(model.StopAreaId(requestedId))
if !ok {
logger.Log.Debugf("Can't find StopArea to request %v", requestedId)
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 VMSubscriber.prepareSIRIVehicleMonitoringSubscriptionRequest
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
func (subscriber *VMSubscriber) prepareSIRIVehicleMonitoringSubscriptionRequest() {
subscriptions := subscriber.connector.partner.Subscriptions().FindSubscriptionsByKind(VehicleMonitoringCollect)
if len(subscriptions) == 0 {
logger.Log.Debugf("VehicleMonitoringSubscriber visit without VehicleMonitoringCollect subscriptions")
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 GMSubscriber.prepareSIRIGeneralMessageSubscriptionRequest
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
func (subscriber *GMSubscriber) prepareSIRIGeneralMessageSubscriptionRequest() {
subscriptions := subscriber.connector.partner.Subscriptions().FindSubscriptionsByKind(GeneralMessageCollect)
if len(subscriptions) == 0 {
logger.Log.Debugf("GeneralMessageSubscriber visit without GeneralMessageCollect subscriptions")
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 CollectManager.requestStopAreaFilteredSituation
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (manager *CollectManager) requestStopAreaFilteredSituation(requestedId string) {
stopArea, ok := manager.referential.Model().StopAreas().Find(model.StopAreaId(requestedId))
if !ok {
logger.Log.Debugf("Can't find StopArea to request %v", requestedId)
return
Method SIRIClient.prepareAndSendRequest
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (client *SIRIClient) prepareAndSendRequest(args siriClientArguments) (xml.Node, error) {
// Wrap the request XML
buffer := NewSIRIBuffer(client.siriEnvelopeType)
xml, err := args.request.BuildXML(client.siriEnvelopeType)
Method SIRILiteStopMonitoringRequestCollector.RequestStopAreaUpdate
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (connector *SIRILiteStopMonitoringRequestCollector) RequestStopAreaUpdate(request *StopAreaUpdateRequest) {
stopArea, ok := connector.partner.Model().StopAreas().Find(request.StopAreaId())
if !ok {
logger.Log.Debugf("StopAreaUpdateRequest in LiteStopMonitoringRequestCollector for unknown StopArea %v", request.StopAreaId())
return
Method SIRIGeneralMessageSubscriptionBroadcaster.HandleSubscriptionRequest
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (connector *SIRIGeneralMessageSubscriptionBroadcaster) HandleSubscriptionRequest(request *sxml.XMLSubscriptionRequest, message *audit.BigQueryMessage) []siri.SIRIResponseStatus {
resps := []siri.SIRIResponseStatus{}
var subIds []string
Method MemoryStopVisits.Load
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (manager *MemoryStopVisits) Load(referentialSlug string) error {
var selectStopVisits []SelectStopVisit
modelName := manager.model.Date()
sqlQuery := fmt.Sprintf("select * from stop_visits where referential_slug = '%s' and model_name = '%s'", referentialSlug, modelName.String())
Method SIRILiteClient.prepareAndSendRequest
has 9 return statements (exceeds 4 allowed). Open
func (c *SIRILiteClient) prepareAndSendRequest(args siriLiteClientArguments) error {
dest := args.destination
ctx, cncl := context.WithTimeout(context.Background(), getTimeOut(args.requestType))
defer cncl()
Method SIRIStopMonitoringSubscriptionBroadcaster.checkStopAreaEvent
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
func (connector *SIRIStopMonitoringSubscriptionBroadcaster) checkStopAreaEvent(stopArea *model.StopArea) {
obj, ok := stopArea.Code(connector.remoteCodeSpace)
if !ok {
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 MemoryReferentials.Load
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
func (manager *MemoryReferentials) Load() error {
selectReferentials := []model.SelectReferential{}
_, err := model.Database.Select(&selectReferentials, "select * from referentials")
if err != nil {
return err
- 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 SIRIClient.prepareAndSendRequest
has 9 return statements (exceeds 4 allowed). Open
func (client *SIRIClient) prepareAndSendRequest(args siriClientArguments) (xml.Node, error) {
// Wrap the request XML
buffer := NewSIRIBuffer(client.siriEnvelopeType)
xml, err := args.request.BuildXML(client.siriEnvelopeType)
Method BigQueryClient.findOrCreateDataset
has 8 return statements (exceeds 4 allowed). Open
func (bq *BigQueryClient) findOrCreateDataset() (*bigquery.Dataset, error) {
it := bq.client.Datasets(bq.ctx)
for {
dataset, err := it.Next()
if err == iterator.Done {
Method Partner.hasSubscribers
has 8 return statements (exceeds 4 allowed). Open
func (partner *Partner) hasSubscribers() bool {
_, ok := partner.connectors[SIRI_STOP_MONITORING_SUBSCRIPTION_BROADCASTER]
if ok {
return true
}
Method HTTPClient.GTFSRequest
has 8 return statements (exceeds 4 allowed). Open
func (c *HTTPClient) GTFSRequest() (*gtfs.FeedMessage, error) {
ctx, cncl := context.WithTimeout(context.Background(), 60*time.Second)
defer cncl()
httpRequest, err := http.NewRequestWithContext(ctx, http.MethodGet, c.Url, nil)
Method PushHandler.serve
has 8 return statements (exceeds 4 allowed). Open
func (handler *PushHandler) serve(response http.ResponseWriter, request *http.Request) {
// Check if request header is protobuf or return an error
if request.Header.Get("Content-Type") != "application/x-protobuf" {
http.Error(response, "Expected application/x-protobuf content", http.StatusUnsupportedMediaType)
return