Repository: gobuffalo/buffalo
Pull request #1675 (2019-05-27 11:11:59)

Fix skip build deps on cleanup
Cleanup was calling `go mod tidy` which started to update existing modules even though I though it is only for cleaning up unused things.


Patch:
diff --git a/.golangci.yml b/.golangci.yml
new file mode 100644
index 00000000..ab6abcff
--- /dev/null
+++ b/.golangci.yml
@@ -0,0 +1,18 @@
+fast: true
+linters:
+  enable-all: false
+  disable-all: false
+  enable:
+    - govet
+    - golint
+    - goimports
+    - deadcode
+    - typecheck
+    - ineffassign
+    - misspell
+    - nakedret
+    - unconvert
+    - megacheck
+    - varcheck
+  disable:
+    - errcheck
\ No newline at end of file
diff --git a/.gometalinter.json b/.gometalinter.json
deleted file mode 100644
index e4f65a36..00000000
--- a/.gometalinter.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
-  "Enable": ["vet", "golint", "goimports", "deadcode", "gotype", "ineffassign", "misspell", "nakedret", "unconvert", "megacheck", "varcheck"]
-}
diff --git a/Dockerfile.build b/Dockerfile.build
index 2dc4c332..12bac5bc 100644
--- a/Dockerfile.build
+++ b/Dockerfile.build
@@ -20,9 +20,9 @@ RUN go get -u github.com/golang/dep/cmd/dep \
 && go get -v -u github.com/gobuffalo/packr/v2/packr2 \
 && go get -v -u github.com/markbates/filetest \
 && go get -v -u github.com/markbates/grift \
-&& go get -v -u github.com/markbates/refresh \
-&& go get -u github.com/alecthomas/gometalinter \
-&& gometalinter --install
+&& go get -v -u github.com/markbates/refresh 
+
+RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.16.0
 
 # clear out the src so that we can fill it with new versions
 RUN rm -rfv $GOPATH/src && mkdir -p $BP
diff --git a/Dockerfile.slim.build b/Dockerfile.slim.build
index d990eab2..aff8db11 100644
--- a/Dockerfile.slim.build
+++ b/Dockerfile.slim.build
@@ -21,9 +21,10 @@ RUN go get -u github.com/golang/dep/cmd/dep \
 && go get -v -u github.com/markbates/refresh \
 && go get -v -u github.com/gobuffalo/httptest \
 && go get -v -u github.com/gorilla/sessions \
-&& go get -v -u golang.org/x/vgo \
-&& go get -u github.com/alecthomas/gometalinter \
-&& gometalinter --install
+&& go get -v -u golang.org/x/vgo
+
+RUN curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.16.0
+
 
 RUN npm i -g --no-progress yarn \
 && yarn config set yarn-offline-mirror /npm-packages-offline-cache \
diff --git a/Makefile b/Makefile
index 9d08252a..475b5918 100644
--- a/Makefile
+++ b/Makefile
@@ -43,7 +43,7 @@ ci-test:
 	docker build . --no-cache --build-arg TRAVIS_BRANCH=$$(git symbolic-ref --short HEAD)
 
 lint:
-	gometalinter --vendor ./... --deadline=1m --skip=internal
+	golangci-lint --vendor ./... --deadline=1m --skip=internal
 
 update:
 	$(GO_BIN) get -u -tags ${TAGS}
diff --git a/app.go b/app.go
index 428c5aad..f40a2863 100644
--- a/app.go
+++ b/app.go
@@ -35,6 +35,7 @@ func (a *App) Muxer() *mux.Router {
 func New(opts Options) *App {
 	LoadPlugins()
 	envy.Load()
+
 	opts = optionsWithDefaults(opts)
 
 	a := &App{
@@ -56,7 +57,8 @@ func New(opts Options) *App {
 		return func(res http.ResponseWriter, req *http.Request) {
 			c := a.newContext(RouteInfo{}, res, req)
 			err := fmt.Errorf(errorf, req.Method, req.URL.Path)
-			a.ErrorHandlers.Get(code)(code, err, c)
+			_ = a.ErrorHandlers.Get(code)(code, err, c)
+
 		}
 	}
 
diff --git a/buffalo/cmd/destroy/action.go b/buffalo/cmd/destroy/action.go
index 525ed1be..5b79bf70 100644
--- a/buffalo/cmd/destroy/action.go
+++ b/buffalo/cmd/destroy/action.go
@@ -2,8 +2,8 @@ package destroy
 
 import (
 	"errors"
-	"github.com/gobuffalo/flect"
 
+	"github.com/gobuffalo/flect"
 	"github.com/spf13/cobra"
 )
 
diff --git a/buffalo/cmd/destroy/mailer.go b/buffalo/cmd/destroy/mailer.go
index a560be9e..0fb40574 100644
--- a/buffalo/cmd/destroy/mailer.go
+++ b/buffalo/cmd/destroy/mailer.go
@@ -3,10 +3,10 @@ package destroy
 import (
 	"errors"
 	"fmt"
-	"github.com/gobuffalo/flect"
 	"os"
 	"path/filepath"
 
+	"github.com/gobuffalo/flect"
 	"github.com/sirupsen/logrus"
 	"github.com/spf13/cobra"
 )
diff --git a/genny/assets/webpack/templates/package.json.tmpl b/genny/assets/webpack/templates/package.json.tmpl
index 43c6dcd4..97bcf77b 100644
--- a/genny/assets/webpack/templates/package.json.tmpl
+++ b/genny/assets/webpack/templates/package.json.tmpl
@@ -35,6 +35,6 @@
     "webpack-cli": "3.1.0",
     "webpack-livereload-plugin":"2.1.1",
     "webpack-manifest-plugin": "~2.0.0",
-    "node-sass": "~4.9.0"
+    "node-sass": "~4.12.0"
   }
 }
diff --git a/genny/build/cleanup.go b/genny/build/cleanup.go
index c0d68b19..90ca20bd 100644
--- a/genny/build/cleanup.go
+++ b/genny/build/cleanup.go
@@ -36,7 +36,7 @@ func Cleanup(opts *Options) genny.RunFn {
 				return err
 			}
 		}
-		if envy.Mods() {
+		if envy.Mods() && opts.WithBuildDeps {
 			if err := r.Exec(exec.Command(genny.GoBin(), "mod", "tidy")); err != nil {
 				return err
 			}
diff --git a/grifts/tools.go b/grifts/tools.go
index ad47175b..e8d989bd 100644
--- a/grifts/tools.go
+++ b/grifts/tools.go
@@ -18,11 +18,8 @@ var _ = grift.Namespace("tools", func() {
 	}
 
 	var _ = grift.Add("install", func(c *grift.Context) error {
-		if _, err := exec.LookPath("gometalinter"); err != nil {
-			if err := run("go", "get", "-u", "-v", "github.com/alecthomas/gometalinter"); err != nil {
-				return err
-			}
-			if err := run("gometalinter", "--install"); err != nil {
+		if _, err := exec.LookPath("golangci-lint"); err != nil {
+			if err := run("go", "get", "-v", "github.com/golangci/golangci-lint/cmd/golangci-lint"); err != nil {
 				return err
 			}
 		}
@@ -33,7 +30,8 @@ var _ = grift.Namespace("tools", func() {
 		if err := grift.Run("tools:install", c); err != nil {
 			return err
 		}
-		return run("gometalinter", "--vendor", "--deadline=3m", "./...")
+
+		return run("golangci-lint", "run", "--fast", "--deadline=3m")
 	})
 
 })


Test patch:
diff --git a/genny/build/cleanup_test.go b/genny/build/cleanup_test.go
new file mode 100644
index 00000000..8a573aa6
--- /dev/null
+++ b/genny/build/cleanup_test.go
@@ -0,0 +1,62 @@
+package build
+
+import (
+	"sync"
+	"testing"
+
+	"github.com/gobuffalo/envy"
+	"github.com/gobuffalo/genny/gentest"
+	"github.com/gobuffalo/meta"
+	"github.com/stretchr/testify/require"
+)
+
+func Test_WithDeps(t *testing.T) {
+	r := require.New(t)
+	envy.Set(envy.GO111MODULE, "on")
+
+	run := gentest.NewRunner()
+
+	opts := &Options{
+		WithAssets:    false,
+		WithBuildDeps: true,
+		Environment:   "bar",
+		App:           meta.New("."),
+	}
+
+	emptyMap := sync.Map{}
+	opts.rollback = &emptyMap
+
+	f := Cleanup(opts)
+	f(run)
+
+	results := run.Results()
+
+	cmds := []string{"go mod tidy"}
+	for i, c := range results.Commands {
+		eq(r, cmds[i], c)
+	}
+}
+
+func Test_WithoutDeps(t *testing.T) {
+	r := require.New(t)
+	envy.Set(envy.GO111MODULE, "on")
+
+	run := gentest.NewRunner()
+
+	opts := &Options{
+		WithAssets:    false,
+		WithBuildDeps: false,
+		Environment:   "bar",
+		App:           meta.New("."),
+	}
+
+	emptyMap := sync.Map{}
+	opts.rollback = &emptyMap
+
+	f := Cleanup(opts)
+	f(run)
+
+	results := run.Results()
+
+	r.Len(results.Commands, 0)
+}