Merge pull request #3 from smowton/smowton/fix/misleading-comment
Fix misleading comment in logicalOperators.go; expand on others
This commit is contained in:
Коммит
6b4d5f65c7
|
@ -75,7 +75,7 @@ func logicalAndElseBranchAlwaysBad2() {
|
||||||
if errorSource() == ErrNone && someOtherCondition() {
|
if errorSource() == ErrNone && someOtherCondition() {
|
||||||
doSomething()
|
doSomething()
|
||||||
} else {
|
} else {
|
||||||
// Bad: On error we may enter either branch, but neither one returns.
|
// Bad: there is no return statement at all.
|
||||||
insteadOfReturn()
|
insteadOfReturn()
|
||||||
}
|
}
|
||||||
doSomething()
|
doSomething()
|
||||||
|
@ -85,7 +85,7 @@ func logicalAndElseBranchAlwaysBad2() {
|
||||||
func logicalAndThenBranchGood() {
|
func logicalAndThenBranchGood() {
|
||||||
|
|
||||||
if someOtherCondition() && errorSource() != ErrNone {
|
if someOtherCondition() && errorSource() != ErrNone {
|
||||||
// Good: whenever an error is indicated we return.
|
// Good: whenever an error is indicated we return (note errorSource() is not called until someOtherCondition() passes)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
doSomething()
|
doSomething()
|
||||||
|
@ -95,7 +95,7 @@ func logicalAndThenBranchGood() {
|
||||||
func logicalAndElseBranchGood() {
|
func logicalAndElseBranchGood() {
|
||||||
|
|
||||||
if someOtherCondition() && errorSource() == ErrNone {
|
if someOtherCondition() && errorSource() == ErrNone {
|
||||||
// Good: whenever an error is indicated we return.
|
// Good: whenever an error is indicated we return (note errorSource() is not called until someOtherCondition() passes)
|
||||||
doSomething()
|
doSomething()
|
||||||
} else {
|
} else {
|
||||||
return
|
return
|
||||||
|
@ -154,7 +154,7 @@ func logicalOrThenBranchAlwaysBad() {
|
||||||
func logicalOrThenBranchGood() {
|
func logicalOrThenBranchGood() {
|
||||||
|
|
||||||
if someOtherCondition() || errorSource() != ErrNone {
|
if someOtherCondition() || errorSource() != ErrNone {
|
||||||
// Good: whenever an error is indicated we return.
|
// Good: whenever an error is indicated we return. (note errorSource() is not called until someOtherCondition() fails)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
doSomething()
|
doSomething()
|
||||||
|
@ -164,7 +164,7 @@ func logicalOrThenBranchGood() {
|
||||||
func logicalOrElseBranchGood() {
|
func logicalOrElseBranchGood() {
|
||||||
|
|
||||||
if someOtherCondition() || errorSource() == ErrNone {
|
if someOtherCondition() || errorSource() == ErrNone {
|
||||||
// Good: whenever an error is indicated we return.
|
// Good: whenever an error is indicated we return. (note errorSource() is not called until someOtherCondition() fails)
|
||||||
doSomething()
|
doSomething()
|
||||||
} else {
|
} else {
|
||||||
return
|
return
|
||||||
|
|
Загрузка…
Ссылка в новой задаче