Skip to content

Commit

Permalink
golangci-lint: remove if-return from the linters
Browse files Browse the repository at this point in the history
if-return has been removed from the default list of revive for a valid
reason. See the argument in mgechev/revive#843.

Comparing two snippets

1.
```
if err := v.volSyncHandler.DeleteRS(name, namespace); err != nil {
	return err
}

if err := v.volSyncHandler.DeleteRD(name, namespace); err != nil {
	return err
}

if err := v.volSyncHandler.DeleteSnapshots(namespace); err != nil {
	return err
}

return nil
```

2.
```
if err := v.volSyncHandler.DeleteRS(name, namespace); err != nil {
	return err
}

if err := v.volSyncHandler.DeleteRD(name, namespace); err != nil {
	return err
}

return v.volSyncHandler.DeleteSnapshots(namespace)
```

1 is a lot easier to read compared to 2 but if-return throws an error
for it.

Signed-off-by: Raghavendra Talur <[email protected]>
  • Loading branch information
raghavendra-talur committed Jan 9, 2025
1 parent bbf136f commit dcbb587
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ linters-settings:
- name: error-strings
- name: error-naming
- name: exported
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
Expand Down

0 comments on commit dcbb587

Please sign in to comment.