Skip to content

Commit 116b5c4

Browse files
authored
Lint comments (prometheus#422)
* Add `godot` linter to validate comments. * Clenup a bunch of comments. * Replace deprecated golint with revive. Signed-off-by: SuperQ <[email protected]>
1 parent 081c329 commit 116b5c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+170
-162
lines changed

.golangci.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
---
22
linters:
33
enable:
4-
- golint
4+
- godot
5+
- revive
6+
7+
linter-settings:
8+
godot:
9+
capital: true
10+
exclude:
11+
# Ignore "See: URL"
12+
- 'See:'

arp.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ import (
2121
"strings"
2222
)
2323

24-
// Learned from include/uapi/linux/if_arp.h
24+
// Learned from include/uapi/linux/if_arp.h.
2525
const (
26-
// completed entry (ha valid)
26+
// completed entry (ha valid).
2727
ATFComplete = 0x02
28-
// permanent entry
28+
// permanent entry.
2929
ATFPermanent = 0x04
30-
// Publish entry
30+
// Publish entry.
3131
ATFPublish = 0x08
32-
// Has requested trailers
32+
// Has requested trailers.
3333
ATFUseTrailers = 0x10
34-
// Obsoleted: Want to use a netmask (only for proxy entries)
34+
// Obsoleted: Want to use a netmask (only for proxy entries).
3535
ATFNetmask = 0x20
36-
// Don't answer this addresses
36+
// Don't answer this addresses.
3737
ATFDontPublish = 0x40
3838
)
3939

@@ -110,7 +110,7 @@ func parseARPEntry(columns []string) (ARPEntry, error) {
110110
return entry, nil
111111
}
112112

113-
// IsComplete returns true if ARP entry is marked with complete flag
113+
// IsComplete returns true if ARP entry is marked with complete flag.
114114
func (entry *ARPEntry) IsComplete() bool {
115115
return entry.Flags&ATFComplete != 0
116116
}

bcache/bcache.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type Stats struct {
2929
}
3030

3131
// BcacheStats contains statistics tied to a bcache ID.
32-
type BcacheStats struct { // nolint:golint
32+
type BcacheStats struct { // nolint:revive
3333
AverageKeySize uint64
3434
BtreeCacheSize uint64
3535
CacheAvailablePercent uint64

bcache/get.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ func NewFS(mountPoint string) (FS, error) {
5151
return FS{&fs}, nil
5252
}
5353

54-
// Stats is a wrapper around stats()
55-
// It returns full available statistics
54+
// Stats is a wrapper around stats().
55+
// It returns full available statistics.
5656
func (fs FS) Stats() ([]*Stats, error) {
5757
return fs.stats(true)
5858
}

blockdevice/stats.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ import (
2525
"github.com/prometheus/procfs/internal/fs"
2626
)
2727

28-
// Info contains identifying information for a block device such as a disk drive
28+
// Info contains identifying information for a block device such as a disk drive.
2929
type Info struct {
3030
MajorNumber uint32
3131
MinorNumber uint32
3232
DeviceName string
3333
}
3434

35-
// IOStats models the iostats data described in the kernel documentation
36-
// https://www.kernel.org/doc/Documentation/iostats.txt,
37-
// https://www.kernel.org/doc/Documentation/block/stat.txt,
38-
// and https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats
35+
// IOStats models the iostats data described in the kernel documentation.
36+
// - https://www.kernel.org/doc/Documentation/iostats.txt,
37+
// - https://www.kernel.org/doc/Documentation/block/stat.txt
38+
// - https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats
3939
type IOStats struct {
4040
// ReadIOs is the number of reads completed successfully.
4141
ReadIOs uint64
@@ -76,7 +76,7 @@ type IOStats struct {
7676
TimeSpentFlushing uint64
7777
}
7878

79-
// Diskstats combines the device Info and IOStats
79+
// Diskstats combines the device Info and IOStats.
8080
type Diskstats struct {
8181
Info
8282
IOStats
@@ -220,7 +220,7 @@ func NewFS(procMountPoint string, sysMountPoint string) (FS, error) {
220220
}
221221

222222
// ProcDiskstats reads the diskstats file and returns
223-
// an array of Diskstats (one per line/device)
223+
// an array of Diskstats (one per line/device).
224224
func (fs FS) ProcDiskstats() ([]Diskstats, error) {
225225
file, err := os.Open(fs.proc.Path(procDiskstatsPath))
226226
if err != nil {
@@ -266,7 +266,7 @@ func (fs FS) ProcDiskstats() ([]Diskstats, error) {
266266
return diskstats, scanner.Err()
267267
}
268268

269-
// SysBlockDevices lists the device names from /sys/block/<dev>
269+
// SysBlockDevices lists the device names from /sys/block/<dev>.
270270
func (fs FS) SysBlockDevices() ([]string, error) {
271271
deviceDirs, err := ioutil.ReadDir(fs.sys.Path(sysBlockPath))
272272
if err != nil {

btrfs/get.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (fs FS) Stats() ([]*Stats, error) {
8080
return stats, nil
8181
}
8282

83-
// GetStats collects all Btrfs statistics from sysfs
83+
// GetStats collects all Btrfs statistics from sysfs.
8484
func GetStats(uuidPath string) (*Stats, error) {
8585
r := &reader{path: uuidPath}
8686
s := r.readFilesystemStats()
@@ -162,7 +162,7 @@ func (r *reader) readAllocationStats(d string) (a *AllocationStats) {
162162
return
163163
}
164164

165-
// readLayouts reads all Btrfs layout statistics for the current path
165+
// readLayouts reads all Btrfs layout statistics for the current path.
166166
func (r *reader) readLayouts() map[string]*LayoutUsage {
167167
files, err := ioutil.ReadDir(r.path)
168168
if err != nil {

cpuinfo.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"github.com/prometheus/procfs/internal/util"
2828
)
2929

30-
// CPUInfo contains general information about a system CPU found in /proc/cpuinfo
30+
// CPUInfo contains general information about a system CPU found in /proc/cpuinfo.
3131
type CPUInfo struct {
3232
Processor uint
3333
VendorID string
@@ -469,7 +469,7 @@ func parseCPUInfoDummy(_ []byte) ([]CPUInfo, error) { // nolint:unused,deadcode
469469
}
470470

471471
// firstNonEmptyLine advances the scanner to the first non-empty line
472-
// and returns the contents of that line
472+
// and returns the contents of that line.
473473
func firstNonEmptyLine(scanner *bufio.Scanner) string {
474474
for scanner.Scan() {
475475
line := scanner.Text()

internal/fs/fs.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const (
2626
// DefaultSysMountPoint is the common mount point of the sys filesystem.
2727
DefaultSysMountPoint = "/sys"
2828

29-
// DefaultConfigfsMountPoint is the common mount point of the configfs
29+
// DefaultConfigfsMountPoint is the common mount point of the configfs.
3030
DefaultConfigfsMountPoint = "/sys/kernel/config"
3131
)
3232

iscsi/get.go

+8-9
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import (
2626
"github.com/prometheus/procfs/internal/util"
2727
)
2828

29-
// GetStats is the main iscsi status information func
30-
// building the path and prepare info for enable iscsi
29+
// GetStats is the main iscsi status information func for
30+
// building the path and prepare info for enable iscsi.
3131
func GetStats(iqnPath string) (*Stats, error) {
3232
var istats Stats
3333

@@ -58,8 +58,7 @@ func GetStats(iqnPath string) (*Stats, error) {
5858
return &istats, nil
5959
}
6060

61-
// isPathEnable is a utility function
62-
// check if the file "enable" contain enable message
61+
// isPathEnable checks if the file "enable" contain enable message.
6362
func isPathEnable(path string) (bool, error) {
6463
enableReadout, err := ioutil.ReadFile(filepath.Join(path, "enable"))
6564
if err != nil {
@@ -104,7 +103,7 @@ func getLunLinkTarget(lunPath string) (lunObject LUN, err error) {
104103
}
105104

106105
// ReadWriteOPS read and return the stat of read and write in megabytes,
107-
// and total commands that send to the target
106+
// and total commands that send to the target.
108107
func ReadWriteOPS(iqnPath string, tpgt string, lun string) (readmb uint64,
109108
writemb uint64, iops uint64, err error) {
110109

@@ -133,7 +132,7 @@ func ReadWriteOPS(iqnPath string, tpgt string, lun string) (readmb uint64,
133132
}
134133

135134
// GetFileioUdev is getting the actual info to build up
136-
// the FILEIO data and match with the enable target
135+
// the FILEIO data and match with the enable target.
137136
func (fs FS) GetFileioUdev(fileioNumber string, objectName string) (*FILEIO, error) {
138137
fileio := FILEIO{
139138
Name: "fileio_" + fileioNumber,
@@ -155,7 +154,7 @@ func (fs FS) GetFileioUdev(fileioNumber string, objectName string) (*FILEIO, err
155154
}
156155

157156
// GetIblockUdev is getting the actual info to build up
158-
// the IBLOCK data and match with the enable target
157+
// the IBLOCK data and match with the enable target.
159158
func (fs FS) GetIblockUdev(iblockNumber string, objectName string) (*IBLOCK, error) {
160159
iblock := IBLOCK{
161160
Name: "iblock_" + iblockNumber,
@@ -177,7 +176,7 @@ func (fs FS) GetIblockUdev(iblockNumber string, objectName string) (*IBLOCK, err
177176
}
178177

179178
// GetRBDMatch is getting the actual info to build up
180-
// the RBD data and match with the enable target
179+
// the RBD data and match with the enable target.
181180
func (fs FS) GetRBDMatch(rbdNumber string, poolImage string) (*RBD, error) {
182181
rbd := RBD{
183182
Name: "rbd_" + rbdNumber,
@@ -222,7 +221,7 @@ func (fs FS) GetRBDMatch(rbdNumber string, poolImage string) (*RBD, error) {
222221
return nil, nil
223222
}
224223

225-
// GetRDMCPPath is getting the actual info to build up RDMCP data
224+
// GetRDMCPPath is getting the actual info to build up RDMCP data.
226225
func (fs FS) GetRDMCPPath(rdmcpNumber string, objectName string) (*RDMCP, error) {
227226
rdmcp := RDMCP{
228227
Name: "rd_mcp_" + rdmcpNumber,

iscsi/iscsi.go

+14-16
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,19 @@ import (
2323

2424
// iscsi target started with /sys/kernel/config/target/iscsi/iqn*
2525
// configfs + target/iscsi/iqn*
26-
// iqnGlob is representing all the possible IQN
26+
// iqnGlob is representing all the possible IQN.
2727
const iqnGlob = "target/iscsi/iqn*"
2828

2929
// targetCore static path /sys/kernel/config/target/core for node_exporter
30-
// reading runtime status
30+
// reading runtime status.
3131
const targetCore = "target/core"
3232

3333
// devicePath static path /sys/devices/rbd/[0-9]* for rbd devices to
34-
// read at runtime status
34+
// read at runtime status.
3535
const devicePath = "devices/rbd"
3636

3737
// FS represents the pseudo-filesystem configfs, which provides an interface to
38-
// iscsi kernel data structures in
39-
// sysfs as /sys
40-
// configfs as /sys/kernel/config
38+
// iscsi kernel data structures in sysfs as /sys and configfs as /sys/kernel/config.
4139
type FS struct {
4240
sysfs *fs.FS
4341
configfs *fs.FS
@@ -46,7 +44,7 @@ type FS struct {
4644
// NewFS returns a new configfs mounted under the given mount point. It will
4745
// error and return empty FS if the mount point can't be read. For the ease of
4846
// use, an empty string parameter configfsMountPoint will call internal fs for
49-
// the default sys path as /sys/kernel/config
47+
// the default sys path as /sys/kernel/config.
5048
func NewFS(sysfsPath string, configfsMountPoint string) (FS, error) {
5149
if strings.TrimSpace(sysfsPath) == "" {
5250
sysfsPath = fs.DefaultSysMountPoint
@@ -65,12 +63,12 @@ func NewFS(sysfsPath string, configfsMountPoint string) (FS, error) {
6563
return FS{&sysfs, &configfs}, nil
6664
}
6765

68-
// helper function to get configfs path
66+
// Path is a helper function to get configfs path.
6967
func (fs FS) Path(p ...string) string {
7068
return fs.configfs.Path(p...)
7169
}
7270

73-
// ISCSIStats getting iscsi runtime information
71+
// ISCSIStats getting iscsi runtime information.
7472
func (fs FS) ISCSIStats() ([]*Stats, error) {
7573
matches, err := filepath.Glob(fs.configfs.Path(iqnGlob))
7674
if err != nil {
@@ -90,15 +88,15 @@ func (fs FS) ISCSIStats() ([]*Stats, error) {
9088
return stats, nil
9189
}
9290

93-
// TPGT struct for sys target portal group tag info
91+
// TPGT struct for sys target portal group tag info.
9492
type TPGT struct {
9593
Name string // name of the tpgt group
9694
TpgtPath string // file path of tpgt
9795
IsEnable bool // is the tpgt enable
9896
Luns []LUN // the Luns that tpgt has
9997
}
10098

101-
// LUN struct for sys logical unit number info
99+
// LUN struct for sys logical unit number info.
102100
type LUN struct {
103101
Name string // name of the lun
104102
LunPath string // file path of the lun
@@ -107,37 +105,37 @@ type LUN struct {
107105
TypeNumber string // place holder for number of the device
108106
}
109107

110-
// FILEIO struct for backstore info
108+
// FILEIO struct for backstore info.
111109
type FILEIO struct {
112110
Name string // name of the fileio
113111
Fnumber string // number related to the backstore
114112
ObjectName string // place holder for object in iscsi object
115113
Filename string // link to the actual file being export
116114
}
117115

118-
// IBLOCK struct for backstore info
116+
// IBLOCK struct for backstore info.
119117
type IBLOCK struct {
120118
Name string // name of the iblock
121119
Bnumber string // number related to the backstore
122120
ObjectName string // place holder for object in iscsi object
123121
Iblock string // link to the actual block being export
124122
}
125123

126-
// RBD struct for backstore info
124+
// RBD struct for backstore info.
127125
type RBD struct {
128126
Name string // name of the rbd
129127
Rnumber string // number related to the backstore
130128
Pool string // place holder for the rbd pool
131129
Image string // place holder for the rbd image
132130
}
133131

134-
// RDMCP struct for backstore info
132+
// RDMCP struct for backstore info.
135133
type RDMCP struct {
136134
Name string // name of the rdm_cp
137135
ObjectName string // place holder for object name
138136
}
139137

140-
// Stats struct for all targets info
138+
// Stats struct for all targets info.
141139
type Stats struct {
142140
Name string
143141
Tpgt []TPGT

loadavg.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"github.com/prometheus/procfs/internal/util"
2222
)
2323

24-
// LoadAvg represents an entry in /proc/loadavg
24+
// LoadAvg represents an entry in /proc/loadavg.
2525
type LoadAvg struct {
2626
Load1 float64
2727
Load5 float64

0 commit comments

Comments
 (0)