Showing 134 of 525 total issues
Method Partner.CanCollectLines
has 5 return statements (exceeds 4 allowed). Open
func (partner *Partner) CanCollectLines(lineIds map[string]struct{}) s.CollectStatus {
if len(lineIds) == 0 {
return s.COLLECT_UNKNOWN
}
Method MemoryLines.Load
has 5 return statements (exceeds 4 allowed). 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)
Method MemoryVehicleJourneys.Load
has 5 return statements (exceeds 4 allowed). 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)
Method UpdateManager.updateStopVisit
has 5 return statements (exceeds 4 allowed). Open
func (manager *UpdateManager) updateStopVisit(event *StopVisitUpdateEvent) {
if event.Code.Value() == "" { // Avoid creating a StopVisit with an empty code
return
}
Method SIRIProductionTimetableSubscriptionBroadcaster.stopPointRef
has 5 return statements (exceeds 4 allowed). Open
func (connector *SIRIProductionTimetableSubscriptionBroadcaster) stopPointRef(stopAreaId model.StopAreaId) (*model.StopArea, string, bool) {
stopPointRef, ok := connector.Partner().Model().StopAreas().Find(stopAreaId)
if !ok {
return &model.StopArea{}, "", false
}
Method SIRILiteHandler.serve
has 5 return statements (exceeds 4 allowed). Open
func (handler *SIRILiteHandler) serve(response http.ResponseWriter, request *http.Request, requestData *SIRIRequestData) {
if handler.token == "" {
http.Error(response, "No Authorization Token", http.StatusUnauthorized)
return
}
Method BroadcastGeneralMessageBuilder.canBroadcast
has 5 return statements (exceeds 4 allowed). Open
func (builder *BroadcastGeneralMessageBuilder) canBroadcast(situation model.Situation) bool {
if situation.Origin == string(builder.partner.Slug()) {
return false
}
Method BroadcastSituationExchangeBuilder.canBroadcast
has 5 return statements (exceeds 4 allowed). Open
func (builder *BroadcastSituationExchangeBuilder) canBroadcast(situation model.Situation) bool {
if situation.Origin == string(builder.partner.Slug()) {
return false
}
Method TimeController.serve
has 5 return statements (exceeds 4 allowed). Open
func (controller *TimeController) serve(response http.ResponseWriter, request *http.Request, requestData *RequestData) {
switch {
case request.Method == "GET":
if requestData.Resource != "" {
http.Error(response, "Invalid request", http.StatusBadRequest)
Method StopMonitoringLastChange.Haschanged
has 5 return statements (exceeds 4 allowed). Open
func (smlc *StopMonitoringLastChange) Haschanged(stopVisit *model.StopVisit) bool {
// Don't send info on cancelled or departed SV
if smlc.departureStatus == model.STOP_VISIT_DEPARTURE_DEPARTED || smlc.departureStatus == model.STOP_VISIT_DEPARTURE_CANCELLED || smlc.arrivalStatuts == model.STOP_VISIT_ARRIVAL_CANCELLED {
return false
}
Method Loader.Load
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (loader Loader) Load(reader io.Reader) Result {
// Config CSV reader
csvReader := csv.NewReader(reader)
csvReader.Comment = '#'
csvReader.FieldsPerRecord = -1
- 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 SIRIEstimatedTimetableRequestBroadcaster.stopPointRef
has 5 return statements (exceeds 4 allowed). Open
func (connector *SIRIEstimatedTimetableRequestBroadcaster) stopPointRef(stopAreaId model.StopAreaId) (*model.StopArea, string, bool) {
stopPointRef, ok := connector.partner.Model().StopAreas().Find(stopAreaId)
if !ok {
return &model.StopArea{}, "", false
}
Method Controller.serve
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
func (controller *Controller) serve(response http.ResponseWriter, request *http.Request, requestData *RequestData) {
// Check request body
if requestData.Method == "PUT" || (requestData.Method == "POST" && requestData.Id != "save" && requestData.Action != "reload") {
requestData.Body = getRequestBody(response, request)
if requestData.Body == nil {
- 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 SMSubscriber.prepareSIRIStopMonitoringSubscriptionRequest
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
func (subscriber *SMSubscriber) prepareSIRIStopMonitoringSubscriptionRequest() {
subscriptions := subscriber.connector.partner.Subscriptions().FindSubscriptionsByKind(StopMonitoringCollect)
if len(subscriptions) == 0 {
logger.Log.Debugf("StopMonitoringSubscriber visit without StopMonitoringCollect 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"