Skip to content

Commit 869e931

Browse files
committed
fix: resolve go vet non-constant format string errors and bare DeferCleanup
1 parent ebe07eb commit 869e931

6 files changed

Lines changed: 14 additions & 10 deletions

File tree

src/python/finalize/finalize.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ func (f *Finalizer) HandleCollectstatic() error {
9595
f.Log.Info("Running python %s collectstatic --noinput --traceback", managePyPath)
9696
output := new(bytes.Buffer)
9797
if err = f.Command.Execute(f.Stager.BuildDir(), output, text.NewIndentWriter(os.Stderr, []byte(" ")), "python", managePyPath, "collectstatic", "--noinput", "--traceback"); err != nil {
98-
f.Log.Error(fmt.Sprintf(` ! Error while running '$ python %s collectstatic --noinput'.
98+
f.Log.Error(` ! Error while running '$ python %s collectstatic --noinput'.
9999
See traceback above for details.
100100
101101
You may need to update application code to resolve this error.
102102
Or, you can disable collectstatic for this application:
103103
104104
$ cf set-env <app> DISABLE_COLLECTSTATIC 1
105105
106-
https://devcenter.heroku.com/articles/django-assets`, managePyPath))
106+
https://devcenter.heroku.com/articles/django-assets`, managePyPath)
107107
return err
108108
}
109109

src/python/hooks/appdynamics.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func (h AppdynamicsHook) RewriteRequirementsFile(stager *libbuildpack.Stager) er
123123
panic(err)
124124
}
125125
fileContents, _ := os.ReadFile(f.Name())
126-
h.Log.Info(string(fileContents))
126+
h.Log.Info("%s", string(fileContents))
127127

128128
return nil
129129
}
@@ -138,7 +138,7 @@ func (h AppdynamicsHook) RewriteProcFileWithAppdynamics(stager *libbuildpack.Sta
138138
return err
139139
}
140140
fileContents, _ := os.ReadFile(file)
141-
h.Log.Info(string(fileContents))
141+
h.Log.Info("%s", string(fileContents))
142142
} else {
143143
h.Log.Info("Cannot find Procfile, skipping this step!")
144144
}
@@ -148,7 +148,7 @@ func (h AppdynamicsHook) RewriteProcFileWithAppdynamics(stager *libbuildpack.Sta
148148
func (h AppdynamicsHook) CreateAppDynamicsEnv(stager *libbuildpack.Stager, environmentVars map[string]string) error {
149149
scriptContents := h.GenerateAppdynamicsScript(environmentVars)
150150
h.Log.BeginStep("Writing Appdynamics Environment")
151-
h.Log.Debug(scriptContents)
151+
h.Log.Debug("%s", scriptContents)
152152
return stager.WriteProfileD("appdynamics.sh", scriptContents)
153153
}
154154

src/python/hooks/hooks_app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func runHook(scriptName string, compiler *libbuildpack.Stager) error {
3030
if exists, err := libbuildpack.FileExists(path); err != nil {
3131
return err
3232
} else if exists {
33-
compiler.Logger().BeginStep("Running " + scriptName + " hook")
33+
compiler.Logger().BeginStep("Running %s hook", scriptName)
3434
if err := os.Chmod(path, 0755); err != nil {
3535
return err
3636
}

src/python/hooks/sealights.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func (sh SealightsHook) RewriteProcFileWithSealights(stager *libbuildpack.Stager
139139
if err != nil {
140140
return fmt.Errorf("Error reading file %s: %v", file, err)
141141
}
142-
sh.Log.Info(string(fileContents))
142+
sh.Log.Info("%s", string(fileContents))
143143
} else {
144144
sh.Log.Info("Cannot find Procfile, skipping this step!")
145145
}

src/python/supply/supply.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ func pipCommand() []string {
876876

877877
func (s *Supplier) runPipInstall(args ...string) error {
878878
installCmd := append(append(pipCommand(), "install"), args...)
879-
s.Log.Info(strings.Join(installCmd, " "))
879+
s.Log.Info("%s", strings.Join(installCmd, " "))
880880
return s.Command.Execute(s.Stager.BuildDir(), indentWriter(os.Stdout), indentWriter(os.Stderr), installCmd[0], installCmd[1:]...)
881881
}
882882

src/python/supply/supply_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,9 @@ var _ = Describe("Supply", func() {
393393
})
394394

395395
Describe("HandleFfi", func() {
396-
DeferCleanup(os.Setenv, "LIBFFI", "")
396+
BeforeEach(func() {
397+
DeferCleanup(os.Setenv, "LIBFFI", "")
398+
})
397399

398400
Context("when the app uses ffi", func() {
399401
BeforeEach(func() {
@@ -750,7 +752,9 @@ export GUNICORN_CMD_ARGS=${GUNICORN_CMD_ARGS:-'--access-logfile -'}
750752
})
751753

752754
Describe("SetupCacheDir", func() {
753-
DeferCleanup(os.Unsetenv, "XDG_CACHE_HOME")
755+
BeforeEach(func() {
756+
DeferCleanup(os.Unsetenv, "XDG_CACHE_HOME")
757+
})
754758

755759
It("Sets pip's cache directory", func() {
756760
mockStager.EXPECT().WriteEnvFile("XDG_CACHE_HOME", filepath.Join(cacheDir, "pip_cache"))

0 commit comments

Comments
 (0)