Skip to content

Two small improvements to code quality#2560

Merged
rawtaz merged 3 commits intorestic:masterfrom
brualan:master
Feb 12, 2020
Merged

Two small improvements to code quality#2560
rawtaz merged 3 commits intorestic:masterfrom
brualan:master

Conversation

@brualan
Copy link
Copy Markdown
Contributor

@brualan brualan commented Jan 27, 2020

What is the purpose of this change? What does it change?

It's two small improvements to code quality. Details can be found in commit messages

Was the change discussed in an issue or in the forum before?

No, I made changes on my own initiative

Checklist

  • I have read the Contribution Guidelines
  • I have added tests for all changes in this PR
  • I have added documentation for the changes (in the manual)
  • There's a new file in changelog/unreleased/ that describes the changes for our users (template here)
  • I have run gofmt on the code in all commits
  • All commit messages are formatted in the same style as the other commits in the repo
  • I'm done, this Pull Request is ready for review

I was running "golangci-lint" and found this two warnings

internal/checker/checker.go:135:18: (*Checker).LoadIndex$3 - result 0 (error) is always nil (unparam)
        final := func() error {
                        ^
internal/repository/repository.go:457:18: (*Repository).LoadIndex$3 - result 0 (error) is always nil (unparam)
        final := func() error {
                        ^

It turns out that these functions are used only in "RunWorkers(...)",
which is used only two times in whole project right after this "final"
functions.
And because these "final" functions always return "nil", I've
descided, that it would be better to remove requriments for "final" func
to return error to avoid magick "return nil" at their end.
in case of len(format) == 0, we will get an
"index out of range" error
Usage of strings.HasSuffix is allowing to avoid that
@brualan brualan requested a review from fd0 January 27, 2020 16:44
Copy link
Copy Markdown
Member

@fd0 fd0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for taking the time!

@rawtaz rawtaz merged commit 299f597 into restic:master Feb 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants