You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please, fix these nested if-else statements.
Early returns are much easier to read.
An example of that would be in the control.go file with the error handling.
If there is no error, the length of the data is acceptable and everything is okay, it seems that this will always return an error.
if err == nil {
if length := len(response.Data); length > 18 { // 18 is the minimum expected
if int(response.Data[19]) != pduStart {
err = fmt.Errorf(ErrorText(errCliCannotStartPLC))
} else {
if int(response.Data[20]) == pduAlreadyStarted {
err = fmt.Errorf(ErrorText(errCliAlreadyRun))
} else {
err = fmt.Errorf(ErrorText(errCliCannotStartPLC))
}
}
} else {
err = fmt.Errorf(ErrorText(errIsoInvalidPDU))
}
}
Also, there are mistakes in the Stop method. int(response.Data[20]) == pduAlreadyStarted
Should be int(response.Data[20]) == pduAlreadyStopped
The text was updated successfully, but these errors were encountered:
Please, fix these nested if-else statements.
Early returns are much easier to read.
An example of that would be in the control.go file with the error handling.
If there is no error, the length of the data is acceptable and everything is okay, it seems that this will always return an error.
Also, there are mistakes in the Stop method.
int(response.Data[20]) == pduAlreadyStarted
Should be
int(response.Data[20]) == pduAlreadyStopped
The text was updated successfully, but these errors were encountered: