Fix linter

This commit is contained in:
Fedor Korotkiy 2020-04-05 00:55:07 +03:00
parent f3d73b97ad
commit 1d5c64d8ca
10 changed files with 15 additions and 15 deletions

View file

@ -29,7 +29,7 @@ func (h *HeartbeatHandler) doHeartbeat(w http.ResponseWriter, r *http.Request) e
}
var req HeartbeatRequest
if err := json.Unmarshal(reqJSON, &req); err != nil {
if err = json.Unmarshal(reqJSON, &req); err != nil {
return err
}

View file

@ -18,8 +18,8 @@ type testCache struct {
tmpDir string
}
func (c *testCache) cleanup() error {
return os.RemoveAll(c.tmpDir)
func (c *testCache) cleanup() {
_ = os.RemoveAll(c.tmpDir)
}
func newTestCache(t *testing.T) *testCache {

View file

@ -16,7 +16,7 @@ func Download(ctx context.Context, endpoint string, c *Cache, artifactID build.I
if err != nil {
return err
}
defer abort()
defer func() { _ = abort() }()
req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint+"/artifact?id="+artifactID.String(), nil)
if err != nil {

View file

@ -66,7 +66,7 @@ func (c *Client) Build(ctx context.Context, graph build.Graph, lsn BuildListener
}
c.l.Debug("build started", zap.String("build_id", started.ID.String()))
if err := c.uploadSources(ctx, &graph, started); err != nil {
if err = c.uploadSources(ctx, &graph, started); err != nil {
return err
}

View file

@ -56,7 +56,7 @@ func (c *Client) Download(ctx context.Context, localCache *Cache, id build.ID) e
if err != nil {
return err
}
defer abort()
defer func() { _ = abort() }()
req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.endpoint+"/file?id="+id.String(), nil)
if err != nil {

View file

@ -31,7 +31,7 @@ func newEnv(t *testing.T) *env {
cache := newCache(t)
defer func() {
if cache != nil {
_ = cache.cleanup()
cache.cleanup()
}
}()
@ -54,7 +54,7 @@ func newEnv(t *testing.T) *env {
func (e *env) stop() {
e.server.Close()
_ = e.cache.cleanup()
e.cache.cleanup()
}
func TestFileUpload(t *testing.T) {
@ -99,11 +99,11 @@ func TestFileUpload(t *testing.T) {
var wg sync.WaitGroup
wg.Add(G)
id := build.ID{0x03, byte(i)}
for j := 0; j < G; j++ {
go func() {
defer wg.Done()
id := build.ID{0x03, byte(j)}
assert.NoError(t, env.client.Upload(ctx, id, tmpFilePath))
}()
}
@ -124,7 +124,7 @@ func TestFileDownload(t *testing.T) {
w, abort, err := env.cache.Write(id)
require.NoError(t, err)
defer abort()
defer func() { _ = abort() }()
_, err = w.Write([]byte("foobar"))
require.NoError(t, err)

View file

@ -27,8 +27,8 @@ func newCache(t *testing.T) *testCache {
return &testCache{Cache: c, tmpDir: tmpDir}
}
func (c *testCache) cleanup() error {
return os.Remove(c.tmpDir)
func (c *testCache) cleanup() {
_ = os.Remove(c.tmpDir)
}
func TestFileCache(t *testing.T) {

View file

@ -59,7 +59,7 @@ func (h *Handler) doPut(w http.ResponseWriter, r *http.Request, id build.ID) err
} else if err != nil {
return nil, err
}
defer abort()
defer func() { _ = abort() }()
if _, err = io.Copy(w, r.Body); err != nil {
return nil, err

View file

@ -12,7 +12,7 @@ func (w *Worker) pullFiles(ctx context.Context, files map[build.ID]string) error
for id := range files {
_, unlock, err := w.fileCache.Get(id)
if errors.Is(err, filecache.ErrNotFound) {
if err := w.fileClient.Download(ctx, w.fileCache, id); err != nil {
if err = w.fileClient.Download(ctx, w.fileCache, id); err != nil {
return err
}
} else if err != nil {

View file

@ -165,7 +165,7 @@ func (w *Worker) runJob(ctx context.Context, spec *api.JobSpec) (*api.JobResult,
return res, nil
}
if err := w.pullFiles(ctx, spec.SourceFiles); err != nil {
if err = w.pullFiles(ctx, spec.SourceFiles); err != nil {
return nil, err
}