Showing 146 of 546 total issues
Function main
has a Cognitive Complexity of 45 (exceeds 20 allowed). Consider refactoring. Open
func main() {
cpuProfile := flag.String("cpuprofile", "", "Write cpu profile to file")
memProfile := flag.String("memprofile", "", "Write memory profile to this file")
uuidPtr := flag.Bool("testuuid", false, "Use the test uuid generator")
- 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 VMBroadcaster.prepareSIRIVehicleMonitoring
has 128 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (vm *VMBroadcaster) prepareSIRIVehicleMonitoring() {
vm.connector.mutex.Lock()
defer vm.connector.mutex.Unlock()
events := vm.connector.toBroadcast
Method MemoryStopAreas.Load
has a Cognitive Complexity of 43 (exceeds 20 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())
- 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 ETTBroadcaster.prepareSIRIEstimatedTimetable
has 119 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (ett *ETTBroadcaster) prepareSIRIEstimatedTimetable() {
ett.connector.mutex.Lock()
events := ett.connector.toBroadcast
ett.connector.toBroadcast = make(map[SubscriptionId][]model.StopVisitId)
Method SIRIEstimatedTimetableRequestBroadcaster.getEstimatedTimetableDelivery
has 118 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (connector *SIRIEstimatedTimetableRequestBroadcaster) getEstimatedTimetableDelivery(request *sxml.XMLEstimatedTimetableRequest) siri.SIRIEstimatedTimetableDelivery {
currentTime := connector.Clock().Now()
delivery := siri.SIRIEstimatedTimetableDelivery{
RequestMessageRef: request.MessageIdentifier(),
Method ServiceAlertsBroadcaster.handleGtfs
has a Cognitive Complexity of 39 (exceeds 20 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) {
- 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 SIRIHandler.serve
has 108 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (handler *SIRIHandler) serve(response http.ResponseWriter, request *http.Request) {
response.Header().Set("Content-Type", "text/xml; charset=utf-8")
m := &audit.BigQueryMessage{
Protocol: "siri",
Method PTTBroadcaster.prepareSIRIProductionTimetable
has 107 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (ptt *PTTBroadcaster) prepareSIRIProductionTimetable() {
ptt.connector.mutex.Lock()
events := ptt.connector.toBroadcast
ptt.connector.toBroadcast = make(map[SubscriptionId][]model.StopVisitId)
Method UpdateManager.updateStopVisit
has 103 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (manager *UpdateManager) updateStopVisit(event *StopVisitUpdateEvent) {
if event.Code.Value() == "" { // Avoid creating a StopVisit with an empty code
return
}
Method SituationCondition.FromString
has 99 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (condition *SituationCondition) FromString(c string) error {
switch SituationCondition(c) {
case SituationConditionAdditionalRide:
fallthrough
case SituationConditionAdditionalService:
Method SIRILiteVehicleMonitoringRequestBroadcaster.RequestVehicles
has 98 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (connector *SIRILiteVehicleMonitoringRequestBroadcaster) RequestVehicles(url string, filters url.Values, message *audit.BigQueryMessage) (siriLiteResponse *siri.SiriLiteResponse) {
lineRef := filters.Get("LineRef")
message.RequestIdentifier = filters.Get("MessageIdentifier")
message.Lines = []string{lineRef}
Method MemoryStopVisits.Load
has a Cognitive Complexity of 35 (exceeds 20 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())
- 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 deepValueEqual
has 93 lines of code (exceeds 50 allowed). Consider refactoring. 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 SIRIHandler.requestHandler
has 93 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (handler *SIRIHandler) requestHandler(envelope *remote.SIRIEnvelope) SIRIRequestHandler {
switch envelope.BodyType() {
case "CheckStatus":
return &SIRICheckStatusRequestHandler{
xmlRequest: sxml.NewXMLCheckStatusRequest(envelope.Body()),
Function NewConnectorFactory
has 92 lines of code (exceeds 50 allowed). Consider refactoring. Open
func NewConnectorFactory(connectorType string) ConnectorFactory {
switch connectorType {
case GRAPHQL_SERVER:
return &GraphqlServerFactory{}
case PUSH_COLLECTOR:
MemoryModel
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
type MemoryModel struct {
lines *MemoryLines
vehicles *MemoryVehicles
stopAreas *MemoryStopAreas
stopVisits *MemoryStopVisits
Method SIRISituationExchangeRequestBroadcaster.buildSituation
has 91 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (connector *SIRISituationExchangeRequestBroadcaster) buildSituation(delivery *siri.SIRISituationExchangeDelivery, situation model.Situation) {
if !connector.canBroadcast(situation) {
return
}
Method BroadcastSituationExchangeBuilder.BuildSituationExchange
has 91 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (builder *BroadcastSituationExchangeBuilder) BuildSituationExchange(situation model.Situation, delivery *siri.SIRISituationExchangeDelivery) {
if !builder.canBroadcast(situation) {
return
}
File stop_visit.go
has 521 lines of code (exceeds 500 allowed). Consider refactoring. Open
package model
import (
"encoding/json"
"fmt"
SIRIClient
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
type SIRIClient struct {
httpClient *HTTPClient
siriEnvelopeType string
}