Skip to content

Commit

Permalink
refactor(lint): changes to fix lint and suppress dupl lint
Browse files Browse the repository at this point in the history
  • Loading branch information
l3uddz committed Jul 31, 2020
1 parent 1c8944e commit 5854b8a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 6 additions & 6 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,23 +106,23 @@ func initConfig() {
/* Private Helpers */

func parseValidateInputs(args []string) error {
var ok bool = false
var err error = nil

// validate pvr exists in config
pvrName = args[0]
lowerPvrName = strings.ToLower(pvrName)
pvrConfig, ok = config.Config.Pvr[pvrName]
pc, ok := config.Config.Pvr[pvrName]
if !ok {
return fmt.Errorf("no pvr configuration found for: %q", pvrName)
}

pvrConfig = pc

// init pvrObj
pvr, err = pvrObj.Get(pvrName, pvrConfig.Type, pvrConfig)
p, err := pvrObj.Get(pvrName, pvrConfig.Type, pvrConfig)
if err != nil {
return errors.WithMessage(err, "failed loading pvr object")
}

pvr = p
return nil
}

Expand All @@ -148,7 +148,7 @@ func searchForItems(searchItems []pvrObj.MediaItem, wantedType string) (bool, er
return false, errors.New("failed unexpectedly searching for items")
} else {
// update search items lastsearch time
for pos, _ := range searchItems {
for pos := range searchItems {
(&searchItems[pos]).LastSearch = searchTime
}

Expand Down
4 changes: 3 additions & 1 deletion database/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

func DeleteMissingItems(pvrName string, wantedType string, newMediaItems []pvr.MediaItem) (int, error) {
// build slice of new item ids
newItemIds := make(map[int]*string, 0)
newItemIds := make(map[int]*string)

for _, item := range newMediaItems {
newItemIds[item.ItemId] = nil
Expand All @@ -29,6 +29,8 @@ func DeleteMissingItems(pvrName string, wantedType string, newMediaItems []pvr.M

for _, item := range dbItems {
if _, ok := newItemIds[item.Id]; !ok {
item := item

// item no longer exists
if err := tx.Unscoped().Delete(&item).Error; err != nil {
tx.Rollback()
Expand Down

0 comments on commit 5854b8a

Please sign in to comment.