mirror of
https://github.com/TECHNOFAB11/dbmate.git
synced 2025-12-11 23:50:04 +01:00
Add gometalinter (#36)
This commit is contained in:
parent
cacf5de3ec
commit
ee3162c34c
6 changed files with 32 additions and 15 deletions
26
.gometalinter.json
Normal file
26
.gometalinter.json
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"Sort": ["linter", "severity", "path", "line"],
|
||||||
|
"WarnUnmatchedDirective": true,
|
||||||
|
"DisableAll": true,
|
||||||
|
"Enable": [
|
||||||
|
"deadcode",
|
||||||
|
"errcheck",
|
||||||
|
"gocyclo",
|
||||||
|
"gofmt",
|
||||||
|
"goimports",
|
||||||
|
"golint",
|
||||||
|
"interfacer",
|
||||||
|
"lll",
|
||||||
|
"maligned",
|
||||||
|
"megacheck",
|
||||||
|
"misspell",
|
||||||
|
"nakedret",
|
||||||
|
"structcheck",
|
||||||
|
"unconvert",
|
||||||
|
"unparam",
|
||||||
|
"varcheck",
|
||||||
|
"vet"
|
||||||
|
],
|
||||||
|
"Cyclo": 12,
|
||||||
|
"LineLength": 100
|
||||||
|
}
|
||||||
|
|
@ -15,9 +15,8 @@ RUN apt-get update \
|
||||||
# development dependencies
|
# development dependencies
|
||||||
RUN curl -fsSL -o /usr/local/bin/dep https://github.com/golang/dep/releases/download/v0.3.2/dep-linux-amd64 \
|
RUN curl -fsSL -o /usr/local/bin/dep https://github.com/golang/dep/releases/download/v0.3.2/dep-linux-amd64 \
|
||||||
&& chmod +x /usr/local/bin/dep
|
&& chmod +x /usr/local/bin/dep
|
||||||
RUN go get \
|
RUN go get gopkg.in/alecthomas/gometalinter.v2 \
|
||||||
github.com/golang/lint/golint \
|
&& gometalinter.v2 --install
|
||||||
github.com/kisielk/errcheck
|
|
||||||
|
|
||||||
# copy source files
|
# copy source files
|
||||||
COPY . /go/src/github.com/amacneil/dbmate
|
COPY . /go/src/github.com/amacneil/dbmate
|
||||||
|
|
|
||||||
4
Makefile
4
Makefile
|
|
@ -19,9 +19,7 @@ test:
|
||||||
|
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
lint:
|
lint:
|
||||||
golint -set_exit_status $(PACKAGES)
|
gometalinter.v2 $(PACKAGES)
|
||||||
go vet $(PACKAGES)
|
|
||||||
errcheck $(PACKAGES)
|
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func testContext(t *testing.T, u *url.URL) *cli.Context {
|
func testContext(t *testing.T, u *url.URL) *cli.Context {
|
||||||
var err error
|
err := os.Setenv("DATABASE_URL", u.String())
|
||||||
|
|
||||||
err = os.Setenv("DATABASE_URL", u.String())
|
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
app := NewApp()
|
app := NewApp()
|
||||||
|
|
|
||||||
|
|
@ -182,11 +182,7 @@ func (db *DB) NewMigration(name string) error {
|
||||||
|
|
||||||
defer mustClose(file)
|
defer mustClose(file)
|
||||||
_, err = file.WriteString(migrationTemplate)
|
_, err = file.WriteString(migrationTemplate)
|
||||||
if err != nil {
|
return err
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func doTransaction(db *sql.DB, txFunc func(Transaction) error) error {
|
func doTransaction(db *sql.DB, txFunc func(Transaction) error) error {
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ func mysqldumpArgs(u *url.URL) []string {
|
||||||
if username := u.User.Username(); username != "" {
|
if username := u.User.Username(); username != "" {
|
||||||
args = append(args, "--user="+username)
|
args = append(args, "--user="+username)
|
||||||
}
|
}
|
||||||
// mysql recommands against using environment variables to supply password
|
// mysql recommends against using environment variables to supply password
|
||||||
// https://dev.mysql.com/doc/refman/5.7/en/password-security-user.html
|
// https://dev.mysql.com/doc/refman/5.7/en/password-security-user.html
|
||||||
if password, set := u.User.Password(); set {
|
if password, set := u.User.Password(); set {
|
||||||
args = append(args, "--password="+password)
|
args = append(args, "--password="+password)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue