Skip to content

Commit

Permalink
chore: remove some lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
waynezhang committed Jan 5, 2024
1 parent 417e3ed commit 84977ae
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 26 deletions.
2 changes: 1 addition & 1 deletion internal/cache/file_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (cache folderCache) Clear() {
if !files.IsExisting(dir) {
log.Warn().Msgf("Failed to find cache directory %s.", dir)
}
files.PruneDirectory(dir)
_ = files.PruneDirectory(dir)
}

func (cache folderCache) imagePath(checksum string, width int) string {
Expand Down
6 changes: 3 additions & 3 deletions internal/config/file_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ func NewFileConfig(file string) Config {

config := fileConfig{v: v}

v.UnmarshalKey("section", &config.sections)
v.UnmarshalKey("image", &config.option)
v.UnmarshalKey("others.folders", &config.otherFolders)
_ = v.UnmarshalKey("section", &config.sections)
_ = v.UnmarshalKey("image", &config.option)
_ = v.UnmarshalKey("others.folders", &config.otherFolders)

log.Debug().Msgf("Config parsed: %v", config)

Expand Down
10 changes: 4 additions & 6 deletions internal/export/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"github.com/waynezhang/foto/internal/utils"
)

func Export(outputPath string, minimize bool) error {
return export(
func Export(outputPath string, minimize bool) {
export(
config.Shared(),
outputPath,
minimizer(minimize),
Expand Down Expand Up @@ -57,7 +57,7 @@ func export(
minimizer mm.Minimizer,
cache cache.Cache,
ctx context,
) error {
) {
sm := ysmrr.NewSpinnerManager(
ysmrr.WithAnimation(animations.Dots),
)
Expand All @@ -79,7 +79,7 @@ func export(
photosDirectory := files.OutputPhotosFilePath(outputPath)
section, err := ctx.buildIndex(cfg)
if err != nil {
ctx.cleanDirectory(outputPath)
_ = ctx.cleanDirectory(outputPath)
utils.CheckFatalError(err, "Failed to build index.")
}

Expand All @@ -99,8 +99,6 @@ func export(

spinner.Complete()
sm.Stop()

return nil
}

func minimizer(minimize bool) mm.Minimizer {
Expand Down
12 changes: 6 additions & 6 deletions internal/export/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ func TestExport(t *testing.T) {

var section1 indexer.Section
var section2 indexer.Section
mapstructure.Decode(testdata.Collection1, &section1)
mapstructure.Decode(testdata.Collection1, &section2)
_ = mapstructure.Decode(testdata.Collection1, &section1)
_ = mapstructure.Decode(testdata.Collection1, &section2)
sections := []indexer.Section{section1, section2}

mockCtx := new(MockContext)
Expand All @@ -150,7 +150,7 @@ func TestExport(t *testing.T) {
cfg := new(MockConfig)
cfg.On("GetOtherFolders").Return([]string{"folder-1", "folder-2"})
outputPath := "test-directory"
export(cfg, outputPath, minimizer, cache, mockCtx)
_ = export(cfg, outputPath, minimizer, cache, mockCtx)

Check failure on line 153 in internal/export/export_test.go

View workflow job for this annotation

GitHub Actions / Test

export(cfg, outputPath, minimizer, cache, mockCtx) (no value) used as value

mockCtx.AssertCalled(t, "cleanDirectory", outputPath)
mockCtx.AssertCalled(t, "buildIndex", cfg)
Expand All @@ -164,7 +164,7 @@ func TestCleanDirectory(t *testing.T) {
defer os.RemoveAll(tmp)

ctx := defaultExportContext{}
ctx.cleanDirectory(tmp)
_ = ctx.cleanDirectory(tmp)
assert.False(t, files.IsExisting(tmp))
}

Expand All @@ -174,8 +174,8 @@ func TestExportPhotos(t *testing.T) {

var section1 indexer.Section
var section2 indexer.Section
mapstructure.Decode(testdata.Collection1, &section1)
mapstructure.Decode(testdata.Collection1, &section2)
_ = mapstructure.Decode(testdata.Collection1, &section1)
_ = mapstructure.Decode(testdata.Collection1, &section2)
sections := []indexer.Section{section1, section2}

mockFunc := new(MockFunc)
Expand Down
8 changes: 4 additions & 4 deletions internal/files/directory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ func TestDirectoryManipulating(t *testing.T) {
assert.True(t, IsExisting(tmp))

dir1 := filepath.Join(tmp, "parent1", "child1")
EnsureDirectory(dir1)
_ = EnsureDirectory(dir1)
assert.True(t, IsExisting(dir1))

// no failure to create existing directory
EnsureParentDirectory(dir1)
_ = EnsureParentDirectory(dir1)
assert.True(t, IsExisting(dir1))

dir2Parent := filepath.Join(tmp, "parent2")
dir2 := filepath.Join(dir2Parent, "child2")
EnsureParentDirectory(dir2)
_ = EnsureParentDirectory(dir2)
assert.True(t, IsExisting(dir2Parent))
assert.False(t, IsExisting(dir2))

PruneDirectory(tmp)
_ = PruneDirectory(tmp)
assert.False(t, IsExisting(tmp))
}

Expand Down
4 changes: 2 additions & 2 deletions internal/images/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestGetPhotoSize(t *testing.T) {
assert.Equal(t, testdata.TestfileHeight, size.Height)

// test against image with orientation data
size, err = GetPhotoSize(testdata.RotatedImageFile)
size, _ = GetPhotoSize(testdata.RotatedImageFile)
assert.Equal(t, testdata.RotatedImageWidth, size.Width)
assert.Equal(t, testdata.RotatedImageHeight, size.Height)

Expand All @@ -49,7 +49,7 @@ func TestResizeImage(t *testing.T) {
err = ResizeImage(testdata.Testfile, path, testdata.ThumbnailWidth)
assert.Nil(t, err)

checksum, err := files.Checksum(path)
checksum, _ := files.Checksum(path)
assert.Equal(t, testdata.ExpectedThubmnailChecksum, *checksum)
}

Expand Down
8 changes: 4 additions & 4 deletions internal/indexer/indexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func TestValidSlug(t *testing.T) {
func TestBuild(t *testing.T) {
var meta1 config.SectionMetadata
var meta2 config.SectionMetadata
mapstructure.Decode(testdata.Collection1, &meta1)
mapstructure.Decode(testdata.Collection2, &meta2)
_ = mapstructure.Decode(testdata.Collection1, &meta1)
_ = mapstructure.Decode(testdata.Collection2, &meta2)

data := []config.SectionMetadata{meta1, meta2}

Expand All @@ -49,8 +49,8 @@ func TestBuild(t *testing.T) {
func TestBuildDuplicatedSlugs(t *testing.T) {
var meta1 config.SectionMetadata
var meta2 config.SectionMetadata
mapstructure.Decode(testdata.Collection1, &meta1)
mapstructure.Decode(testdata.Collection2, &meta2)
_ = mapstructure.Decode(testdata.Collection1, &meta1)
_ = mapstructure.Decode(testdata.Collection2, &meta2)
meta2.Slug = meta1.Slug

data := []config.SectionMetadata{meta1, meta2}
Expand Down

0 comments on commit 84977ae

Please sign in to comment.