Skip to content

fix(commands): properly return error instead of nil

Description

This MR enables the nilerr linter and fixes found issues. nilerr detects code that returns nil even when it checks that the error is not nil. For one, the MR adds the unit test to verify a new behaviour. For a few places, ignores nilerr with the //nolint directive.

$ golangci-lint run
internal/commands/mr/create/mr_create.go:299:3: error is not nil (line 297) but it returns nil (nilerr)
                return nil
                ^
internal/commands/mr/create/mr_create.go:310:4: error is not nil (line 308) but it returns nil (nilerr)
                        return nil
                        ^
internal/commands/mr/mrutils/mrutils.go:429:3: error is not nil (line 426) but it returns nil (nilerr)
                return utils.Humanize(sourceBranch), "", nil
                ^
internal/commands/mr/mrutils/mrutils.go:449:4: error is not nil (line 446) but it returns nil (nilerr)
                        return title, commits[0].Title, nil
                        ^
4 issues:
* nilerr: 4

How has this been tested?

Unit tests.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation
  • Chore (Related to CI or Packaging to platforms)
  • Test gap
Edited by Oleksandr Redko

Merge request reports

Loading