Fixed ineffectual assignments
authorChristian Muehlhaeuser <muesli@gmail.com>
Fri, 2 Aug 2019 15:28:43 +0000 (15:28 +0000)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Sat, 10 Aug 2019 18:11:51 +0000 (20:11 +0200)
Dropped/fixed ineffectual assignments after static code analysis.

hugofs/nosymlink_test.go
hugolib/config.go
hugolib/hugo_sites_build_test.go
output/outputFormat_test.go
tpl/collections/collections.go

index 5e1964419e15373ee75248e1125e4cdcbcaf7826..a04e671fce02d1e03267e85c12476a3d75440558 100644 (file)
@@ -102,9 +102,9 @@ func TestNoSymlinkFs(t *testing.T) {
                                        return fi, err
                                },
                        } {
-                               fi, err := stat(symlinkedDir)
+                               _, err := stat(symlinkedDir)
                                assert.Equal(ErrPermissionSymlink, err)
-                               fi, err = stat(symlinkedFile)
+                               fi, err := stat(symlinkedFile)
                                assertFileStat(symlinkedFilename, fi, err)
 
                                fi, err = stat(filepath.Join(workDir, "blog"))
index 8c2e44c10aeb48691118d205b6a8532fd42fd40d..38cf6c3c1bbb1c279eec555753894b17a913ddea 100644 (file)
@@ -256,8 +256,7 @@ func (l configLoader) loadConfig(configName string, v *viper.Viper) (string, err
        }
 
        var filename string
-       fileExt := helpers.ExtNoDelimiter(configName)
-       if fileExt != "" {
+       if helpers.ExtNoDelimiter(configName) != "" {
                exists, _ := helpers.Exists(baseFilename, l.Fs)
                if exists {
                        filename = baseFilename
@@ -268,7 +267,6 @@ func (l configLoader) loadConfig(configName string, v *viper.Viper) (string, err
                        exists, _ := helpers.Exists(filenameToCheck, l.Fs)
                        if exists {
                                filename = filenameToCheck
-                               fileExt = ext
                                break
                        }
                }
index 123c27b9c7b0f3b2629a8e1a419ffac06e6afe45..15e4920f07008925dcf3e9ac41f9f8e2142d0c51 100644 (file)
@@ -1204,12 +1204,15 @@ func readFileFromFs(t testing.TB, fs afero.Fs, filename string) string {
                        end++
                }
 
-               root := filepath.Join(parts[start:end]...)
-               if hadSlash {
-                       root = helpers.FilePathSeparator + root
-               }
+               /*
+                       root := filepath.Join(parts[start:end]...)
+                       if hadSlash {
+                               root = helpers.FilePathSeparator + root
+                       }
+
+                       helpers.PrintFs(fs, root, os.Stdout)
+               */
 
-               //helpers.PrintFs(fs, root, os.Stdout)
                t.Fatalf("Failed to read file: %s", err)
        }
        return string(b)
index 3d2fa5d1722897d649cf2e1c3fa270204e4ec229..aef1403a94b22960f611c993c7bbd9254588c8d9 100644 (file)
@@ -118,7 +118,7 @@ func TestGetFormatByFilename(t *testing.T) {
        f, found := formats.FromFilename("my.amp.html")
        require.True(t, found)
        require.Equal(t, AMPFormat, f)
-       f, found = formats.FromFilename("my.ics")
+       _, found = formats.FromFilename("my.ics")
        require.True(t, found)
        f, found = formats.FromFilename("my.html")
        require.True(t, found)
index 3839ad4728a159c9df428f1d9105a5a34d397fc6..195199876403203473514ee53d2659749ced3b98 100644 (file)
@@ -98,8 +98,9 @@ func (ns *Namespace) Delimit(seq, delimiter interface{}, last ...interface{}) (t
                dStr, err := cast.ToStringE(l)
                if err != nil {
                        dLast = nil
+               } else {
+                       dLast = &dStr
                }
-               dLast = &dStr
        }
 
        seqv := reflect.ValueOf(seq)