Skip to content

Commit

Permalink
chore(deps): Adding gofumpt as a formatting tool
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Oct 31, 2021
1 parent 8f5a3d9 commit a6adffc
Show file tree
Hide file tree
Showing 30 changed files with 105 additions and 122 deletions.
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,19 @@ dev: format style test build
.PHONY: init
init:
@curl --disable --silent --show-error --location --max-time 30 "https://raw.githubusercontent.com/ViBiOh/scripts/main/bootstrap" | bash -s -- "-c" "git_hooks" "coverage" "release"
go install github.com/kisielk/errcheck@latest
go install golang.org/x/lint/golint@latest
go install golang.org/x/tools/cmd/goimports@latest
go install github.com/golang/mock/[email protected]
go install "github.com/golang/mock/[email protected]"
go install "github.com/kisielk/errcheck@latest"
go install "golang.org/x/lint/golint@latest"
go install "golang.org/x/tools/cmd/goimports@latest"
go install "mvdan.cc/gofumpt@latest"
$(MAKE) mocks
go mod tidy -compat=1.17

## format: Format code. e.g Prettier (js), format (golang)
.PHONY: format
format:
goimports -w $(shell find . -name "*.go")
gofmt -s -w $(shell find . -name "*.go")
gofumpt -s -w $(shell find . -name "*.go")

## style: Check lint, code styling rules. e.g. pylint, phpcs, eslint, style (java) etc ...
.PHONY: style
Expand Down
28 changes: 13 additions & 15 deletions pkg/ketchup/ketchup.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,19 @@ const (
appPath = "/app"
)

var (
// FuncMap for template rendering
FuncMap = template.FuncMap{
"frequencyImage": func(frequency model.KetchupFrequency) string {
switch frequency {
case model.None:
return "bell-slash"
case model.Weekly:
return "calendar"
default:
return "clock"
}
},
}
)
// FuncMap for template rendering
var FuncMap = template.FuncMap{
"frequencyImage": func(frequency model.KetchupFrequency) string {
switch frequency {
case model.None:
return "bell-slash"
case model.Weekly:
return "calendar"
default:
return "clock"
}
},
}

// App of package
type App struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ketchup/renderer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func TestMin(t *testing.T) {
b uint64
}

var cases = []struct {
cases := []struct {
intention string
args args
want uint64
Expand Down
28 changes: 13 additions & 15 deletions pkg/ketchup/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,19 @@ type securityPayload struct {
Question string `json:"question"`
}

var (
colors = map[int64]securityQuestion{
0: {"❄️ and 🧻 are both?", "white"},
1: {"☀️ and 🍋 are both?", "yellow"},
2: {"🥦 and 🥝 are both?", "green"},
3: {"👖 and 💧 are both?", "blue"},
4: {"🍅 and 🩸 are both?", "red"},
5: {"🍆 and ☂️ are both?", "purple"},
6: {"🦓 and 🕳 are both?", "black"},
7: {"🍊 and 🥕 are both?", "orange"},
8: {"🟥 mixed with 🟦 give?", "purple"},
9: {"🟨 mixed with 🟥 give?", "orange"},
10: {"🟦 mixed with 🟨 give?", "green"},
}
)
var colors = map[int64]securityQuestion{
0: {"❄️ and 🧻 are both?", "white"},
1: {"☀️ and 🍋 are both?", "yellow"},
2: {"🥦 and 🥝 are both?", "green"},
3: {"👖 and 💧 are both?", "blue"},
4: {"🍅 and 🩸 are both?", "red"},
5: {"🍆 and ☂️ are both?", "purple"},
6: {"🦓 and 🕳 are both?", "black"},
7: {"🍊 and 🥕 are both?", "orange"},
8: {"🟥 mixed with 🟦 give?", "purple"},
9: {"🟨 mixed with 🟥 give?", "orange"},
10: {"🟦 mixed with 🟨 give?", "green"},
}

func (a App) generateToken(ctx context.Context) (securityPayload, error) {
questionID, err := rand.Int(rand.Reader, big.NewInt(int64(len(colors))))
Expand Down
2 changes: 1 addition & 1 deletion pkg/middleware/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

func TestMiddleware(t *testing.T) {
var cases = []struct {
cases := []struct {
intention string
next http.Handler
request *http.Request
Expand Down
6 changes: 2 additions & 4 deletions pkg/model/ketchup.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ const (
Weekly
)

var (
// KetchupFrequencyValues string values
KetchupFrequencyValues = []string{"None", "Daily", "Weekly"}
)
// KetchupFrequencyValues string values
var KetchupFrequencyValues = []string{"None", "Daily", "Weekly"}

// ParseKetchupFrequency parse raw string into a KetchupFrequency
func ParseKetchupFrequency(value string) (KetchupFrequency, error) {
Expand Down
10 changes: 5 additions & 5 deletions pkg/model/ketchup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestParseKetchupFrequency(t *testing.T) {
value string
}

var cases = []struct {
cases := []struct {
intention string
args args
want KetchupFrequency
Expand Down Expand Up @@ -75,7 +75,7 @@ func TestKetchupByRepositoryID(t *testing.T) {
array []Ketchup
}

var cases = []struct {
cases := []struct {
intention string
args args
want []Ketchup
Expand Down Expand Up @@ -112,7 +112,7 @@ func TestKetchupByPriority(t *testing.T) {
array []Ketchup
}

var cases = []struct {
cases := []struct {
intention string
args args
want []Ketchup
Expand Down Expand Up @@ -193,7 +193,7 @@ func TestReleaseByRepositoryID(t *testing.T) {
array []Release
}

var cases = []struct {
cases := []struct {
intention string
args args
want []Release
Expand Down Expand Up @@ -230,7 +230,7 @@ func TestReleaseByKindAndName(t *testing.T) {
array []Release
}

var cases = []struct {
cases := []struct {
intention string
args args
want []Release
Expand Down
6 changes: 2 additions & 4 deletions pkg/model/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ const (
Pypi
)

var (
// RepositoryKindValues string values
RepositoryKindValues = []string{"github", "helm", "docker", "npm", "pypi"}
)
// RepositoryKindValues string values
var RepositoryKindValues = []string{"github", "helm", "docker", "npm", "pypi"}

// ParseRepositoryKind parse raw string into a RepositoryKind
func ParseRepositoryKind(value string) (RepositoryKind, error) {
Expand Down
8 changes: 4 additions & 4 deletions pkg/model/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func TestString(t *testing.T) {
var cases = []struct {
cases := []struct {
intention string
instance RepositoryKind
want string
Expand Down Expand Up @@ -38,7 +38,7 @@ func TestURL(t *testing.T) {
pattern string
}

var cases = []struct {
cases := []struct {
intention string
instance Repository
args args
Expand Down Expand Up @@ -85,7 +85,7 @@ func TestCompareURL(t *testing.T) {
pattern string
}

var cases = []struct {
cases := []struct {
intention string
instance Repository
args args
Expand Down Expand Up @@ -122,7 +122,7 @@ func TestParseRepositoryKind(t *testing.T) {
value string
}

var cases = []struct {
cases := []struct {
intention string
args args
want RepositoryKind
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/semver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestCheckPatternsMatching(t *testing.T) {
version semver.Version
}

var cases = []struct {
cases := []struct {
intention string
args args
want map[string]semver.Version
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func TestReadUser(t *testing.T) {
ctx context.Context
}

var cases = []struct {
cases := []struct {
intention string
args args
want User
Expand Down
4 changes: 1 addition & 3 deletions pkg/notifier/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ import (
"github.com/prometheus/client_golang/prometheus/push"
)

var (
pageSize = uint(20)
)
var pageSize = uint(20)

// App of package
type App struct {
Expand Down
8 changes: 4 additions & 4 deletions pkg/notifier/notifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func safeParse(version string) semver.Version {
}

func TestFlags(t *testing.T) {
var cases = []struct {
cases := []struct {
intention string
want string
}{
Expand Down Expand Up @@ -66,7 +66,7 @@ func TestGetNewRepositoryReleases(t *testing.T) {
repo model.Repository
}

var cases = []struct {
cases := []struct {
intention string
instance App
args args
Expand Down Expand Up @@ -159,7 +159,7 @@ func TestGetKetchupToNotify(t *testing.T) {
releases []model.Release
}

var cases = []struct {
cases := []struct {
intention string
args args
want map[model.User][]model.Release
Expand Down Expand Up @@ -326,7 +326,7 @@ func TestSendNotification(t *testing.T) {
ketchupToNotify map[model.User][]model.Release
}

var cases = []struct {
cases := []struct {
intention string
instance App
args args
Expand Down
7 changes: 4 additions & 3 deletions pkg/notifier/releases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestGetNewStandardReleases(t *testing.T) {
ctx context.Context
}

var cases = []struct {
cases := []struct {
intention string
instance App
args args
Expand Down Expand Up @@ -82,7 +82,8 @@ func TestGetNewStandardReleases(t *testing.T) {
mockRepositoryService.EXPECT().ListByKinds(gomock.Any(), gomock.Any(), gomock.Any(), model.Github, model.Docker, model.NPM, model.Pypi).Return(nil, uint64(0), errors.New("failed"))
case "github error":
mockRepositoryService.EXPECT().ListByKinds(gomock.Any(), gomock.Any(), gomock.Any(), model.Github, model.Docker, model.NPM, model.Pypi).Return([]model.Repository{
model.NewGithubRepository(1, repositoryName).AddVersion(model.DefaultPattern, repositoryVersion)}, uint64(1), nil)
model.NewGithubRepository(1, repositoryName).AddVersion(model.DefaultPattern, repositoryVersion),
}, uint64(1), nil)
mockRepositoryService.EXPECT().LatestVersions(gomock.Any()).Return(nil, errors.New("failed"))
case "same version":
mockRepositoryService.EXPECT().ListByKinds(gomock.Any(), gomock.Any(), gomock.Any(), model.Github, model.Docker, model.NPM, model.Pypi).Return([]model.Repository{
Expand Down Expand Up @@ -135,7 +136,7 @@ func TestGetNewHelmReleases(t *testing.T) {
content string
}

var cases = []struct {
cases := []struct {
intention string
instance App
args args
Expand Down
2 changes: 1 addition & 1 deletion pkg/provider/docker/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestGetNextURL(t *testing.T) {
lowerCaseHeader.Add("link", `rel="prev"; /v2/prev`)
lowerCaseHeader.Add("link", `rel="next"; /v2/next`)

var cases = []struct {
cases := []struct {
intention string
args args
want string
Expand Down
2 changes: 1 addition & 1 deletion pkg/provider/github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func TestFlags(t *testing.T) {
var cases = []struct {
cases := []struct {
intention string
want string
}{
Expand Down
3 changes: 1 addition & 2 deletions pkg/provider/helm/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ type chart struct {
}

// App of package
type App struct {
}
type App struct{}

// New creates new App from Config
func New() App {
Expand Down
3 changes: 1 addition & 2 deletions pkg/provider/npm/npm.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ type versionResp struct {
}

// App of package
type App struct {
}
type App struct{}

// New creates new App from Config
func New() App {
Expand Down
3 changes: 1 addition & 2 deletions pkg/provider/pypi/pypi.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ type packageResp struct {
}

// App of package
type App struct {
}
type App struct{}

// New creates new App
func New() App {
Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func TestFlags(t *testing.T) {
var cases = []struct {
cases := []struct {
intention string
want string
}{
Expand Down
2 changes: 1 addition & 1 deletion pkg/semver/pattern_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestCheck(t *testing.T) {
version Version
}

var cases = []struct {
cases := []struct {
intention string
instance Pattern
args args
Expand Down
Loading

0 comments on commit a6adffc

Please sign in to comment.