runc
runc copied to clipboard
golangci: enable GoDoc linting
relates to https://github.com/opencontainers/runc/issues/2627
golint is scoring pretty low currently, because many exported functions and variables are missing a well-formatted GoDoc comment:
https://goreportcard.com/report/github.com/opencontainers/runc
Ran inside a container (ignoring the CGO issues, as I was a bit lazy);
docker run -e CGO_ENABLED=1 --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.40.1 golangci-lint run -v --max-issues-per-linter=0 --max-same-issues=0
Remaining linting issues;
Error: exported type `KeySerial` should have comment or be unexported (golint)
Error: exported function `JoinSessionKeyring` should have comment or be unexported (golint)
Error: exported const Wildcard should have comment (or a comment on this block) or be unexported (golint)
Error: exported type `Device` should have comment or be unexported (golint)
Error: struct field `Uid` should be `UID` (golint)
Error: exported type `Type` should have comment or be unexported (golint)
Error: exported const WildcardDevice should have comment (or a comment on this block) or be unexported (golint)
Error: exported method `Type.IsValid` should have comment or be unexported (golint)
Error: exported method `Type.CanMknod` should have comment or be unexported (golint)
Error: exported method `Type.CanCgroup` should have comment or be unexported (golint)
Error: exported type `Rule` should have comment or be unexported (golint)
Error: exported method `Rule.CgroupString` should have comment or be unexported (golint)
Error: exported method `Rule.Mkdev` should have comment or be unexported (golint)
Error: exported var `ErrNotValidFormat` should have comment or be unexported (golint)
Error: exported type `Stacktrace` should have comment or be unexported (golint)
Error: exported type `ParentDeathSignal` should have comment or be unexported (golint)
Error: exported method `ParentDeathSignal.Restore` should have comment or be unexported (golint)
Error: exported method `ParentDeathSignal.Set` should have comment or be unexported (golint)
Error: exported function `Execv` should have comment or be unexported (golint)
Error: exported function `Prlimit` should have comment or be unexported (golint)
Error: exported function `SetParentDeathSignal` should have comment or be unexported (golint)
Error: exported function `GetParentDeathSignal` should have comment or be unexported (golint)
Error: exported function `SetKeepCaps` should have comment or be unexported (golint)
Error: exported function `ClearKeepCaps` should have comment or be unexported (golint)
Error: exported function `Setctty` should have comment or be unexported (golint)
Error: exported const Dead should have comment (or a comment on this block) or be unexported (golint)
Error: don't use underscores in Go names; type Stat_t should be StatT (golint)
Error: comment on exported function `Lgetxattr` should be of the form `Lgetxattr ...` (golint)
Error: exported type `Emulator` should have comment or be unexported (golint)
Error: exported method `Emulator.IsBlacklist` should have comment or be unexported (golint)
Error: exported method `Emulator.IsAllowAll` should have comment or be unexported (golint)
Error: exported method `Emulator.Apply` should have comment or be unexported (golint)
Error: receiver name source should be consistent with previous receiver name e for Emulator (golint)
Error: exported type `Config` should have comment or be unexported (golint)
Error: exported function `ForwardLogs` should have comment or be unexported (golint)
Error: exported function `ConfigureLogging` should have comment or be unexported (golint)
Error: comment on exported const `MaxNameLen` should be of the form `MaxNameLen ...` (golint)
Error: func LookupUid should be LookupUID (golint)
Error: exported function `GetPasswdPath` should have comment or be unexported (golint)
Error: exported function `GetPasswd` should have comment or be unexported (golint)
Error: exported function `GetGroupPath` should have comment or be unexported (golint)
Error: exported function `GetGroup` should have comment or be unexported (golint)
Error: exported function `CurrentUserSubUIDs` should have comment or be unexported (golint)
Error: exported function `CurrentUserSubGIDs` should have comment or be unexported (golint)
Error: exported function `CurrentProcessUIDMap` should have comment or be unexported (golint)
Error: exported function `CurrentProcessGIDMap` should have comment or be unexported (golint)
Error: exported type `User` should have comment or be unexported (golint)
Error: struct field `Uid` should be `UID` (golint)
Error: exported type `Group` should have comment or be unexported (golint)
Error: exported function `ParsePasswdFile` should have comment or be unexported (golint)
From the above:
Error: don't use underscores in Go names; type Stat_t should be StatT (golint)
Error: func LookupUid should be LookupUID (golint)
Error: struct field `Uid` should be `UID` (golint)
Error: struct field `Uid` should be `UID` (golint)
Note that golint has been depracted, and replaced by revive:
level=warning msg="[runner] The linter 'golint' is deprecated (since v1.41.0) due to: The repository of the linter has been archived by the owner. Replaced by revive."
Remaining ones:
To discuss: (rename or add nolint comments?)
libcontainer/user/lookup_unix.go:31:6: var-naming: func LookupUid should be LookupUID (revive)
libcontainer/user/user.go:30:2: var-naming: struct field Uid should be UID (revive)
libcontainer/user/user.go:214:2: var-naming: struct field Uid should be UID (revive)
libcontainer/devices/device.go:23:2: var-naming: struct field Uid should be UID (revive)
libcontainer/configs/cgroup_linux.go:60:2: var-naming: struct field CpuShares should be CPUShares (revive)
libcontainer/configs/cgroup_linux.go:63:2: var-naming: struct field CpuQuota should be CPUQuota (revive)
libcontainer/configs/cgroup_linux.go:66:2: var-naming: struct field CpuPeriod should be CPUPeriod (revive)
libcontainer/configs/cgroup_linux.go:69:2: var-naming: struct field CpuRtRuntime should be CPURtRuntime (revive)
libcontainer/configs/cgroup_linux.go:72:2: var-naming: struct field CpuRtPeriod should be CPURtPeriod (revive)
libcontainer/configs/cgroup_linux.go:125:2: var-naming: struct field CpuWeight should be CPUWeight (revive)
libcontainer/configs/config.go:159:2: var-naming: struct field UidMappings should be UIDMappings (revive)
libcontainer/cgroups/stats.go:16:6: var-naming: type CpuUsage should be CPUUsage (revive)
libcontainer/cgroups/stats.go:37:6: var-naming: type CpuStats should be CPUStats (revive)
libcontainer/cgroups/stats.go:38:2: var-naming: struct field CpuUsage should be CPUUsage (revive)
libcontainer/cgroups/stats.go:150:2: var-naming: struct field CpuStats should be CPUStats (revive)
types/events.go:60:6: var-naming: type CpuUsage should be CPUUsage (revive)
types/events.go:70:6: var-naming: type Cpu should be CPU (revive)
libcontainer/cgroups/fs/cpu.go:16:6: var-naming: type CpuGroup should be CPUGroup (revive)
libcontainer/error.go:12:2: var-naming: const IdInUse should be IDInUse (revive)
libcontainer/error.go:13:2: var-naming: const InvalidIdFormat should be InvalidIDFormat (revive)
libcontainer/criu_opts_linux.go:20:2: var-naming: struct field TcpEstablished should be TCPEstablished (revive)
libcontainer/init_linux.go:65:2: var-naming: struct field ContainerId should be ContainerID (revive)
To discuss: (rename or add nolint comments?)
I think renaming is fine and make sense (unless we're changing public API, it which case we need to see how many users are there, how easy is for them to adapt etc.)
@kolyshkin (forgot to ping you); last commit is a quick renamed of variables to the correct capitalisation. There's some inconsistency in CRIU vs Criu (looks like the CRIU sdk itself uses the "wrong" casing). Thought I'd just rename them all for discussion.
Needs rebase