Showing 146 of 546 total issues
Method SIRISituationExchangeRequestBroadcaster.canBroadcast
has 5 return statements (exceeds 4 allowed). Open
Open
func (connector *SIRISituationExchangeRequestBroadcaster) canBroadcast(situation model.Situation) bool {
if situation.Origin == string(connector.partner.Slug()) {
return false
}
Method UpdateManager.updateStopVisit
has 5 return statements (exceeds 4 allowed). Open
Open
func (manager *UpdateManager) updateStopVisit(event *StopVisitUpdateEvent) {
if event.Code.Value() == "" { // Avoid creating a StopVisit with an empty code
return
}
Method MemoryReferentials.Load
has 5 return statements (exceeds 4 allowed). Open
Open
func (manager *MemoryReferentials) Load() error {
selectReferentials := []model.SelectReferential{}
_, err := model.Database.Select(&selectReferentials, "select * from referentials")
if err != nil {
return err
Method Purifier.Purge
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *Purifier) Purge() error {
if p.date == "" {
return fmt.Errorf("purifier date is empty")
}
Method APISituation.Validate
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
Open
func (apiSituation *APISituation) Validate() bool {
if apiSituation.CodeSpace == "" {
apiSituation.Errors.Add("CodeSpace", e.ERROR_BLANK)
}
- 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 Controller.serve
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
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"