Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

kmuratov
Copy link
Contributor

Enable multi-linter #125

  • enabled maligned linter
  • enabled staticcheck linter
  • enabled errcheck linter
  • added some fixes for golint

@kmuratov kmuratov changed the title Enabled maligned, staticcheck and errcheck linters WIP: Enabled maligned, staticcheck and errcheck linters Apr 17, 2019
@coveralls
Copy link

coveralls commented Apr 17, 2019

Pull Request Test Coverage Report for Build 389

  • 47 of 94 (50.0%) changed or added relevant lines in 7 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-1.3%) to 51.722%

Changes Missing Coverage Covered Lines Changed/Added Lines %
database/firebird/firebird.go 3 5 60.0%
testing/docker.go 0 5 0.0%
migration.go 3 9 33.33%
testing/testing.go 0 8 0.0%
migrate.go 34 60 56.67%
Totals Coverage Status
Change from base Build 373: -1.3%
Covered Lines: 751
Relevant Lines: 1452

💛 - Coveralls

@kmuratov kmuratov changed the title WIP: Enabled maligned, staticcheck and errcheck linters Enabled maligned, staticcheck and errcheck linters Apr 17, 2019
Copy link
Member

@dhui dhui left a comment

Choose a reason for hiding this comment

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

Wow, thanks so much for fixing all of the issues found when enabling the other linters!

This PR is mostly ready to be merged. There are just fixes that could be a bit better.

}

return uint(port.Int()), binding.HostIP, uint(hostPortUint), nil
hostPortUint, err := strconv.ParseUint(bindings[0].HostPort, 10, 64)
Copy link
Member

Choose a reason for hiding this comment

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

Let's keep the current behavior of searching through the available bindings.
Most tests use dktest instead of this so this won't affect any existing db driver tests, but I'd like to preserve past functionality.

There were issues with assuming that the first binding exists and that the binding data format is consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, I see now. Using of only the first binding confused me.
I'll rollback it and add nolint.

But if you wish I can replace it with this one (it might be more explicit):

for port, bindings := range d.ContainerJSON.NetworkSettings.Ports {
	if !selectFirst && port.Int() != cPort {
		// Skip ahead until we find the port we want
		continue
	}
	if len(bindings) == 0 {
		continue
	}
	hostPortUint, err := strconv.ParseUint(bindings[0].HostPort, 10, 64)
	if err != nil {
		return 0, "", 0, err
	}

	return uint(port.Int()), bindings[0].HostIP, uint(hostPortUint), nil
}

Copy link
Member

@dhui dhui left a comment

Choose a reason for hiding this comment

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

A little bit more cleanup and we're good to go.

Also, don't forget about: #206 (comment)

I'm looking forward to merging this PR!

if _, err := tx.ExecContext(context.Background(), query); err != nil {
tx.Rollback()
if errRollback := tx.Rollback(); errRollback != nil {
err = multierror.Append(err, errRollback)
Copy link
Member

Choose a reason for hiding this comment

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

Note to self: mark this as a backwards incompatible change in the release notes

e.g. rollback errors are now handled so OrigErr may be a multierror

migrate.go Outdated
}

ret <- migr
// nolint: errcheck
Copy link
Member

Choose a reason for hiding this comment

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

I think we could send the error on the ret channel since runMigrations has a type assertion and handles the error case.

For now, let's just log the error for now to avoid any changes in behavior.
My guess is that any buffering errors will result in errors down stream.

The logging may actually help debug a lot of the reported file error issues!

@dhui
Copy link
Member

dhui commented Apr 25, 2019

I've also noticed that the unittests for this PR haven't ever passed e.g. even subsequent re-runs/retries have failed. I wonder if it's b/c we're erroring on Firebird close now in isReady() function in the tests.

Previously, the Firebird db tests were failing intermittently.

database/util.go Outdated
const advisoryLockIDSalt uint = 1486364155

// GenerateAdvisoryLockId inspired by rails migrations, see https://goo.gl/8o9bCT
// nolint: golint
Copy link
Member

Choose a reason for hiding this comment

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

I meant that this should be on the same line as the function declaration. e.g. func GenerateAdvisoryLockId(databaseName string, additionalNames ...string) (string, error) { // nolint: golint

}

// nolint: staticcheck
return uint(port.Int()), binding.HostIP, uint(hostPortUint), nil
Copy link
Member

Choose a reason for hiding this comment

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

Likewise, this should be on the same line: return uint(port.Int()), binding.HostIP, uint(hostPortUint), nil // nolint: staticcheck

specs = []dktesting.ContainerSpec{
{ImageName: "jacobalberty/firebird:2.5-ss", Options: opts},
{ImageName: "jacobalberty/firebird:3.0", Options: opts},
{ImageName: "jacobalberty/firebird:2.5.8-ss", Options: opts},
Copy link
Member

Choose a reason for hiding this comment

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

It might be better to drop support for 2.5 until tests pass consistently

{ImageName: "jacobalberty/firebird:2.5-ss", Options: opts},
{ImageName: "jacobalberty/firebird:3.0", Options: opts},
{ImageName: "jacobalberty/firebird:2.5.8-ss", Options: opts},
{ImageName: "jacobalberty/firebird:3.0.4", Options: opts},
Copy link
Member

Choose a reason for hiding this comment

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

Let's leave the the version as 3.0.
https://hub.docker.com/r/jacobalberty/firebird/tags

It looks like only a single tag is updated per release: https://github.com/jacobalberty/firebird-docker/blob/master/hooks/post_push

@dhui
Copy link
Member

dhui commented Apr 26, 2019

The Firebird test failures are unrelated to this PR. To unblock this PR, I'm going to remove official support for Firebird. For more info, see: #49 (comment)

@kmuratov
Copy link
Contributor Author

That's fine. Thank you for all your reviews and comments.

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.

4 participants