Skip to content

Commit dd762bd

Browse files
committed
fixed linter issues with ireturn
1 parent b9e28fe commit dd762bd

File tree

9 files changed

+97
-98
lines changed

9 files changed

+97
-98
lines changed

internal/api/api_model_validator.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,24 @@ package api
33
import (
44
"github.com/go-playground/validator/v10"
55
"github.com/tomvodi/limepipes/internal/apigen/apimodel"
6-
"github.com/tomvodi/limepipes/internal/interfaces"
76
)
87

9-
type apiModelValidator struct {
8+
type ModelValidator struct {
109
validator *validator.Validate
1110
}
1211

13-
func (v *apiModelValidator) ValidateUpdateTune(tuneUpd apimodel.UpdateTune) error {
12+
func (v *ModelValidator) ValidateUpdateTune(tuneUpd apimodel.UpdateTune) error {
1413
return v.validator.Struct(tuneUpd)
1514
}
1615

17-
func (v *apiModelValidator) ValidateUpdateSet(setUpd apimodel.UpdateSet) error {
16+
func (v *ModelValidator) ValidateUpdateSet(setUpd apimodel.UpdateSet) error {
1817
return v.validator.Struct(setUpd)
1918
}
2019

2120
func NewAPIModelValidator(
2221
validator *validator.Validate,
23-
) interfaces.APIModelValidator {
24-
return &apiModelValidator{
22+
) *ModelValidator {
23+
return &ModelValidator{
2524
validator: validator,
2625
}
2726
}

internal/api/handler.go

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/google/uuid"
88
"github.com/tomvodi/limepipes-plugin-api/plugin/v1/file_type"
99
"github.com/tomvodi/limepipes/internal/apigen/apimodel"
10-
api_interfaces "github.com/tomvodi/limepipes/internal/apigen/interfaces"
1110
"github.com/tomvodi/limepipes/internal/common"
1211
"github.com/tomvodi/limepipes/internal/interfaces"
1312
"io"
@@ -16,17 +15,17 @@ import (
1615
"path/filepath"
1716
)
1817

19-
type apiHandler struct {
18+
type Handler struct {
2019
service interfaces.DataService
2120
pluginLoader interfaces.PluginLoader
2221
healthChecker interfaces.HealthChecker
2322
}
2423

25-
func (a *apiHandler) Home(c *gin.Context) {
24+
func (a *Handler) Home(c *gin.Context) {
2625
c.Status(http.StatusOK)
2726
}
2827

29-
func (a *apiHandler) Health(c *gin.Context) {
28+
func (a *Handler) Health(c *gin.Context) {
3029
handler, err := a.healthChecker.GetCheckHandler()
3130
if err != nil {
3231
httpErrorResponse(c, http.StatusInternalServerError, err)
@@ -37,7 +36,7 @@ func (a *apiHandler) Health(c *gin.Context) {
3736
handleFunc(c)
3837
}
3938

40-
func (a *apiHandler) ImportFile(c *gin.Context) {
39+
func (a *Handler) ImportFile(c *gin.Context) {
4140
iFile, err := c.FormFile("file")
4241
if err != nil {
4342
httpErrorResponse(c, http.StatusBadRequest, err)
@@ -95,7 +94,7 @@ func (a *apiHandler) ImportFile(c *gin.Context) {
9594
c.JSON(http.StatusOK, importResponse)
9695
}
9796

98-
func (a *apiHandler) createImportFileInfo(
97+
func (a *Handler) createImportFileInfo(
9998
iFile *multipart.FileHeader,
10099
fType file_type.Type,
101100
) (*common.ImportFileInfo, error) {
@@ -118,7 +117,7 @@ func (a *apiHandler) createImportFileInfo(
118117
return fInfo, nil
119118
}
120119

121-
func (a *apiHandler) importFile(
120+
func (a *Handler) importFile(
122121
fInfo *common.ImportFileInfo,
123122
fileExt string,
124123
) ([]*apimodel.ImportTune, *apimodel.BasicMusicSet, error) {
@@ -152,11 +151,11 @@ func handleResponseForError(c *gin.Context, err error) {
152151
})
153152
}
154153

155-
func (a *apiHandler) Index(c *gin.Context) {
154+
func (a *Handler) Index(c *gin.Context) {
156155
c.JSON(http.StatusOK, gin.H{})
157156
}
158157

159-
func (a *apiHandler) CreateTune(c *gin.Context) {
158+
func (a *Handler) CreateTune(c *gin.Context) {
160159
var createTune apimodel.CreateTune
161160
if err := c.ShouldBindJSON(&createTune); err != nil {
162161
httpErrorResponse(c, http.StatusBadRequest, err)
@@ -172,7 +171,7 @@ func (a *apiHandler) CreateTune(c *gin.Context) {
172171
c.JSON(http.StatusOK, tune)
173172
}
174173

175-
func (a *apiHandler) GetTune(c *gin.Context) {
174+
func (a *Handler) GetTune(c *gin.Context) {
176175
tuneID, err := uuid.Parse(c.Param("tuneID"))
177176
if err != nil {
178177
httpErrorResponse(c, http.StatusBadRequest, err)
@@ -188,7 +187,7 @@ func (a *apiHandler) GetTune(c *gin.Context) {
188187
c.JSON(http.StatusOK, tune)
189188
}
190189

191-
func (a *apiHandler) ListTunes(c *gin.Context) {
190+
func (a *Handler) ListTunes(c *gin.Context) {
192191
tunes, err := a.service.Tunes()
193192
if err != nil {
194193
httpErrorResponse(c, http.StatusInternalServerError, err)
@@ -197,7 +196,7 @@ func (a *apiHandler) ListTunes(c *gin.Context) {
197196
c.JSON(http.StatusOK, tunes)
198197
}
199198

200-
func (a *apiHandler) UpdateTune(c *gin.Context) {
199+
func (a *Handler) UpdateTune(c *gin.Context) {
201200
var updateTune apimodel.UpdateTune
202201
if err := c.ShouldBindJSON(&updateTune); err != nil {
203202
httpErrorResponse(c, http.StatusBadRequest, err)
@@ -219,7 +218,7 @@ func (a *apiHandler) UpdateTune(c *gin.Context) {
219218
c.JSON(http.StatusOK, tune)
220219
}
221220

222-
func (a *apiHandler) DeleteTune(c *gin.Context) {
221+
func (a *Handler) DeleteTune(c *gin.Context) {
223222
tuneID, err := uuid.Parse(c.Param("tuneID"))
224223
if err != nil {
225224
httpErrorResponse(c, http.StatusBadRequest, err)
@@ -234,7 +233,7 @@ func (a *apiHandler) DeleteTune(c *gin.Context) {
234233
c.Status(http.StatusNoContent)
235234
}
236235

237-
func (a *apiHandler) CreateSet(c *gin.Context) {
236+
func (a *Handler) CreateSet(c *gin.Context) {
238237
var createSet apimodel.CreateSet
239238

240239
if err := c.ShouldBindJSON(&createSet); err != nil {
@@ -251,7 +250,7 @@ func (a *apiHandler) CreateSet(c *gin.Context) {
251250
c.JSON(http.StatusOK, set)
252251
}
253252

254-
func (a *apiHandler) GetSet(c *gin.Context) {
253+
func (a *Handler) GetSet(c *gin.Context) {
255254
setID, err := uuid.Parse(c.Param("setID"))
256255
if err != nil {
257256
httpErrorResponse(c, http.StatusBadRequest, err)
@@ -267,7 +266,7 @@ func (a *apiHandler) GetSet(c *gin.Context) {
267266
c.JSON(http.StatusOK, set)
268267
}
269268

270-
func (a *apiHandler) ListSets(c *gin.Context) {
269+
func (a *Handler) ListSets(c *gin.Context) {
271270
sets, err := a.service.MusicSets()
272271
if err != nil {
273272
httpErrorResponse(c, http.StatusInternalServerError, err)
@@ -276,7 +275,7 @@ func (a *apiHandler) ListSets(c *gin.Context) {
276275
c.JSON(http.StatusOK, sets)
277276
}
278277

279-
func (a *apiHandler) UpdateSet(c *gin.Context) {
278+
func (a *Handler) UpdateSet(c *gin.Context) {
280279
var updateSet apimodel.UpdateSet
281280
if err := c.ShouldBindJSON(&updateSet); err != nil {
282281
httpErrorResponse(c, http.StatusBadRequest, err)
@@ -297,7 +296,7 @@ func (a *apiHandler) UpdateSet(c *gin.Context) {
297296
c.JSON(http.StatusOK, set)
298297
}
299298

300-
func (a *apiHandler) DeleteSet(c *gin.Context) {
299+
func (a *Handler) DeleteSet(c *gin.Context) {
301300
setID, err := uuid.Parse(c.Param("setID"))
302301
if err != nil {
303302
httpErrorResponse(c, http.StatusBadRequest, err)
@@ -312,7 +311,7 @@ func (a *apiHandler) DeleteSet(c *gin.Context) {
312311
c.Status(http.StatusNoContent)
313312
}
314313

315-
func (a *apiHandler) AssignTunesToSet(c *gin.Context) {
314+
func (a *Handler) AssignTunesToSet(c *gin.Context) {
316315
var tuneIDs []uuid.UUID
317316
if err := c.ShouldBindJSON(&tuneIDs); err != nil {
318317
httpErrorResponse(c, http.StatusBadRequest, err)
@@ -338,8 +337,8 @@ func NewAPIHandler(
338337
service interfaces.DataService,
339338
pluginLoader interfaces.PluginLoader,
340339
healthChecker interfaces.HealthChecker,
341-
) api_interfaces.ApiHandler {
342-
return &apiHandler{
340+
) *Handler {
341+
return &Handler{
343342
service: service,
344343
pluginLoader: pluginLoader,
345344
healthChecker: healthChecker,

internal/api/handler_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ type multipartRequest struct {
3333
HTTPMethod string
3434
}
3535

36-
var _ = Describe("Api handler", func() {
36+
var _ = Describe("Api Handler", func() {
3737
utils.SetupConsoleLogger()
3838
var c *gin.Context
3939
var httpRec *httptest.ResponseRecorder
40-
var api *apiHandler
40+
var api *Handler
4141
var testID1 uuid.UUID
4242
var dataService *mocks.DataService
4343
var pluginLoader *mocks.PluginLoader
@@ -51,7 +51,7 @@ var _ = Describe("Api handler", func() {
5151
dataService = mocks.NewDataService(GinkgoT())
5252
pluginLoader = mocks.NewPluginLoader(GinkgoT())
5353
lpPlugin = pmocks.NewLimePipesPlugin(GinkgoT())
54-
api = &apiHandler{
54+
api = &Handler{
5555
service: dataService,
5656
pluginLoader: pluginLoader,
5757
}

0 commit comments

Comments
 (0)