Skip to content

Commit

Permalink
pkg/*: fix "empty-lines" (revive)
Browse files Browse the repository at this point in the history
    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>
  • Loading branch information
thaJeztah committed Sep 27, 2022
1 parent db1663a commit 412c650
Show file tree
Hide file tree
Showing 29 changed files with 4 additions and 51 deletions.
2 changes: 0 additions & 2 deletions pkg/archive/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ func ReplaceFileTarWrapper(inputTarStream io.ReadCloser, mods map[string]TarModi
}

pipeWriter.Close()

}()
return pipeReader
}
Expand Down Expand Up @@ -772,7 +771,6 @@ func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, L
}
return err
}

}

if len(errors) > 0 {
Expand Down
1 change: 0 additions & 1 deletion pkg/archive/archive_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions pkg/archive/changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ func (info *FileInfo) path() string {
}

func (info *FileInfo) addChanges(oldInfo *FileInfo, changes *[]Change) {

sizeAtEntry := len(*changes)

if oldInfo == nil {
Expand Down Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion pkg/archive/changes_posix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion pkg/archive/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion pkg/archive/copy_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion pkg/archive/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 0 additions & 3 deletions pkg/authorization/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

})

}

}
1 change: 0 additions & 1 deletion pkg/authorization/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 0 additions & 3 deletions pkg/authorization/middleware_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -61,7 +60,5 @@ func TestMiddlewareWrapHandler(t *testing.T) {
if err := mdHandler(ctx, resp, req, map[string]string{}); err != nil {
assert.NilError(t, err)
}

})

}
5 changes: 1 addition & 4 deletions pkg/authorization/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -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()

Expand Down
10 changes: 2 additions & 8 deletions pkg/devicemapper/devmapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -396,7 +392,6 @@ func CancelDeferredRemove(deviceName string) error {
return ErrEnxio
}
return fmt.Errorf("devicemapper: Error running CancelDeferredRemove %s", err)

}
return nil
}
Expand Down Expand Up @@ -680,7 +675,6 @@ func CreateDevice(poolName string, deviceID int) error {
}

return fmt.Errorf("devicemapper: Error running CreateDevice %s", err)

}
return nil
}
Expand Down
4 changes: 1 addition & 3 deletions pkg/devicemapper/devmapper_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 0 additions & 1 deletion pkg/directory/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions pkg/fileutils/fileutils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func TestCopyFileWithInvalidSrc(t *testing.T) {
if bytes != 0 {
t.Fatal("Should have written 0 bytes")
}

}

// CopyFile with invalid dest
Expand All @@ -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
Expand Down Expand Up @@ -492,7 +490,6 @@ func TestMatches(t *testing.T) {
check(pm, test.text, test.pass, desc)
}
})

}

func TestCleanPatterns(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion pkg/idtools/idtools_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ func callGetent(database, key string) (io.Reader, error) {
default:
return nil, err
}

}
return bytes.NewReader(out), nil
}
Expand Down
1 change: 0 additions & 1 deletion pkg/idtools/usergroupadd_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion pkg/ioutils/bytespipe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

}
}

Expand Down
1 change: 0 additions & 1 deletion pkg/ioutils/fswriters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion pkg/ioutils/writers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion pkg/loopback/attach_loopback.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion pkg/namesgenerator/names-generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion pkg/plugins/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ func (p *Plugin) runHandlers() {
p.handlersRun = true
}
handlers.RUnlock()

}

// activated returns if the plugin has already been activated.
Expand Down
1 change: 0 additions & 1 deletion pkg/sysinfo/sysinfo_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion pkg/system/meminfo_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ func parseMemInfo(reader io.Reader) (*MemInfo, error) {
case "SwapFree:":
meminfo.SwapFree = bytes
}

}
if memAvailable != -1 {
meminfo.MemFree = memAvailable
Expand Down
1 change: 0 additions & 1 deletion pkg/system/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ func DefaultPathEnv(os string) string {
return ""
}
return defaultUnixPathEnv

}

// CheckSystemDriveAndRemoveDriveLetter verifies that a path, if it includes a drive letter,
Expand Down
1 change: 0 additions & 1 deletion pkg/tailfile/tailfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

}
}
1 change: 0 additions & 1 deletion pkg/tarsum/fileinfosums_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,4 @@ func TestSortFileInfoSums(t *testing.T) {
if fis.GetFile("noPresent") != nil {
t.Error("Should have return nil if name not found.")
}

}
3 changes: 0 additions & 3 deletions pkg/tarsum/tarsum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ func TestNewTarSumForLabelInvalid(t *testing.T) {
}

func TestNewTarSumForLabel(t *testing.T) {

layer := testLayers[0]

reader, err := os.Open(layer.filename)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 412c650

Please sign in to comment.