From a60047e3906994d8daaf0f033b56674e4c444dd0 Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Wed, 20 Dec 2023 13:30:27 -0600 Subject: [PATCH] linter autofix --- backend/app/api/handlers/v1/v1_ctrl_group.go | 2 +- backend/app/api/handlers/v1/v1_ctrl_items.go | 1 - backend/app/api/handlers/v1/v1_ctrl_items_attachments.go | 1 - backend/internal/data/repo/repo_items.go | 8 ++++---- backend/internal/data/repo/repo_items_test.go | 1 - backend/internal/data/repo/repo_labels.go | 4 ++-- backend/internal/data/repo/repo_locations.go | 4 ++-- backend/internal/data/repo/repo_maintenance_entry.go | 3 +-- backend/internal/data/repo/repo_notifier.go | 8 ++++---- backend/internal/data/repo/repo_tokens_test.go | 1 - backend/internal/sys/config/conf.go | 6 +++--- backend/internal/sys/config/conf_database.go | 2 +- backend/internal/sys/validate/validate.go | 1 - 13 files changed, 18 insertions(+), 24 deletions(-) diff --git a/backend/app/api/handlers/v1/v1_ctrl_group.go b/backend/app/api/handlers/v1/v1_ctrl_group.go index 8b1624d..45a8557 100644 --- a/backend/app/api/handlers/v1/v1_ctrl_group.go +++ b/backend/app/api/handlers/v1/v1_ctrl_group.go @@ -12,7 +12,7 @@ import ( type ( GroupInvitationCreate struct { - Uses int `json:"uses" validate:"required,min=1,max=100"` + Uses int `json:"uses" validate:"required,min=1,max=100"` ExpiresAt time.Time `json:"expiresAt"` } diff --git a/backend/app/api/handlers/v1/v1_ctrl_items.go b/backend/app/api/handlers/v1/v1_ctrl_items.go index 55919f8..6666cc1 100644 --- a/backend/app/api/handlers/v1/v1_ctrl_items.go +++ b/backend/app/api/handlers/v1/v1_ctrl_items.go @@ -233,7 +233,6 @@ func (ctrl *V1Controller) HandleGetAllCustomFieldValues() errchain.HandlerFunc { } return adapters.Query(fn, http.StatusOK) - } // HandleItemsImport godocs diff --git a/backend/app/api/handlers/v1/v1_ctrl_items_attachments.go b/backend/app/api/handlers/v1/v1_ctrl_items_attachments.go index 12bbbb5..c4ac672 100644 --- a/backend/app/api/handlers/v1/v1_ctrl_items_attachments.go +++ b/backend/app/api/handlers/v1/v1_ctrl_items_attachments.go @@ -39,7 +39,6 @@ func (ctrl *V1Controller) HandleItemAttachmentCreate() errchain.HandlerFunc { if err != nil { log.Err(err).Msg("failed to parse multipart form") return validate.NewRequestError(errors.New("failed to parse multipart form"), http.StatusBadRequest) - } errs := validate.NewFieldErrors() diff --git a/backend/internal/data/repo/repo_items.go b/backend/internal/data/repo/repo_items.go index 6358a98..06984f5 100644 --- a/backend/internal/data/repo/repo_items.go +++ b/backend/internal/data/repo/repo_items.go @@ -55,8 +55,8 @@ type ( ItemCreate struct { ImportRef string `json:"-"` - ParentID uuid.UUID `json:"parentId" extensions:"x-nullable"` - Name string `json:"name" validate:"required,min=1,max=255"` + ParentID uuid.UUID `json:"parentId" extensions:"x-nullable"` + Name string `json:"name" validate:"required,min=1,max=255"` Description string `json:"description" validate:"max=1000"` AssetID AssetID `json:"-"` @@ -66,7 +66,7 @@ type ( } ItemUpdate struct { - ParentID uuid.UUID `json:"parentId" extensions:"x-nullable,x-omitempty"` + ParentID uuid.UUID `json:"parentId" extensions:"x-nullable,x-omitempty"` ID uuid.UUID `json:"id"` AssetID AssetID `json:"assetId"` Name string `json:"name"` @@ -108,7 +108,7 @@ type ( ItemPatch struct { ID uuid.UUID `json:"id"` Quantity *int `json:"quantity,omitempty" extensions:"x-nullable,x-omitempty"` - ImportRef *string `json:"-,omitempty" extensions:"x-nullable,x-omitempty"` + ImportRef *string `json:"-,omitempty" extensions:"x-nullable,x-omitempty"` } ItemSummary struct { diff --git a/backend/internal/data/repo/repo_items_test.go b/backend/internal/data/repo/repo_items_test.go index ba991f9..d4d067c 100644 --- a/backend/internal/data/repo/repo_items_test.go +++ b/backend/internal/data/repo/repo_items_test.go @@ -77,7 +77,6 @@ func TestItemsRepository_RecursiveRelationships(t *testing.T) { updated, err = tRepos.Items.GetOne(context.Background(), child.ID) assert.NoError(t, err) assert.Nil(t, updated.Parent) - } } diff --git a/backend/internal/data/repo/repo_labels.go b/backend/internal/data/repo/repo_labels.go index 4de1a9e..ea7b4a3 100644 --- a/backend/internal/data/repo/repo_labels.go +++ b/backend/internal/data/repo/repo_labels.go @@ -19,14 +19,14 @@ type LabelRepository struct { type ( LabelCreate struct { - Name string `json:"name" validate:"required,min=1,max=255"` + Name string `json:"name" validate:"required,min=1,max=255"` Description string `json:"description" validate:"max=255"` Color string `json:"color"` } LabelUpdate struct { ID uuid.UUID `json:"id"` - Name string `json:"name" validate:"required,min=1,max=255"` + Name string `json:"name" validate:"required,min=1,max=255"` Description string `json:"description" validate:"max=255"` Color string `json:"color"` } diff --git a/backend/internal/data/repo/repo_locations.go b/backend/internal/data/repo/repo_locations.go index c826ebe..e4d8710 100644 --- a/backend/internal/data/repo/repo_locations.go +++ b/backend/internal/data/repo/repo_locations.go @@ -21,12 +21,12 @@ type LocationRepository struct { type ( LocationCreate struct { Name string `json:"name"` - ParentID uuid.UUID `json:"parentId" extensions:"x-nullable"` + ParentID uuid.UUID `json:"parentId" extensions:"x-nullable"` Description string `json:"description"` } LocationUpdate struct { - ParentID uuid.UUID `json:"parentId" extensions:"x-nullable"` + ParentID uuid.UUID `json:"parentId" extensions:"x-nullable"` ID uuid.UUID `json:"id"` Name string `json:"name"` Description string `json:"description"` diff --git a/backend/internal/data/repo/repo_maintenance_entry.go b/backend/internal/data/repo/repo_maintenance_entry.go index b699d09..2714bbd 100644 --- a/backend/internal/data/repo/repo_maintenance_entry.go +++ b/backend/internal/data/repo/repo_maintenance_entry.go @@ -23,7 +23,7 @@ type MaintenanceEntryRepository struct { type MaintenanceEntryCreate struct { CompletedDate types.Date `json:"completedDate"` ScheduledDate types.Date `json:"scheduledDate"` - Name string `json:"name" validate:"required"` + Name string `json:"name" validate:"required"` Description string `json:"description"` Cost float64 `json:"cost,string"` } @@ -152,7 +152,6 @@ func (r *MaintenanceEntryRepository) GetLog(ctx context.Context, groupID, itemID maintenanceentry.DateNotNil(), maintenanceentry.DateNEQ(time.Time{}), )) - } else if query.Scheduled { q = q.Where(maintenanceentry.And( maintenanceentry.Or( diff --git a/backend/internal/data/repo/repo_notifier.go b/backend/internal/data/repo/repo_notifier.go index 2ea27eb..f31be4b 100644 --- a/backend/internal/data/repo/repo_notifier.go +++ b/backend/internal/data/repo/repo_notifier.go @@ -35,15 +35,15 @@ func NewNotifierRepository(db *ent.Client) *NotifierRepository { type ( NotifierCreate struct { - Name string `json:"name" validate:"required,min=1,max=255"` + Name string `json:"name" validate:"required,min=1,max=255"` IsActive bool `json:"isActive"` - URL string `json:"url" validate:"required,shoutrrr"` + URL string `json:"url" validate:"required,shoutrrr"` } NotifierUpdate struct { - Name string `json:"name" validate:"required,min=1,max=255"` + Name string `json:"name" validate:"required,min=1,max=255"` IsActive bool `json:"isActive"` - URL *string `json:"url" validate:"omitempty,shoutrrr" extensions:"x-nullable" ` + URL *string `json:"url" validate:"omitempty,shoutrrr" extensions:"x-nullable"` } NotifierOut struct { diff --git a/backend/internal/data/repo/repo_tokens_test.go b/backend/internal/data/repo/repo_tokens_test.go index e066911..43b6c14 100644 --- a/backend/internal/data/repo/repo_tokens_test.go +++ b/backend/internal/data/repo/repo_tokens_test.go @@ -116,7 +116,6 @@ func TestAuthTokenRepo_PurgeExpiredTokens(t *testing.T) { assert.NotNil(createdToken) createdTokens = append(createdTokens, createdToken) - } // Purge expired tokens diff --git a/backend/internal/sys/config/conf.go b/backend/internal/sys/config/conf.go index 28c278d..90fa6f4 100644 --- a/backend/internal/sys/config/conf.go +++ b/backend/internal/sys/config/conf.go @@ -16,7 +16,7 @@ const ( type Config struct { conf.Version - Mode string `yaml:"mode" conf:"default:development"` // development or production + Mode string `yaml:"mode" conf:"default:development"` // development or production Web WebConfig `yaml:"web"` Storage Storage `yaml:"storage"` Log LoggerConf `yaml:"logger"` @@ -27,13 +27,13 @@ type Config struct { } type Options struct { - AllowRegistration bool `yaml:"disable_registration" conf:"default:true"` + AllowRegistration bool `yaml:"disable_registration" conf:"default:true"` AutoIncrementAssetID bool `yaml:"auto_increment_asset_id" conf:"default:true"` } type DebugConf struct { Enabled bool `yaml:"enabled" conf:"default:false"` - Port string `yaml:"port" conf:"default:4000"` + Port string `yaml:"port" conf:"default:4000"` } type WebConfig struct { diff --git a/backend/internal/sys/config/conf_database.go b/backend/internal/sys/config/conf_database.go index 76d0ba2..9b92d45 100644 --- a/backend/internal/sys/config/conf_database.go +++ b/backend/internal/sys/config/conf_database.go @@ -6,6 +6,6 @@ const ( type Storage struct { // Data is the path to the root directory - Data string `yaml:"data" conf:"default:./.data"` + Data string `yaml:"data" conf:"default:./.data"` SqliteUrl string `yaml:"sqlite-url" conf:"default:./.data/homebox.db?_pragma=busy_timeout=1000&_pragma=journal_mode=WAL&_fk=1"` } diff --git a/backend/internal/sys/validate/validate.go b/backend/internal/sys/validate/validate.go index e10a646..98daa62 100644 --- a/backend/internal/sys/validate/validate.go +++ b/backend/internal/sys/validate/validate.go @@ -52,7 +52,6 @@ func init() { if err != nil { panic(err) } - } // Checks a struct for validation errors and returns any errors the occur. This