Skip to content

Commit b04f965

Browse files
committed
fixed linter issues
1 parent 7136c21 commit b04f965

File tree

23 files changed

+77
-96
lines changed

23 files changed

+77
-96
lines changed

cmd/limepipes-cli/cmd/common.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"github.com/rs/zerolog/log"
66
"github.com/spf13/cobra"
7-
"github.com/tomvodi/limepipes/cmd/limepipes-cli/import_type"
7+
"github.com/tomvodi/limepipes/cmd/limepipes-cli/importtype"
88
"io/fs"
99
"os"
1010
"path/filepath"
@@ -20,9 +20,9 @@ var (
2020

2121
func addImportFileTypes(cmd *cobra.Command) {
2222

23-
cmd.Flags().StringSliceVarP(&importTypes, "import-file-types", "i", []string{import_type.BWW.String()},
23+
cmd.Flags().StringSliceVarP(&importTypes, "import-file-types", "i", []string{importtype.BWW.String()},
2424
fmt.Sprintf("only import files of a specific type. Can be specified with a comma separated list like "+
25-
"-i=bww,xml. Valid file types are (%s).", strings.Join(import_type.TypeStrings(), ", ")),
25+
"-i=bww,xml. Valid file types are (%s).", strings.Join(importtype.TypeStrings(), ", ")),
2626
)
2727
}
2828

@@ -54,7 +54,7 @@ func hasInvalidImportTypes() []string {
5454
var invalidImportTypes []string
5555
for _, importType := range importTypes {
5656
isValidImportType := false
57-
for _, allImportType := range import_type.TypeStrings() {
57+
for _, allImportType := range importtype.TypeStrings() {
5858
if allImportType == importType {
5959
isValidImportType = true
6060
break

cmd/limepipes-cli/cmd/import.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/tomvodi/limepipes/internal/config"
1010
"github.com/tomvodi/limepipes/internal/database"
1111
"github.com/tomvodi/limepipes/internal/interfaces"
12-
"github.com/tomvodi/limepipes/internal/plugin_loader"
12+
"github.com/tomvodi/limepipes/internal/pluginloader"
1313
"github.com/tomvodi/limepipes/internal/utils"
1414
"gorm.io/gorm"
1515
"os"
@@ -30,14 +30,14 @@ subdirectories when given the recursive flag.
3030
If a given file that has an extension which is not in the import-file-types, it will be ignored.
3131
`,
3232
Args: cobra.MinimumNArgs(1),
33-
RunE: func(cmd *cobra.Command, args []string) error {
33+
RunE: func(_ *cobra.Command, args []string) error {
3434
utils.SetupConsoleLogger()
3535
cfg, err := config.Init()
3636
if err != nil {
3737
return fmt.Errorf("failed init configuration: %s", err.Error())
3838
}
3939

40-
pluginLoader := plugin_loader.NewPluginLoader()
40+
pluginLoader := pluginloader.NewPluginLoader()
4141
err = pluginLoader.LoadPluginsFromDir(cfg.PluginsDirectoryPath)
4242
if err != nil {
4343
log.Fatal().Err(err).Msg("failed loading plugins")
@@ -77,9 +77,9 @@ If a given file that has an extension which is not in the import-file-types, it
7777
if skipFailedFiles {
7878
log.Error().Err(err).Msgf("import file %s does not have an extension", file)
7979
continue
80-
} else {
81-
return err
8280
}
81+
82+
return err
8383
}
8484

8585
filePlugin, err := pluginLoader.PluginForFileExtension(".bww")
@@ -88,19 +88,19 @@ If a given file that has an extension which is not in the import-file-types, it
8888
log.Error().Err(err).Msgf("failed getting plugin for file %s with extension %s",
8989
file, fExt)
9090
continue
91-
} else {
92-
return err
9391
}
92+
93+
return err
9494
}
9595

9696
fileData, err := os.ReadFile(file)
9797
if err != nil {
9898
if skipFailedFiles {
9999
log.Error().Err(err).Msgf("failed reading file %s", file)
100100
continue
101-
} else {
102-
return err
103101
}
102+
103+
return err
104104
}
105105

106106
log.Info().Msgf("importing file %d/%d %s", i+1, allFileCnt, file)
@@ -110,9 +110,9 @@ If a given file that has an extension which is not in the import-file-types, it
110110
if skipFailedFiles {
111111
log.Error().Err(err).Msgf("failed parsing file %s", file)
112112
continue
113-
} else {
114-
return fmt.Errorf("failed parsing file %s: %v", file, err)
115113
}
114+
115+
return fmt.Errorf("failed parsing file %s: %v", file, err)
116116
}
117117

118118
if verbose {
@@ -130,29 +130,29 @@ If a given file that has an extension which is not in the import-file-types, it
130130
log.Error().Err(err).Msgf("failed getting file type for file %s with extension %s",
131131
file, fExt)
132132
continue
133-
} else {
134-
return err
135133
}
134+
135+
return err
136136
}
137137

138138
fInfo, err := common.NewImportFileInfoFromLocalFile(file, fType)
139139
if err != nil {
140140
if skipFailedFiles {
141141
log.Error().Err(err).Msg("failed creating import file info")
142142
continue
143-
} else {
144-
return err
145143
}
144+
145+
return err
146146
}
147147

148148
_, _, err = dbService.ImportTunes(tunesImport.ImportedTunes, fInfo)
149149
if err != nil {
150150
if skipFailedFiles {
151151
log.Error().Err(err).Msg("failed importing tunes")
152152
continue
153-
} else {
154-
return fmt.Errorf("failed importing tunes: %s", err.Error())
155153
}
154+
155+
return fmt.Errorf("failed importing tunes: %s", err.Error())
156156
}
157157
}
158158

cmd/limepipes-cli/cmd/parser.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/spf13/cobra"
77
"github.com/tomvodi/limepipes/internal/config"
88
"github.com/tomvodi/limepipes/internal/interfaces"
9-
"github.com/tomvodi/limepipes/internal/plugin_loader"
9+
"github.com/tomvodi/limepipes/internal/pluginloader"
1010
"github.com/tomvodi/limepipes/internal/utils"
1111
"os"
1212
"path/filepath"
@@ -27,7 +27,7 @@ var parserCmd = &cobra.Command{
2727
When given directory paths, it will import all files of that directory. It will also include
2828
subdirectories when given the recursive flag.
2929
If a given file that has an extension which is not in the import-file-types, it will be ignored.`,
30-
RunE: func(cmd *cobra.Command, args []string) error {
30+
RunE: func(_ *cobra.Command, args []string) error {
3131
utils.SetupConsoleLogger()
3232
err := checkForInvalidImportTypes()
3333
if err != nil {
@@ -39,7 +39,7 @@ If a given file that has an extension which is not in the import-file-types, it
3939
return fmt.Errorf("failed init configuration: %s", err.Error())
4040
}
4141

42-
pluginLoader := plugin_loader.NewPluginLoader()
42+
pluginLoader := pluginloader.NewPluginLoader()
4343
err = pluginLoader.LoadPluginsFromDir(cfg.PluginsDirectoryPath)
4444
if err != nil {
4545
log.Fatal().Err(err).Msg("failed loading plugins")
@@ -98,9 +98,9 @@ If a given file that has an extension which is not in the import-file-types, it
9898
if skipFailedFiles {
9999
log.Error().Err(err).Msgf("failed parsing file %s", file)
100100
continue
101-
} else {
102-
return fmt.Errorf("failed parsing file %s: %v", file, err)
103101
}
102+
103+
return fmt.Errorf("failed parsing file %s: %v", file, err)
104104
}
105105

106106
if err == nil {

cmd/limepipes-cli/import_type/import_type.go renamed to cmd/limepipes-cli/importtype/import_type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package import_type
1+
package importtype
22

33
//go:generate go run github.com/dmarkham/enumer -type=Type -transform=snake
44

cmd/limepipes-cli/import_type/type_enumer.go renamed to cmd/limepipes-cli/importtype/type_enumer.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/limepipes/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/tomvodi/limepipes/internal/database"
1212
"github.com/tomvodi/limepipes/internal/health"
1313
"github.com/tomvodi/limepipes/internal/interfaces"
14-
"github.com/tomvodi/limepipes/internal/plugin_loader"
14+
"github.com/tomvodi/limepipes/internal/pluginloader"
1515
"github.com/tomvodi/limepipes/internal/utils"
1616
"gorm.io/gorm"
1717
)
@@ -35,7 +35,7 @@ func main() {
3535
log.Fatal().Err(err).Msg("failed init configuration")
3636
}
3737

38-
pluginLoader := plugin_loader.NewPluginLoader()
38+
pluginLoader := pluginloader.NewPluginLoader()
3939
err = pluginLoader.LoadPluginsFromDir(cfg.PluginsDirectoryPath)
4040
if err != nil {
4141
log.Fatal().Err(err).Msg("failed loading plugins")
@@ -73,6 +73,6 @@ func main() {
7373
},
7474
)
7575

76-
log.Info().Msgf("listening on %s", cfg.ServerUrl)
77-
log.Fatal().Err(router.RunTLS(cfg.ServerUrl, cfg.TlsCertPath, cfg.TlsCertKeyPath))
76+
log.Info().Msgf("listening on %s", cfg.ServerURL)
77+
log.Fatal().Err(router.RunTLS(cfg.ServerURL, cfg.TLSCertPath, cfg.TLSCertKeyPath))
7878
}

internal/api/api_model_validator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func (v *apiModelValidator) ValidateUpdateSet(setUpd apimodel.UpdateSet) error {
2020

2121
func NewAPIModelValidator(
2222
validator *validator.Validate,
23-
) interfaces.ApiModelValidator {
23+
) interfaces.APIModelValidator {
2424
return &apiModelValidator{
2525
validator: validator,
2626
}

internal/config/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package config
22

33
type Config struct {
4-
ServerUrl string `mapstructure:"API_SERVER_URL"`
4+
ServerURL string `mapstructure:"API_SERVER_URL"`
55

6-
TlsCertPath string `mapstructure:"TLS_CERT_PATH"`
7-
TlsCertKeyPath string `mapstructure:"TLS_CERT_KEY_PATH"`
6+
TLSCertPath string `mapstructure:"TLS_CERT_PATH"`
7+
TLSCertKeyPath string `mapstructure:"TLS_CERT_KEY_PATH"`
88

99
DbHost string `mapstructure:"DB_HOST"`
1010
DbPort string `mapstructure:"DB_PORT"`

internal/database/db_data_service.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222

2323
type dbService struct {
2424
db *gorm.DB
25-
validator interfaces.ApiModelValidator
25+
validator interfaces.APIModelValidator
2626
}
2727

2828
func (d *dbService) Tunes() ([]*apimodel.Tune, error) {
@@ -49,7 +49,7 @@ func (d *dbService) CreateTune(
4949

5050
dbTune := model.Tune{}
5151
if importFile != nil {
52-
dbTune.ImportFileId = importFile.ID
52+
dbTune.ImportFileID = importFile.ID
5353
}
5454
var tuneType *model.TuneType
5555
var err error
@@ -65,7 +65,7 @@ func (d *dbService) CreateTune(
6565
return &apimodel.Tune{}, fmt.Errorf("could not create db object")
6666
}
6767
if tuneType != nil {
68-
dbTune.TuneTypeId = &tuneType.ID
68+
dbTune.TuneTypeID = &tuneType.ID
6969
}
7070

7171
if err = d.db.Create(&dbTune).Error; err != nil {
@@ -162,7 +162,7 @@ func (d *dbService) UpdateTune(id uuid.UUID, updateTune apimodel.UpdateTune) (*a
162162
if err := mapstructure.Decode(&updateTune, &updateVals); err != nil {
163163
return nil, err
164164
}
165-
updateVals["TuneTypeId"] = tuneType.ID
165+
updateVals["TuneTypeID"] = tuneType.ID
166166
delete(updateVals, "Type")
167167

168168
if err := d.db.Model(t).Updates(updateVals).Error; err != nil {
@@ -263,7 +263,7 @@ func (d *dbService) CreateMusicSet(
263263

264264
dbSet := model.MusicSet{}
265265
if importFile != nil {
266-
dbSet.ImportFileId = importFile.ID
266+
dbSet.ImportFileID = importFile.ID
267267
}
268268
if err := copier.Copy(&dbSet, &musicSet); err != nil {
269269
return &apimodel.MusicSet{}, fmt.Errorf("could not create db object")
@@ -903,7 +903,7 @@ func (d *dbService) DeleteFileFromTune(tuneID uuid.UUID, fType file_type.Type) e
903903

904904
func NewDbDataService(
905905
db *gorm.DB,
906-
validator interfaces.ApiModelValidator,
906+
validator interfaces.APIModelValidator,
907907
) interfaces.DataService {
908908
return &dbService{
909909
db: db,

internal/database/model/base_model.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
)
77

88
type BaseModel struct {
9-
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid()" copier:"Id"`
9+
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid()" copier:"ID"`
1010
CreatedAt sqltime.Time `gorm:"type:timestamp"`
1111
UpdatedAt sqltime.Time `gorm:"type:timestamp"`
1212
}

internal/database/model/music_set.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ type MusicSet struct {
88
Description string
99
Creator string
1010
Tunes []Tune `gorm:"many2many:music_set_tunes;constraint:OnUpdate:CASCADE;OnDelete:RESTRICT"`
11-
ImportFileId uuid.UUID
11+
ImportFileID uuid.UUID
1212
}

internal/database/model/tune.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import "github.com/google/uuid"
55
type Tune struct {
66
BaseModel
77
Title string
8-
TuneTypeId *uuid.UUID
8+
TuneTypeID *uuid.UUID
99
TuneType *TuneType
1010
TimeSig string
1111
Composer string
1212
Arranger string
1313
Sets []MusicSet `gorm:"many2many:music_set_tunes;constraint:OnUpdate:CASCADE;"`
1414
Files []*TuneFile `gorm:"constraint:OnDelete:CASCADE;"`
15-
ImportFileId uuid.UUID
15+
ImportFileID uuid.UUID
1616
}

internal/exporter/musicxml/musicxml_exporter.go

Lines changed: 0 additions & 19 deletions
This file was deleted.

internal/health/health.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (h *healthCheck) init() error {
4848
},
4949
),
5050
healthlib.WithStatusListener(
51-
func(ctx context.Context, state healthlib.CheckerState) {
51+
func(_ context.Context, state healthlib.CheckerState) {
5252
log.Info().Msgf(
5353
fmt.Sprintf("health status changed to %s", state.Status),
5454
)

internal/interfaces/api_model_validator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package interfaces
22

33
import "github.com/tomvodi/limepipes/internal/apigen/apimodel"
44

5-
type ApiModelValidator interface {
5+
type APIModelValidator interface {
66
ValidateUpdateTune(tuneUpd apimodel.UpdateTune) error
77
ValidateUpdateSet(tuneUpd apimodel.UpdateSet) error
88
}

internal/interfaces/api_router.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ package interfaces
22

33
import "github.com/gin-gonic/gin"
44

5-
type ApiRouter interface {
5+
type APIRouter interface {
66
GetEngine() *gin.Engine
77
}

internal/interfaces/data_service.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@ type DataService interface {
1616
UpdateTune(id uuid.UUID, tune apimodel.UpdateTune) (*apimodel.Tune, error)
1717
DeleteTune(id uuid.UUID) error
1818

19-
AddFileToTune(tuneId uuid.UUID, tFile *model.TuneFile) error
20-
DeleteFileFromTune(tuneId uuid.UUID, fType file_type.Type) error
21-
GetTuneFile(tuneId uuid.UUID, fType file_type.Type) (*model.TuneFile, error)
22-
GetTuneFiles(tuneId uuid.UUID) ([]*model.TuneFile, error)
19+
AddFileToTune(tuneID uuid.UUID, tFile *model.TuneFile) error
20+
DeleteFileFromTune(tuneID uuid.UUID, fType file_type.Type) error
21+
GetTuneFile(tuneID uuid.UUID, fType file_type.Type) (*model.TuneFile, error)
22+
GetTuneFiles(tuneID uuid.UUID) ([]*model.TuneFile, error)
2323

2424
MusicSets() ([]*apimodel.MusicSet, error)
2525
CreateMusicSet(tune apimodel.CreateSet, importFile *model.ImportFile) (*apimodel.MusicSet, error)
2626
GetMusicSet(id uuid.UUID) (*apimodel.MusicSet, error)
2727
UpdateMusicSet(id uuid.UUID, tune apimodel.UpdateSet) (*apimodel.MusicSet, error)
2828
DeleteMusicSet(id uuid.UUID) error
2929

30-
AssignTunesToMusicSet(setId uuid.UUID, tuneIds []uuid.UUID) (*apimodel.MusicSet, error)
30+
AssignTunesToMusicSet(setID uuid.UUID, tuneIDs []uuid.UUID) (*apimodel.MusicSet, error)
3131

3232
GetImportFileByHash(fHash string) (*model.ImportFile, error)
3333
ImportTunes(

0 commit comments

Comments
 (0)