Skip to content

Commit

Permalink
Fix lint after golangci-lint 1.52 update (#279)
Browse files Browse the repository at this point in the history
Summary:
As per title.

Pull Request resolved: #279

Test Plan: unittests

Reviewed By: leoleovich

Differential Revision: D44293708

Pulled By: abulimov

fbshipit-source-id: 28c2cf7f316ce7f4f2875cc247bf73084825ab2a
  • Loading branch information
abulimov authored and facebook-github-bot committed Mar 22, 2023
1 parent 5a7de15 commit 0b3295f
Show file tree
Hide file tree
Showing 16 changed files with 25 additions and 48 deletions.
6 changes: 6 additions & 0 deletions .golangci.yml
Expand Up @@ -16,3 +16,9 @@ linters:
- unparam # unused function parameters
- usestdlibvars # possibility to use variables/constants from the Go standard library
- whitespace # leading and trailing whitespace
issues:
exclude-rules:
# not worth it
- path: _test\.go
linters:
- revive
3 changes: 1 addition & 2 deletions calnex/api/api.go
Expand Up @@ -468,9 +468,8 @@ func (a *API) FetchCsv(channel Channel, allData bool) ([][]string, error) {
if err != nil {
if errors.Is(err, io.EOF) {
break
} else {
return nil, fmt.Errorf("failed to parse csv for data from channel %s: %w", channel.String(), err)
}
return nil, fmt.Errorf("failed to parse csv for data from channel %s: %w", channel.String(), err)
}
res = append(res, csvLine)
}
Expand Down
5 changes: 1 addition & 4 deletions cmd/ntpcheck/checker/chrony.go
Expand Up @@ -56,10 +56,7 @@ func (c *chronyConn) Close() error {
if err := os.RemoveAll(c.local); err != nil {
return err
}
if err := c.Conn.Close(); err != nil {
return err
}
return nil
return c.Conn.Close()
}

type chronyClient interface {
Expand Down
6 changes: 1 addition & 5 deletions cmd/ntpcheck/cmd/utils.go
Expand Up @@ -238,11 +238,7 @@ func addFakeSecondZoneInfo(srcfile, dstfile string, offsetMonth int) error {

defer o.Close()

if err := leapsectz.Write(o, '2', ls, ""); err != nil {
return err
}

return nil
return leapsectz.Write(o, '2', ls, "")
}

// cli vars
Expand Down
5 changes: 1 addition & 4 deletions cmd/ziffy/node/sender.go
Expand Up @@ -243,10 +243,7 @@ func (s *Sender) sendEventMsg(p ptp.Packet, ptpConn int, ptpAddr unix.Sockaddr)
if err != nil {
return err
}
if err := unix.Sendto(ptpConn, b, 0, ptpAddr); err != nil {
return err
}
return nil
return unix.Sendto(ptpConn, b, 0, ptpAddr)
}

func (s *Sender) monitorIcmp(conn net.PacketConn) {
Expand Down
5 changes: 1 addition & 4 deletions fbclock/daemon/config.go
Expand Up @@ -46,10 +46,7 @@ func (c *Config) EvalAndValidate() error {
if c.Interval > time.Minute {
return fmt.Errorf("bad config: 'interval' is over a minute")
}
if err := c.Math.Prepare(); err != nil {
return err
}
return nil
return c.Math.Prepare()
}

// ReadConfig reads config and unmarshals it from yaml into Config
Expand Down
2 changes: 1 addition & 1 deletion fbclock/daemon/json_stats.go
Expand Up @@ -47,7 +47,7 @@ func (s *JSONStats) Start(monitoringport int) {
}

// handleRequest is a handler used for all http monitoring requests
func (s *JSONStats) handleRequest(w http.ResponseWriter, r *http.Request) {
func (s *JSONStats) handleRequest(w http.ResponseWriter, _ *http.Request) {
js, err := json.Marshal(s.counters)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
Expand Down
4 changes: 1 addition & 3 deletions leaphash/leaphash.go
Expand Up @@ -45,9 +45,7 @@ func Compute(data string) string {
// "#$" - last modification time
// "#@" - the expiration time of the file
filtered += strings.Map(filterBlanks, lines[i][2:len(lines[i])])
} else if strings.HasPrefix(lines[i], "#") {
// comment
} else {
} else if !strings.HasPrefix(lines[i], "#") {
// leap second lines, without comments and without any blank characters
line := lines[i]

Expand Down
2 changes: 1 addition & 1 deletion ntp/responder/stats/json.go
Expand Up @@ -60,7 +60,7 @@ func (j *JSONStats) toMap() (export map[string]int64) {
}

// handleRequest is a handler used for all http monitoring requests
func (j *JSONStats) handleRequest(w http.ResponseWriter, r *http.Request) {
func (j *JSONStats) handleRequest(w http.ResponseWriter, _ *http.Request) {
js, err := json.Marshal(j.toMap())
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
Expand Down
2 changes: 1 addition & 1 deletion ptp/c4u/stats/json.go
Expand Up @@ -64,7 +64,7 @@ func (s *JSONStats) Snapshot() {
}

// handleRequest is a handler used for all http monitoring requests
func (s *JSONStats) handleRequest(w http.ResponseWriter, r *http.Request) {
func (s *JSONStats) handleRequest(w http.ResponseWriter, _ *http.Request) {
js, err := json.Marshal(s.report.toMap())
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
Expand Down
2 changes: 1 addition & 1 deletion ptp/linearizability/linearizability_sptp.go
Expand Up @@ -115,7 +115,7 @@ func (lt *SPTPTester) Close() error {
// RunTest performs one Tester run and will exit on completion.
// The result of the test will be returned, including any error arising during the test.
// Warning: the listener must be started via RunListener before calling this function.
func (lt *SPTPTester) RunTest(ctx context.Context) TestResult {
func (lt *SPTPTester) RunTest(_ context.Context) TestResult {
result := SPTPTestResult{
Server: lt.cfg.Server,
Error: nil,
Expand Down
5 changes: 1 addition & 4 deletions ptp/protocol/management.go
Expand Up @@ -139,10 +139,7 @@ func (p *Management) MarshalBinaryToBuf(bytes io.Writer) error {
}
return binary.Write(bytes, binary.BigEndian, b)
}
if err := binary.Write(bytes, binary.BigEndian, p.TLV); err != nil {
return err
}
return nil
return binary.Write(bytes, binary.BigEndian, p.TLV)
}

// MarshalBinary converts packet to []bytes
Expand Down
2 changes: 1 addition & 1 deletion ptp/ptp4u/stats/json.go
Expand Up @@ -75,7 +75,7 @@ func (s *JSONStats) Snapshot() {
}

// handleRequest is a handler used for all http monitoring requests
func (s *JSONStats) handleRequest(w http.ResponseWriter, r *http.Request) {
func (s *JSONStats) handleRequest(w http.ResponseWriter, _ *http.Request) {
js, err := json.Marshal(s.report.toMap())
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
Expand Down
4 changes: 2 additions & 2 deletions ptp/sptp/client/clock.go
Expand Up @@ -126,12 +126,12 @@ func (c *SysClock) MaxFreqPPB() (float64, error) {
type FreeRunningClock struct{}

// AdjFreqPPB adjusts PHC frequency
func (c *FreeRunningClock) AdjFreqPPB(freqPPB float64) error {
func (c *FreeRunningClock) AdjFreqPPB(_ float64) error {
return nil
}

// Step jumps time on PHC
func (c *FreeRunningClock) Step(step time.Duration) error {
func (c *FreeRunningClock) Step(_ time.Duration) error {
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions ptp/sptp/client/json_stats.go
Expand Up @@ -48,7 +48,7 @@ func (s *JSONStats) Start(monitoringport int) {
}

// handleRootRequest is a handler used for all http monitoring requests
func (s *JSONStats) handleRootRequest(w http.ResponseWriter, r *http.Request) {
func (s *JSONStats) handleRootRequest(w http.ResponseWriter, _ *http.Request) {
js, err := json.Marshal(s.GetStats())
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
Expand All @@ -61,7 +61,7 @@ func (s *JSONStats) handleRootRequest(w http.ResponseWriter, r *http.Request) {
}

// handleCountersRequest is a handler used for all http monitoring requests
func (s *JSONStats) handleCountersRequest(w http.ResponseWriter, r *http.Request) {
func (s *JSONStats) handleCountersRequest(w http.ResponseWriter, _ *http.Request) {
js, err := json.Marshal(s.GetCounters())
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
Expand Down
16 changes: 3 additions & 13 deletions timestamp/timestamp_linux.go
Expand Up @@ -114,11 +114,7 @@ func EnableSWTimestampsRx(connFd int) error {
flags := unix.SOF_TIMESTAMPING_RX_SOFTWARE |
unix.SOF_TIMESTAMPING_SOFTWARE
// Allow reading of SW timestamps via socket
if err := unix.SetsockoptInt(connFd, unix.SOL_SOCKET, timestamping, flags); err != nil {
return err
}

return nil
return unix.SetsockoptInt(connFd, unix.SOL_SOCKET, timestamping, flags)
}

// EnableSWTimestamps enables SW timestamps (TX and RX) on the socket
Expand All @@ -132,10 +128,7 @@ func EnableSWTimestamps(connFd int) error {
return err
}

if err := unix.SetsockoptInt(connFd, unix.SOL_SOCKET, unix.SO_SELECT_ERR_QUEUE, 1); err != nil {
return err
}
return nil
return unix.SetsockoptInt(connFd, unix.SOL_SOCKET, unix.SO_SELECT_ERR_QUEUE, 1)
}

// EnableHWTimestamps enables HW timestamps (TX and RX) on the socket
Expand All @@ -161,10 +154,7 @@ func EnableHWTimestamps(connFd int, iface string) error {
return err
}

if err := unix.SetsockoptInt(connFd, unix.SOL_SOCKET, unix.SO_SELECT_ERR_QUEUE, 1); err != nil {
return err
}
return nil
return unix.SetsockoptInt(connFd, unix.SOL_SOCKET, unix.SO_SELECT_ERR_QUEUE, 1)
}

func waitForHWTS(connFd int) error {
Expand Down

0 comments on commit 0b3295f

Please sign in to comment.