Parcourir la source

pkg/*: fix "empty-lines" (revive)

    pkg/directory/directory.go:9:49: empty-lines: extra empty line at the start of a block (revive)
    pkg/pubsub/publisher.go:8:48: empty-lines: extra empty line at the start of a block (revive)
    pkg/loopback/attach_loopback.go:96:69: empty-lines: extra empty line at the start of a block (revive)
    pkg/devicemapper/devmapper_wrapper.go:136:48: empty-lines: extra empty line at the start of a block (revive)
    pkg/devicemapper/devmapper.go:391:35: empty-lines: extra empty line at the end of a block (revive)
    pkg/devicemapper/devmapper.go:676:35: empty-lines: extra empty line at the end of a block (revive)
    pkg/archive/changes_posix_test.go:15:38: empty-lines: extra empty line at the end of a block (revive)
    pkg/devicemapper/devmapper.go:241:51: empty-lines: extra empty line at the start of a block (revive)
    pkg/fileutils/fileutils_test.go:17:47: empty-lines: extra empty line at the end of a block (revive)
    pkg/fileutils/fileutils_test.go:34:48: empty-lines: extra empty line at the end of a block (revive)
    pkg/fileutils/fileutils_test.go:318:32: empty-lines: extra empty line at the end of a block (revive)
    pkg/tailfile/tailfile.go:171:6: empty-lines: extra empty line at the end of a block (revive)
    pkg/tarsum/fileinfosums_test.go:16:41: empty-lines: extra empty line at the end of a block (revive)
    pkg/tarsum/tarsum_test.go:198:42: empty-lines: extra empty line at the start of a block (revive)
    pkg/tarsum/tarsum_test.go:294:25: empty-lines: extra empty line at the start of a block (revive)
    pkg/tarsum/tarsum_test.go:407:34: empty-lines: extra empty line at the end of a block (revive)
    pkg/ioutils/fswriters_test.go:52:45: empty-lines: extra empty line at the end of a block (revive)
    pkg/ioutils/writers_test.go:24:39: empty-lines: extra empty line at the end of a block (revive)
    pkg/ioutils/bytespipe_test.go:78:26: empty-lines: extra empty line at the end of a block (revive)
    pkg/sysinfo/sysinfo_linux_test.go:13:37: empty-lines: extra empty line at the end of a block (revive)
    pkg/archive/archive_linux_test.go:57:64: empty-lines: extra empty line at the end of a block (revive)
    pkg/archive/changes.go:248:72: empty-lines: extra empty line at the start of a block (revive)
    pkg/archive/changes_posix_test.go:15:38: empty-lines: extra empty line at the end of a block (revive)
    pkg/archive/copy.go:248:124: empty-lines: extra empty line at the end of a block (revive)
    pkg/archive/diff_test.go:198:44: empty-lines: extra empty line at the end of a block (revive)
    pkg/archive/archive.go:304:12: empty-lines: extra empty line at the end of a block (revive)
    pkg/archive/archive.go:749:37: empty-lines: extra empty line at the end of a block (revive)
    pkg/archive/archive.go:812:81: empty-lines: extra empty line at the start of a block (revive)
    pkg/archive/copy_unix_test.go:347:34: empty-lines: extra empty line at the end of a block (revive)
    pkg/system/path.go:11:39: empty-lines: extra empty line at the end of a block (revive)
    pkg/system/meminfo_linux.go:29:21: empty-lines: extra empty line at the end of a block (revive)
    pkg/plugins/plugins.go:135:32: empty-lines: extra empty line at the end of a block (revive)
    pkg/authorization/response.go:71:48: empty-lines: extra empty line at the start of a block (revive)
    pkg/authorization/api_test.go:18:51: empty-lines: extra empty line at the end of a block (revive)
    pkg/authorization/middleware_test.go:23:44: empty-lines: extra empty line at the end of a block (revive)
    pkg/authorization/middleware_unix_test.go:17:46: empty-lines: extra empty line at the end of a block (revive)
    pkg/authorization/api_test.go:57:45: empty-lines: extra empty line at the end of a block (revive)
    pkg/authorization/response.go:83:50: empty-lines: extra empty line at the start of a block (revive)
    pkg/authorization/api_test.go:66:47: empty-lines: extra empty line at the end of a block (revive)
    pkg/authorization/middleware_unix_test.go:45:48: empty-lines: extra empty line at the end of a block (revive)
    pkg/authorization/response.go:145:75: empty-lines: extra empty line at the start of a block (revive)
    pkg/authorization/middleware_unix_test.go:56:51: empty-lines: extra empty line at the end of a block (revive)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn il y a 2 ans
Parent
commit
412c650e05

+ 0 - 2
pkg/archive/archive.go

@@ -385,7 +385,6 @@ func ReplaceFileTarWrapper(inputTarStream io.ReadCloser, mods map[string]TarModi
 		}
 
 		pipeWriter.Close()
-
 	}()
 	return pipeReader
 }
@@ -772,7 +771,6 @@ func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, L
 			}
 			return err
 		}
-
 	}
 
 	if len(errors) > 0 {

+ 0 - 1
pkg/archive/archive_linux_test.go

@@ -61,7 +61,6 @@ func checkOpaqueness(t *testing.T, path string, opaque string) {
 	if string(xattrOpaque) != opaque {
 		t.Fatalf("Unexpected opaque value: %q, expected %q", string(xattrOpaque), opaque)
 	}
-
 }
 
 func checkOverlayWhiteout(t *testing.T, path string) {

+ 0 - 2
pkg/archive/changes.go

@@ -246,7 +246,6 @@ func (info *FileInfo) path() string {
 }
 
 func (info *FileInfo) addChanges(oldInfo *FileInfo, changes *[]Change) {
-
 	sizeAtEntry := len(*changes)
 
 	if oldInfo == nil {
@@ -319,7 +318,6 @@ func (info *FileInfo) addChanges(oldInfo *FileInfo, changes *[]Change) {
 		copy((*changes)[sizeAtEntry+1:], (*changes)[sizeAtEntry:])
 		(*changes)[sizeAtEntry] = change
 	}
-
 }
 
 // Changes add changes to file information.

+ 0 - 1
pkg/archive/changes_posix_test.go

@@ -102,7 +102,6 @@ func TestHardLinkOrder(t *testing.T) {
 			t.Errorf("headers - %q expected linkname %q; but got %q", hdrs[i].Name, hdrs[i].Linkname, hdrsRev[i].Linkname)
 		}
 	}
-
 }
 
 type tarHeaders []tar.Header

+ 0 - 1
pkg/archive/copy.go

@@ -303,7 +303,6 @@ func PrepareArchiveCopy(srcContent io.Reader, srcInfo, dstInfo CopyInfo) (dstDir
 		}
 		return dstDir, RebaseArchiveEntries(srcContent, srcBase, dstBase), nil
 	}
-
 }
 
 // RebaseArchiveEntries rewrites the given srcContent archive replacing

+ 0 - 1
pkg/archive/copy_unix_test.go

@@ -372,7 +372,6 @@ func TestCopyCaseB(t *testing.T) {
 	if err != ErrDirNotExists {
 		t.Fatalf("expected ErrDirNotExists error, but got %T: %s", err, err)
 	}
-
 }
 
 // C. SRC specifies a file and DST exists as a file.

+ 0 - 1
pkg/archive/diff_test.go

@@ -308,7 +308,6 @@ func TestApplyLayerWhiteouts(t *testing.T) {
 			t.Fatalf("invalid files for layer %d: expected %q, got %q", i, tc.expected, paths)
 		}
 	}
-
 }
 
 func makeTestLayer(paths []string) (rc io.ReadCloser, err error) {

+ 0 - 3
pkg/authorization/api_test.go

@@ -68,9 +68,6 @@ func TestPeerCertificateMarshalJSON(t *testing.T) {
 			assert.Assert(t, is.Nil(err))
 			assert.Equal(t, "Earth", pcObj.Subject.Country[0])
 			assert.Equal(t, true, pcObj.IsCA)
-
 		})
-
 	}
-
 }

+ 0 - 1
pkg/authorization/middleware_test.go

@@ -43,7 +43,6 @@ func TestNewResponseModifier(t *testing.T) {
 	if recorder.Header().Get("H1") != "V1" {
 		t.Fatalf("Header value must exists %s", recorder.Header().Get("H1"))
 	}
-
 }
 
 func setAuthzPlugins(m *Middleware, plugins []Plugin) {

+ 0 - 3
pkg/authorization/middleware_unix_test.go

@@ -50,7 +50,6 @@ func TestMiddlewareWrapHandler(t *testing.T) {
 		if err := mdHandler(ctx, resp, req, map[string]string{}); err == nil {
 			assert.Assert(t, is.ErrorContains(err, ""))
 		}
-
 	})
 
 	t.Run("Positive Test Case :", func(t *testing.T) {
@@ -61,7 +60,5 @@ func TestMiddlewareWrapHandler(t *testing.T) {
 		if err := mdHandler(ctx, resp, req, map[string]string{}); err != nil {
 			assert.NilError(t, err)
 		}
-
 	})
-
 }

+ 1 - 4
pkg/authorization/response.go

@@ -67,9 +67,8 @@ func (rm *responseModifier) Hijacked() bool {
 	return rm.hijacked
 }
 
-// WriterHeader stores the http status code
+// WriteHeader stores the http status code
 func (rm *responseModifier) WriteHeader(s int) {
-
 	// Use original request if hijacked
 	if rm.hijacked {
 		rm.rw.WriteHeader(s)
@@ -81,7 +80,6 @@ func (rm *responseModifier) WriteHeader(s int) {
 
 // Header returns the internal http header
 func (rm *responseModifier) Header() http.Header {
-
 	// Use original header if hijacked
 	if rm.hijacked {
 		return rm.rw.Header()
@@ -143,7 +141,6 @@ func (rm *responseModifier) RawHeaders() ([]byte, error) {
 
 // Hijack returns the internal connection of the wrapped http.ResponseWriter
 func (rm *responseModifier) Hijack() (net.Conn, *bufio.ReadWriter, error) {
-
 	rm.hijacked = true
 	rm.FlushAll()
 

+ 2 - 8
pkg/devicemapper/devmapper.go

@@ -237,12 +237,8 @@ func (t *Task) getDriverVersion() (string, error) {
 	return res, nil
 }
 
-func (t *Task) getNextTarget(next unsafe.Pointer) (nextPtr unsafe.Pointer, start uint64,
-	length uint64, targetType string, params string) {
-
-	return DmGetNextTarget(t.unmanaged, next, &start, &length,
-			&targetType, &params),
-		start, length, targetType, params
+func (t *Task) getNextTarget(next unsafe.Pointer) (nextPtr unsafe.Pointer, start uint64, length uint64, targetType string, params string) {
+	return DmGetNextTarget(t.unmanaged, next, &start, &length, &targetType, &params), start, length, targetType, params
 }
 
 // UdevWait waits for any processes that are waiting for udev to complete the specified cookie.
@@ -396,7 +392,6 @@ func CancelDeferredRemove(deviceName string) error {
 			return ErrEnxio
 		}
 		return fmt.Errorf("devicemapper: Error running CancelDeferredRemove %s", err)
-
 	}
 	return nil
 }
@@ -680,7 +675,6 @@ func CreateDevice(poolName string, deviceID int) error {
 		}
 
 		return fmt.Errorf("devicemapper: Error running CreateDevice %s", err)
-
 	}
 	return nil
 }

+ 1 - 3
pkg/devicemapper/devmapper_wrapper.go

@@ -132,9 +132,7 @@ func dmTaskSetAddNodeFct(task *cdmTask, addNode AddNodeType) int {
 	return int(C.dm_task_set_add_node((*C.struct_dm_task)(task), C.dm_add_node_t(addNode)))
 }
 
-func dmTaskAddTargetFct(task *cdmTask,
-	start, size uint64, ttype, params string) int {
-
+func dmTaskAddTargetFct(task *cdmTask, start, size uint64, ttype, params string) int {
 	Cttype := C.CString(ttype)
 	defer free(Cttype)
 

+ 0 - 1
pkg/directory/directory.go

@@ -7,7 +7,6 @@ import (
 
 // MoveToSubdir moves all contents of a directory to a subdirectory underneath the original path
 func MoveToSubdir(oldpath, subdir string) error {
-
 	infos, err := os.ReadDir(oldpath)
 	if err != nil {
 		return err

+ 0 - 3
pkg/fileutils/fileutils_test.go

@@ -27,7 +27,6 @@ func TestCopyFileWithInvalidSrc(t *testing.T) {
 	if bytes != 0 {
 		t.Fatal("Should have written 0 bytes")
 	}
-
 }
 
 // CopyFile with invalid dest
@@ -49,7 +48,6 @@ func TestCopyFileWithInvalidDest(t *testing.T) {
 	if bytes != 0 {
 		t.Fatal("Should have written 0 bytes")
 	}
-
 }
 
 // CopyFile with same src and dest
@@ -492,7 +490,6 @@ func TestMatches(t *testing.T) {
 			check(pm, test.text, test.pass, desc)
 		}
 	})
-
 }
 
 func TestCleanPatterns(t *testing.T) {

+ 0 - 1
pkg/idtools/idtools_unix.go

@@ -213,7 +213,6 @@ func callGetent(database, key string) (io.Reader, error) {
 		default:
 			return nil, err
 		}
-
 	}
 	return bytes.NewReader(out), nil
 }

+ 0 - 1
pkg/idtools/usergroupadd_linux.go

@@ -88,7 +88,6 @@ func addUser(name string) error {
 }
 
 func createSubordinateRanges(name string) error {
-
 	// first, we should verify that ranges weren't automatically created
 	// by the distro tooling
 	ranges, err := parseSubuid(name)

+ 0 - 1
pkg/ioutils/bytespipe_test.go

@@ -119,7 +119,6 @@ func TestBytesPipeWriteRandomChunks(t *testing.T) {
 		if expected != actual {
 			t.Fatalf("BytesPipe returned invalid data. Expected checksum %v, got %v", expected, actual)
 		}
-
 	}
 }
 

+ 0 - 1
pkg/ioutils/fswriters_test.go

@@ -95,7 +95,6 @@ func TestAtomicWriteSetCommit(t *testing.T) {
 	if expected := testMode; st.Mode() != expected {
 		t.Fatalf("Mode mismatched, expected %o, got %o", expected, st.Mode())
 	}
-
 }
 
 func TestAtomicWriteSetCancel(t *testing.T) {

+ 0 - 1
pkg/ioutils/writers_test.go

@@ -27,7 +27,6 @@ func TestNopWriteCloser(t *testing.T) {
 	if err := wrapper.Close(); err != nil {
 		t.Fatal("NopWriteCloser always return nil on Close.")
 	}
-
 }
 
 func TestNopWriter(t *testing.T) {

+ 0 - 1
pkg/loopback/attach_loopback.go

@@ -94,7 +94,6 @@ func openNextAvailableLoopback(index int, sparseFile *os.File) (loopFile *os.Fil
 // AttachLoopDevice attaches the given sparse file to the next
 // available loopback device. It returns an opened *os.File.
 func AttachLoopDevice(sparseName string) (loop *os.File, err error) {
-
 	// Try to retrieve the next available loopback device via syscall.
 	// If it fails, we discard error and start looping for a
 	// loopback from index 0.

+ 0 - 1
pkg/namesgenerator/names-generator_test.go

@@ -23,7 +23,6 @@ func TestNameRetries(t *testing.T) {
 	if !strings.ContainsAny(name, "0123456789") {
 		t.Fatalf("Generated name doesn't contain a number")
 	}
-
 }
 
 func BenchmarkGetRandomName(b *testing.B) {

+ 0 - 1
pkg/plugins/plugins.go

@@ -151,7 +151,6 @@ func (p *Plugin) runHandlers() {
 		p.handlersRun = true
 	}
 	handlers.RUnlock()
-
 }
 
 // activated returns if the plugin has already been activated.

+ 0 - 1
pkg/sysinfo/sysinfo_linux_test.go

@@ -33,7 +33,6 @@ func TestReadProcBool(t *testing.T) {
 	if readProcBool(path.Join(tmpDir, "no-exist")) {
 		t.Fatal("should be false for non-existent entry")
 	}
-
 }
 
 func TestCgroupEnabled(t *testing.T) {

+ 0 - 1
pkg/system/meminfo_linux.go

@@ -55,7 +55,6 @@ func parseMemInfo(reader io.Reader) (*MemInfo, error) {
 		case "SwapFree:":
 			meminfo.SwapFree = bytes
 		}
-
 	}
 	if memAvailable != -1 {
 		meminfo.MemFree = memAvailable

+ 0 - 1
pkg/system/path.go

@@ -13,7 +13,6 @@ func DefaultPathEnv(os string) string {
 		return ""
 	}
 	return defaultUnixPathEnv
-
 }
 
 // CheckSystemDriveAndRemoveDriveLetter verifies that a path, if it includes a drive letter,

+ 0 - 1
pkg/tailfile/tailfile.go

@@ -216,6 +216,5 @@ func (s *scanner) Scan(ctx context.Context) bool {
 			// It's much simpler and cleaner to just re-read `len(delimiter)-1` bytes again.
 			s.pos += int64(len(s.delim)) - 1
 		}
-
 	}
 }

+ 0 - 1
pkg/tarsum/fileinfosums_test.go

@@ -58,5 +58,4 @@ func TestSortFileInfoSums(t *testing.T) {
 	if fis.GetFile("noPresent") != nil {
 		t.Error("Should have return nil if name not found.")
 	}
-
 }

+ 0 - 3
pkg/tarsum/tarsum_test.go

@@ -196,7 +196,6 @@ func TestNewTarSumForLabelInvalid(t *testing.T) {
 }
 
 func TestNewTarSumForLabel(t *testing.T) {
-
 	layer := testLayers[0]
 
 	reader, err := os.Open(layer.filename)
@@ -292,7 +291,6 @@ func TestTarSumsReadSize(t *testing.T) {
 	layer := testLayers[0]
 
 	for i := 0; i < 5; i++ {
-
 		reader, err := os.Open(layer.filename)
 		if err != nil {
 			t.Fatal(err)
@@ -515,7 +513,6 @@ func TestIteration(t *testing.T) {
 			t.Errorf("expected sum: %q, got: %q", htest.expectedSum, s)
 		}
 	}
-
 }
 
 func renderSumForHeader(v Version, h *tar.Header, data []byte) (string, error) {