Showing 134 of 525 total issues
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 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 GtfsHandler.serve
has 64 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)
Method BroadcastGeneralMessageBuilder.BuildGeneralMessage
has 64 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 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 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
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())
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, ptSituationElement *siri.SIRIPtSituationElement, 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 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 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 PushHandler.serve
has 57 lines of code (exceeds 50 allowed). Consider refactoring. 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
Method SIRISubscriptionRequestDispatcher.Dispatch
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (connector *SIRISubscriptionRequestDispatcher) Dispatch(request *sxml.XMLSubscriptionRequest, message *audit.BigQueryMessage) (*siri.SIRISubscriptionResponse, error) {
response := siri.SIRISubscriptionResponse{
Address: connector.Partner().Address(),
ResponderRef: connector.Partner().RequestorRef(),
ResponseTimestamp: connector.Clock().Now(),
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 SIRIStopMonitoringSubscriptionBroadcaster.HandleSubscriptionRequest
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (connector *SIRIStopMonitoringSubscriptionBroadcaster) HandleSubscriptionRequest(request *sxml.XMLSubscriptionRequest, message *audit.BigQueryMessage) (resps []siri.SIRIResponseStatus) {
var monitoringRefs, subIds []string
for _, sm := range request.XMLSubscriptionSMEntries() {
rs := siri.SIRIResponseStatus{
Function NewSIRICheckStatusResponse
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
address string,
producerRef string,
requestMessageRef string,
responseMessageIdentifier string,
status bool,
Method CollectManager.UpdateStopArea
has a Cognitive Complexity of 26 (exceeds 20 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 {
- 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 SIRISubscriptionRequestDispatcher.Dispatch
has 13 return statements (exceeds 4 allowed). Open
func (connector *SIRISubscriptionRequestDispatcher) Dispatch(request *sxml.XMLSubscriptionRequest, message *audit.BigQueryMessage) (*siri.SIRISubscriptionResponse, error) {
response := siri.SIRISubscriptionResponse{
Address: connector.Partner().Address(),
ResponderRef: connector.Partner().RequestorRef(),
ResponseTimestamp: connector.Clock().Now(),
Method SMBroadcaster.prepareSIRIStopMonitoringNotify
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (smb *SMBroadcaster) prepareSIRIStopMonitoringNotify() {
smb.connector.mutex.Lock()
events := smb.connector.toBroadcast
smb.connector.toBroadcast = make(map[SubscriptionId][]model.StopVisitId)