18 msformat208 mscheck 321total 24errors 134warnings 163notes

byteview.go8

1:1formatfile is not formatted

byteview.go:1:1

1/*
2Copyright 2012 Google Inc.
  • Fix (safe): run `strider fmt byteview.go`
17:9package-commentspackage should have a documentation comment

byteview.go:17:9

16
17package groupcache
18
32:6exported-declaration-commentexported type should have a comment beginning with its name

byteview.go:32:6

31// a pointer (like a time.Time).
32type ByteView struct {
33 // If b is non-nil, b is used, else s is used.
96:19exported-declaration-commentexported function or method should have a comment beginning with its name

byteview.go:96:19

95// b2.
96func (v ByteView) Equal(b2 ByteView) bool {
97 if b2.b == nil {
105:19exported-declaration-commentexported function or method should have a comment beginning with its name

byteview.go:105:19

104// in s.
105func (v ByteView) EqualString(s string) bool {
106 if v.b == nil {
123:19exported-declaration-commentexported function or method should have a comment beginning with its name

byteview.go:123:19

122// in b2.
123func (v ByteView) EqualBytes(b2 []byte) bool {
124 if v.b != nil {
159:2no-naked-returnreturn values must be explicit

byteview.go:159:2

158 }
159 return
160}
174:2no-naked-returnreturn values must be explicit

byteview.go:174:2

173 n = int64(m)
174 return
175}

byteview_test.go23

1:1formatfile is not formatted

byteview_test.go:1:1

1/*
2Copyright 2012 Google Inc.
  • Fix (safe): run `strider fmt byteview_test.go`
27:6cognitive-complexityfunction has cognitive complexity 24; maximum is 7

byteview_test.go:27:6

26
27func TestByteView(t *testing.T) {
28 for _, s := range []string{"", "x", "yy"} {
27:6cyclomatic-complexityfunction complexity is 13; maximum is 10

byteview_test.go:27:6

26
27func TestByteView(t *testing.T) {
28 for _, s := range []string{"", "x", "yy"} {
27:6test-parallelismconsider calling t.Parallel() when this test begins

byteview_test.go:27:6

26
27func TestByteView(t *testing.T) {
28 for _, s := range []string{"", "x", "yy"} {
60:11use-anyuse any instead of interface{}

byteview_test.go:60:11

59// of returns a byte view of the []byte or string in x.
60func of(x interface{}) ByteView {
61 if bytes, ok := x.([]byte); ok {
61:5import-shadowingidentifier bytes shadows an imported package

byteview_test.go:61:5

60func of(x interface{}) ByteView {
61 if bytes, ok := x.([]byte); ok {
62 return ByteView{b: bytes}
64:22unchecked-type-assertionuse the checked two-result form of the type assertion

byteview_test.go:64:22

63 }
64 return ByteView{s: x.(string)}
65}
67:6cognitive-complexityfunction has cognitive complexity 11; maximum is 7

byteview_test.go:67:6

66
67func TestByteViewEqual(t *testing.T) {
68 tests := []struct {
67:6test-parallelismconsider calling t.Parallel() when this test begins

byteview_test.go:67:6

66
67func TestByteViewEqual(t *testing.T) {
68 tests := []struct {
68:13nested-structsmove nested anonymous struct types to named declarations

byteview_test.go:68:13

67func TestByteViewEqual(t *testing.T) {
68 tests := []struct {
69 a interface{} // string or []byte
69:8use-anyuse any instead of interface{}

byteview_test.go:69:8

68 tests := []struct {
69 a interface{} // string or []byte
70 b interface{} // string or []byte
70:8use-anyuse any instead of interface{}

byteview_test.go:70:8

69 a interface{} // string or []byte
70 b interface{} // string or []byte
71 want bool
73:9add-constantstring literal "x" appears more than twice; define a constant

byteview_test.go:73:9

72 }{
73 {"x", "x", true},
74 {"x", "y", false},
78:24add-constantstring literal "yy" appears more than twice; define a constant

byteview_test.go:78:24

77 {[]byte("x"), []byte("y"), false},
78 {[]byte("x"), []byte("yy"), false},
79 {[]byte("x"), "x", true},
80:17add-constantstring literal "y" appears more than twice; define a constant

byteview_test.go:80:17

79 {[]byte("x"), "x", true},
80 {[]byte("x"), "y", false},
81 {[]byte("x"), "yy", false},
88:6import-shadowingidentifier bytes shadows an imported package

byteview_test.go:88:6

87 va := of(tt.a)
88 if bytes, ok := tt.b.([]byte); ok {
89 if got := va.EqualBytes(bytes); got != tt.want {
93:33unchecked-type-assertionuse the checked two-result form of the type assertion

byteview_test.go:93:33

92 } else {
93 if got := va.EqualString(tt.b.(string)); got != tt.want {
94 t.Errorf("%d. EqualString = %v; want %v", i, got, tt.want)
103:6cognitive-complexityfunction has cognitive complexity 9; maximum is 7

byteview_test.go:103:6

102
103func TestByteViewSlice(t *testing.T) {
104 tests := []struct {
103:6test-parallelismconsider calling t.Parallel() when this test begins

byteview_test.go:103:6

102
103func TestByteViewSlice(t *testing.T) {
104 tests := []struct {
104:13nested-structsmove nested anonymous struct types to named declarations

byteview_test.go:104:13

103func TestByteViewSlice(t *testing.T) {
104 tests := []struct {
105 in string
107:8use-anyuse any instead of interface{}

byteview_test.go:107:8

106 from int
107 to interface{} // nil to mean the end (SliceFrom); else int
108 want string
122:10add-constantstring literal "abc" appears more than twice; define a constant

byteview_test.go:122:10

121 {
122 in: "abc",
123 to: 2,
131:31unchecked-type-assertionuse the checked two-result form of the type assertion

byteview_test.go:131:31

130 if tt.to != nil {
131 v = v.Slice(tt.from, tt.to.(int))
132 } else {

consistenthash/consistenthash.go4

1:1formatfile is not formatted

consistenthash/consistenthash.go:1:1

1/*
2Copyright 2013 Google Inc.
  • Fix (safe): run `strider fmt consistenthash/consistenthash.go`
26:6exported-declaration-commentexported type should have a comment beginning with its name

consistenthash/consistenthash.go:26:6

25
26type Hash func(data []byte) uint32
27
28:6exported-declaration-commentexported type should have a comment beginning with its name

consistenthash/consistenthash.go:28:6

27
28type Map struct {
29 hash Hash
35:6exported-declaration-commentexported function or method should have a comment beginning with its name

consistenthash/consistenthash.go:35:6

34
35func New(replicas int, fn Hash) *Map {
36 m := &Map{

consistenthash/consistenthash_test.go12

1:1formatfile is not formatted

consistenthash/consistenthash_test.go:1:1

1/*
2Copyright 2013 Google Inc.
  • Fix (safe): run `strider fmt consistenthash/consistenthash_test.go`
25:6test-parallelismconsider calling t.Parallel() when this test begins

consistenthash/consistenthash_test.go:25:6

24
25func TestHashing(t *testing.T) {
26
42:9add-constantstring literal "2" appears more than twice; define a constant

consistenthash/consistenthash_test.go:42:9

41 testCases := map[string]string{
42 "2": "2",
43 "11": "2",
50:13error-stringserror string should not be capitalized or end with punctuation

consistenthash/consistenthash_test.go:50:13

49 if hash.Get(k) != v {
50 t.Errorf("Asking for %s, should have yielded %s", k, v)
51 }
62:13error-stringserror string should not be capitalized or end with punctuation

consistenthash/consistenthash_test.go:62:13

61 if hash.Get(k) != v {
62 t.Errorf("Asking for %s, should have yielded %s", k, v)
63 }
68:6test-parallelismconsider calling t.Parallel() when this test begins

consistenthash/consistenthash_test.go:68:6

67
68func TestConsistency(t *testing.T) {
69 hash1 := New(1, nil)
76:12error-stringserror string should not be capitalized or end with punctuation

consistenthash/consistenthash_test.go:76:12

75 if hash1.Get("Ben") != hash2.Get("Ben") {
76 t.Errorf("Fetching 'Ben' from both hashes should be the same")
77 }
79:21add-constantstring literal "Ben" appears more than twice; define a constant

consistenthash/consistenthash_test.go:79:21

78
79 hash2.Add("Becky", "Ben", "Bobby")
80
81:5optimize-operands-orderplace the cheaper logical operand first to improve short-circuiting

consistenthash/consistenthash_test.go:81:5

80
81 if hash1.Get("Ben") != hash2.Get("Ben") ||
82 hash1.Get("Bob") != hash2.Get("Bob") ||
82:13add-constantstring literal "Bob" appears more than twice; define a constant

consistenthash/consistenthash_test.go:82:13

81 if hash1.Get("Ben") != hash2.Get("Ben") ||
82 hash1.Get("Bob") != hash2.Get("Bob") ||
83 hash1.Get("Bonny") != hash2.Get("Bonny") {
83:13add-constantstring literal "Bonny" appears more than twice; define a constant

consistenthash/consistenthash_test.go:83:13

82 hash1.Get("Bob") != hash2.Get("Bob") ||
83 hash1.Get("Bonny") != hash2.Get("Bonny") {
84 t.Errorf("Direct matches should always return the same entry")
84:12error-stringserror string should not be capitalized or end with punctuation

consistenthash/consistenthash_test.go:84:12

83 hash1.Get("Bonny") != hash2.Get("Bonny") {
84 t.Errorf("Direct matches should always return the same entry")
85 }

groupcache.go41

1:1file-length-limitfile has 503 lines; maximum is 500

groupcache.go:1:1

1/*
2Copyright 2012 Google Inc.
1:1formatfile is not formatted

groupcache.go:1:1

1/*
2Copyright 2012 Google Inc.
  • Fix (safe): run `strider fmt groupcache.go`
41:6exported-declaration-commentexported type should have a comment beginning with its name

groupcache.go:41:6

40// A Getter loads data for a key.
41type Getter interface {
42 // Get returns the value identified by key, populating dest.
52:6exported-declaration-commentexported type should have a comment beginning with its name

groupcache.go:52:6

51// A GetterFunc implements Getter with a function.
52type GetterFunc func(ctx context.Context, key string, dest Sink) error
53
54:21exported-declaration-commentexported function or method should have a comment beginning with its name

groupcache.go:54:21

53
54func (f GetterFunc) Get(ctx context.Context, key string, dest Sink) error {
55 return f(ctx, key, dest)
58:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

groupcache.go:58:1

57
58var (
59 mu sync.RWMutex
59:2no-package-varpackage variables introduce mutable global state

groupcache.go:59:2

58var (
59 mu sync.RWMutex
60 groups = make(map[string]*Group)
60:2no-package-varpackage variables introduce mutable global state

groupcache.go:60:2

59 mu sync.RWMutex
60 groups = make(map[string]*Group)
61
62:2no-package-varpackage variables introduce mutable global state

groupcache.go:62:2

61
62 initPeerServerOnce sync.Once
63 initPeerServer func()
63:2no-package-varpackage variables introduce mutable global state

groupcache.go:63:2

62 initPeerServerOnce sync.Once
63 initPeerServer func()
64)
68:6exported-declaration-commentexported function or method should have a comment beginning with its name

groupcache.go:68:6

67// nil if there's no such group.
68func GetGroup(name string) *Group {
69 mu.RLock()
84:6exported-declaration-commentexported function or method should have a comment beginning with its name

groupcache.go:84:6

83// The group name must be unique for each getter.
84func NewGroup(name string, cacheBytes int64, getter Getter) *Group {
85 return newGroup(name, cacheBytes, getter, nil)
89:6confusing-namingname newGroup differs from NewGroup only by capitalization

groupcache.go:89:6

88// If peers is nil, the peerPicker is called via a sync.Once to initialize it.
89func newGroup(name string, cacheBytes int64, getter Getter, peers PeerPicker) *Group {
90 if getter == nil {
114:5no-package-varpackage variables introduce mutable global state

groupcache.go:114:5

113// newGroupHook, if non-nil, is called right after a new group is created.
114var newGroupHook func(*Group)
115
118:6exported-declaration-commentexported function or method should have a comment beginning with its name

groupcache.go:118:6

117// a group is created.
118func RegisterNewGroupHook(fn func(*Group)) {
119 if newGroupHook != nil {
127:6exported-declaration-commentexported function or method should have a comment beginning with its name

groupcache.go:127:6

126// group is created.
127func RegisterServerStart(fn func()) {
128 if initPeerServer != nil {
142:6exported-declaration-commentexported type should have a comment beginning with its name

groupcache.go:142:6

141// a group of 1 or more machines.
142type Group struct {
143 name string
177:2import-shadowingidentifier rand shadows an imported package

groupcache.go:177:2

176 // to get predictable results in TestPeers.
177 rand *rand.Rand
178}
185:28use-anyuse any instead of interface{}

groupcache.go:185:28

184 // Done is called when Do is done.
185 Do(key string, fn func() (interface{}, error)) (interface{}, error)
186}
185:50use-anyuse any instead of interface{}

groupcache.go:185:50

184 // Done is called when Do is done.
185 Do(key string, fn func() (interface{}, error)) (interface{}, error)
186}
212:17exported-declaration-commentexported function or method should have a comment beginning with its name

groupcache.go:212:17

211
212func (g *Group) Get(ctx context.Context, key string, dest Sink) error {
213 g.peersOnce.Do(g.initPeers)
243:44use-anyuse any instead of interface{}

groupcache.go:243:44

242 g.Stats.Loads.Add(1)
243 viewi, err := g.loadGroup.Do(key, func() (interface{}, error) {
244 // Check the cache again because singleflight can only dedup calls
279:4task-commentTODO comment should be resolved or linked to an owned work item

groupcache.go:279:4

278 g.Stats.PeerErrors.Add(1)
279 // TODO(bradfitz): log the peer's error? keep
280 // log of the past few for /groupcachez? It's
295:16unchecked-type-assertionuse the checked two-result form of the type assertion

groupcache.go:295:16

294 if err == nil {
295 value = viewi.(ByteView)
296 }
297:2no-naked-returnreturn values must be explicit

groupcache.go:297:2

296 }
297 return
298}
319:2task-commentTODO comment should be resolved or linked to an owned work item

groupcache.go:319:2

318 value := ByteView{b: res.Value}
319 // TODO(bradfitz): use res.MinuteQps or something smart to
320 // conditionally populate hotCache. For now just do it some
336:3no-naked-returnreturn values must be explicit

groupcache.go:336:3

335 if g.cacheBytes <= 0 {
336 return
337 }
340:3no-naked-returnreturn values must be explicit

groupcache.go:340:3

339 if ok {
340 return
341 }
343:2no-naked-returnreturn values must be explicit

groupcache.go:343:2

342 value, ok = g.hotCache.get(key)
343 return
344}
360:3task-commentTODO comment should be resolved or linked to an owned work item

groupcache.go:360:3

359
360 // TODO(bradfitz): this is good-enough-for-now logic.
361 // It should be something based on measurements and/or
377:2exported-declaration-commentexported declaration should have a comment beginning with its name

groupcache.go:377:2

376 // owner for.
377 MainCache CacheType = iota + 1
378
382:2exported-declaration-commentexported declaration should have a comment beginning with its name

groupcache.go:382:2

381 // owner.
382 HotCache
383)
387:2single-case-switchswitch with one case can be replaced by an if statement

groupcache.go:387:2

386func (g *Group) CacheStats(which CacheType) CacheStats {
387 switch which {
388 case MainCache:
403:2import-shadowingidentifier lru shadows an imported package

groupcache.go:403:2

402 nbytes int64 // of all keys and values
403 lru *lru.Cache
404 nhit, nget int64
425:39use-anyuse any instead of interface{}

groupcache.go:425:39

424 c.lru = &lru.Cache{
425 OnEvicted: func(key lru.Key, value interface{}) {
426 val := value.(ByteView)
426:17unchecked-type-assertionuse the checked two-result form of the type assertion

groupcache.go:426:17

425 OnEvicted: func(key lru.Key, value interface{}) {
426 val := value.(ByteView)
427 c.nbytes -= int64(len(key.(string))) + int64(val.Len())
427:30unchecked-type-assertionuse the checked two-result form of the type assertion

groupcache.go:427:30

426 val := value.(ByteView)
427 c.nbytes -= int64(len(key.(string))) + int64(val.Len())
428 c.nevict++
441:3no-naked-returnreturn values must be explicit

groupcache.go:441:3

440 if c.lru == nil {
441 return
442 }
445:3no-naked-returnreturn values must be explicit

groupcache.go:445:3

444 if !ok {
445 return
446 }
448:11unchecked-type-assertionuse the checked two-result form of the type assertion

groupcache.go:448:11

447 c.nhit++
448 return vi.(ByteView), true
449}
479:6exported-declaration-commentexported type should have a comment beginning with its name

groupcache.go:479:6

478// An AtomicInt is an int64 to be accessed atomically.
479type AtomicInt int64
480

groupcache_test.go40

1:1formatfile is not formatted

groupcache_test.go:1:1

1/*
2Copyright 2012 Google Inc.
  • Fix (safe): run `strider fmt groupcache_test.go`
33:2deprecated-api-usagegithub.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead.

groupcache_test.go:33:2

32
33 "github.com/golang/protobuf/proto"
34
36:2redundant-import-aliasimport alias is identical to the package name

groupcache_test.go:36:2

35 pb "github.com/golang/groupcache/groupcachepb"
36 testpb "github.com/golang/groupcache/testpb"
37)
40:2no-package-varpackage variables introduce mutable global state

groupcache_test.go:40:2

39var (
40 once sync.Once
41 stringGroup, protoGroup Getter
41:2no-package-varpackage variables introduce mutable global state

groupcache_test.go:41:2

40 once sync.Once
41 stringGroup, protoGroup Getter
42
41:15no-package-varpackage variables introduce mutable global state

groupcache_test.go:41:15

40 once sync.Once
41 stringGroup, protoGroup Getter
42
43:2no-package-varpackage variables introduce mutable global state

groupcache_test.go:43:2

42
43 stringc = make(chan string)
44
45:2no-package-varpackage variables introduce mutable global state

groupcache_test.go:45:2

44
45 dummyCtx = context.TODO()
46
50:2no-package-varpackage variables introduce mutable global state

groupcache_test.go:50:2

49 // cacheFills function.
50 cacheFills AtomicInt
51)
53:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

groupcache_test.go:53:1

52
53const (
54 stringGroupName = "string-group"
84:6cognitive-complexityfunction has cognitive complexity 9; maximum is 7

groupcache_test.go:84:6

83// outstanding callers. This is the string variant.
84func TestGetDupSuppressString(t *testing.T) {
85 once.Do(testSetup)
84:6test-parallelismconsider calling t.Parallel() when this test begins

groupcache_test.go:84:6

83// outstanding callers. This is the string variant.
84func TestGetDupSuppressString(t *testing.T) {
85 once.Do(testSetup)
103:2task-commentTODO comment should be resolved or linked to an owned work item

groupcache_test.go:103:2

102 // singleflight.
103 // TODO(bradfitz): decide whether there are any non-offensive
104 // debug/test hooks that could be added to singleflight to
126:6cognitive-complexityfunction has cognitive complexity 9; maximum is 7

groupcache_test.go:126:6

125// outstanding callers. This is the proto variant.
126func TestGetDupSuppressProto(t *testing.T) {
127 once.Do(testSetup)
126:6test-parallelismconsider calling t.Parallel() when this test begins

groupcache_test.go:126:6

125// outstanding callers. This is the proto variant.
126func TestGetDupSuppressProto(t *testing.T) {
127 once.Do(testSetup)
144:2task-commentTODO comment should be resolved or linked to an owned work item

groupcache_test.go:144:2

143 // singleflight.
144 // TODO(bradfitz): decide whether there are any non-offensive
145 // debug/test hooks that could be added to singleflight to
174:6test-parallelismconsider calling t.Parallel() when this test begins

groupcache_test.go:174:6

173
174func TestCaching(t *testing.T) {
175 once.Do(testSetup)
189:6test-parallelismconsider calling t.Parallel() when this test begins

groupcache_test.go:189:6

188
189func TestCacheEviction(t *testing.T) {
190 once.Do(testSetup)
205:18unchecked-type-assertionuse the checked two-result form of the type assertion

groupcache_test.go:205:18

204
205 g := stringGroup.(*Group)
206 evict0 := g.mainCache.nevict
214:3discarded-error-resulterror result returned by stringGroup.Get is discarded

groupcache_test.go:214:3

213 key := fmt.Sprintf("dummy-key-%d", bytesFlooded)
214 stringGroup.Get(dummyCtx, key, StringSink(&res))
215 bytesFlooded += int64(len(key) + len(res))
234:20exported-declaration-commentexported function or method should have a comment beginning with its name

groupcache_test.go:234:20

233
234func (p *fakePeer) Get(_ context.Context, in *pb.GetRequest, out *pb.GetResponse) error {
235 p.hits++
239:2modifies-parameterassignment modifies parameter out

groupcache_test.go:239:2

238 }
239 out.Value = []byte("got:" + in.GetKey())
240 return nil
245:20exported-declaration-commentexported function or method should have a comment beginning with its name

groupcache_test.go:245:20

244
245func (p fakePeers) PickPeer(key string) (peer ProtoGetter, ok bool) {
246 if len(p) == 0 {
247:3no-naked-returnreturn values must be explicit

groupcache_test.go:247:3

246 if len(p) == 0 {
247 return
248 }
254:6cognitive-complexityfunction has cognitive complexity 8; maximum is 7

groupcache_test.go:254:6

253// TestPeers tests that peers (virtual, in-process) are hit, and how much.
254func TestPeers(t *testing.T) {
255 once.Do(testSetup)
254:6test-parallelismconsider calling t.Parallel() when this test begins

groupcache_test.go:254:6

253// TestPeers tests that peers (virtual, in-process) are hit, and how much.
254func TestPeers(t *testing.T) {
255 once.Do(testSetup)
277:12add-constantstring literal "got:" appears more than twice; define a constant

groupcache_test.go:277:12

276 key := fmt.Sprintf("key-%d", i)
277 want := "got:" + key
278 var got string
312:2task-commentTODO comment should be resolved or linked to an owned work item

groupcache_test.go:312:2

311 // With one of the peers being down.
312 // TODO(bradfitz): on a peer number being unavailable, the
313 // consistent hashing should maybe keep trying others to
325:6test-parallelismconsider calling t.Parallel() when this test begins

groupcache_test.go:325:6

324
325func TestTruncatingByteSliceTarget(t *testing.T) {
326 var buf [100]byte
344:6test-parallelismconsider calling t.Parallel() when this test begins

groupcache_test.go:344:6

343
344func TestAllocatingByteSliceTarget(t *testing.T) {
345 var dst []byte
349:2discarded-error-resulterror result returned by sink.SetBytes is discarded

groupcache_test.go:349:2

348 inBytes := []byte("some bytes")
349 sink.SetBytes(inBytes)
350 if want := "some bytes"; string(dst) != want {
351:12error-stringserror string should not be capitalized or end with punctuation

groupcache_test.go:351:12

350 if want := "some bytes"; string(dst) != want {
351 t.Errorf("SetBytes resulted in %q; want %q", dst, want)
352 }
378:30exported-declaration-commentexported function or method should have a comment beginning with its name

groupcache_test.go:378:30

377
378func (g *orderedFlightGroup) Do(key string, fn func() (interface{}, error)) (interface{}, error) {
379 <-g.stage1
378:56use-anyuse any instead of interface{}

groupcache_test.go:378:56

377
378func (g *orderedFlightGroup) Do(key string, fn func() (interface{}, error)) (interface{}, error) {
379 <-g.stage1
378:78use-anyuse any instead of interface{}

groupcache_test.go:378:78

377
378func (g *orderedFlightGroup) Do(key string, fn func() (interface{}, error)) (interface{}, error) {
379 <-g.stage1
388:6cognitive-complexityfunction has cognitive complexity 8; maximum is 7

groupcache_test.go:388:6

387// unable to dedup calls.
388func TestNoDedup(t *testing.T) {
389 const testkey = "testkey"
388:6test-parallelismconsider calling t.Parallel() when this test begins

groupcache_test.go:388:6

387// unable to dedup calls.
388func TestNoDedup(t *testing.T) {
389 const testkey = "testkey"
413:13add-constantstring literal "ERROR:" appears more than twice; define a constant

groupcache_test.go:413:13

412 if err := g.Get(dummyCtx, testkey, StringSink(&s)); err != nil {
413 resc <- "ERROR:" + err.Error()
414 return
448:6test-parallelismconsider calling t.Parallel() when this test begins

groupcache_test.go:448:6

447
448func TestGroupStatsAlignment(t *testing.T) {
449 var g Group
456:1task-commentTODO comment should be resolved or linked to an owned work item

groupcache_test.go:456:1

455
456// TODO(bradfitz): port the Google-internal full integration test into here,
457// using HTTP requests instead of our RPC system.

groupcachepb/groupcache.pb.go21

1:1formatfile is not formatted

groupcachepb/groupcache.pb.go:1:1

1// Code generated by protoc-gen-go.
2// source: groupcache.proto
  • Fix (safe): run `strider fmt groupcachepb/groupcache.pb.go`
5:9filename-formatfilename does not match the supported Go filename format

groupcachepb/groupcache.pb.go:5:9

4
5package groupcachepb
6
5:9package-commentspackage should have a documentation comment

groupcachepb/groupcache.pb.go:5:9

4
5package groupcachepb
6
7:8redundant-import-aliasimport alias is identical to the package name

groupcachepb/groupcache.pb.go:7:8

6
7import proto "github.com/golang/protobuf/proto"
8import json "encoding/json"
7:14deprecated-api-usagegithub.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead.

groupcachepb/groupcache.pb.go:7:14

6
7import proto "github.com/golang/protobuf/proto"
8import json "encoding/json"
8:8redundant-import-aliasimport alias is identical to the package name

groupcachepb/groupcache.pb.go:8:8

7import proto "github.com/golang/protobuf/proto"
8import json "encoding/json"
9import math "math"
9:8redundant-import-aliasimport alias is identical to the package name

groupcachepb/groupcache.pb.go:9:8

8import json "encoding/json"
9import math "math"
10
16:6exported-declaration-commentexported type should have a comment beginning with its name

groupcachepb/groupcache.pb.go:16:6

15
16type GetRequest struct {
17 Group *string `protobuf:"bytes,1,req,name=group" json:"group,omitempty"`
19:2var-namingidentifier should use MixedCaps rather than underscores

groupcachepb/groupcache.pb.go:19:2

18 Key *string `protobuf:"bytes,2,req,name=key" json:"key,omitempty"`
19 XXX_unrecognized []byte `json:"-"`
20}
22:22exported-declaration-commentexported function or method should have a comment beginning with its name

groupcachepb/groupcache.pb.go:22:22

21
22func (m *GetRequest) Reset() { *m = GetRequest{} }
23func (m *GetRequest) String() string { return proto.CompactTextString(m) }
24:20exported-declaration-commentexported function or method should have a comment beginning with its name

groupcachepb/groupcache.pb.go:24:20

23func (m *GetRequest) String() string { return proto.CompactTextString(m) }
24func (*GetRequest) ProtoMessage() {}
25
26:22exported-declaration-commentexported function or method should have a comment beginning with its name

groupcachepb/groupcache.pb.go:26:22

25
26func (m *GetRequest) GetGroup() string {
27 if m != nil && m.Group != nil {
33:22exported-declaration-commentexported function or method should have a comment beginning with its name

groupcachepb/groupcache.pb.go:33:22

32
33func (m *GetRequest) GetKey() string {
34 if m != nil && m.Key != nil {
40:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

groupcachepb/groupcache.pb.go:40:1

39
40type GetResponse struct {
41 Value []byte `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"`
40:6exported-declaration-commentexported type should have a comment beginning with its name

groupcachepb/groupcache.pb.go:40:6

39
40type GetResponse struct {
41 Value []byte `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"`
43:2var-namingidentifier should use MixedCaps rather than underscores

groupcachepb/groupcache.pb.go:43:2

42 MinuteQps *float64 `protobuf:"fixed64,2,opt,name=minute_qps" json:"minute_qps,omitempty"`
43 XXX_unrecognized []byte `json:"-"`
44}
46:23exported-declaration-commentexported function or method should have a comment beginning with its name

groupcachepb/groupcache.pb.go:46:23

45
46func (m *GetResponse) Reset() { *m = GetResponse{} }
47func (m *GetResponse) String() string { return proto.CompactTextString(m) }
48:21exported-declaration-commentexported function or method should have a comment beginning with its name

groupcachepb/groupcache.pb.go:48:21

47func (m *GetResponse) String() string { return proto.CompactTextString(m) }
48func (*GetResponse) ProtoMessage() {}
49
50:23exported-declaration-commentexported function or method should have a comment beginning with its name

groupcachepb/groupcache.pb.go:50:23

49
50func (m *GetResponse) GetValue() []byte {
51 if m != nil {
57:23exported-declaration-commentexported function or method should have a comment beginning with its name

groupcachepb/groupcache.pb.go:57:23

56
57func (m *GetResponse) GetMinuteQps() float64 {
58 if m != nil && m.MinuteQps != nil {
64:6no-initreplace init with explicit initialization

groupcachepb/groupcache.pb.go:64:6

63
64func init() {
65}

http.go16

1:1formatfile is not formatted

http.go:1:1

1/*
2Copyright 2013 Google Inc.
  • Fix (safe): run `strider fmt http.go`
17:9package-commentspackage should have a documentation comment

http.go:17:9

16
17package groupcache
18
31:2deprecated-api-usagegithub.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead.

http.go:31:2

30 pb "github.com/golang/groupcache/groupcachepb"
31 "github.com/golang/protobuf/proto"
32)
80:6exported-declaration-commentexported function or method should have a comment beginning with its name

http.go:80:6

79// for example "http://example.net:8000".
80func NewHTTPPool(self string) *HTTPPool {
81 p := NewHTTPPoolOpts(self, nil)
86:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

http.go:86:1

85
86var httpPoolMade bool
87
86:5no-package-varpackage variables introduce mutable global state

http.go:86:5

85
86var httpPoolMade bool
87
91:6exported-declaration-commentexported function or method should have a comment beginning with its name

http.go:91:6

90// The returned *HTTPPool implements http.Handler and must be registered using http.Handle.
91func NewHTTPPoolOpts(self string, o *HTTPPoolOptions) *HTTPPool {
92 if httpPoolMade {
119:20exported-declaration-commentexported function or method should have a comment beginning with its name

http.go:119:20

118// for example "http://example.net:8000".
119func (p *HTTPPool) Set(peers ...string) {
120 p.mu.Lock()
126:25range-value-addresstaking the address of range value peer can be misleading

http.go:126:25

125 for _, peer := range peers {
126 p.httpGetters[peer] = &httpGetter{transport: p.Transport, baseURL: peer + p.opts.BasePath}
127 }
130:20exported-declaration-commentexported function or method should have a comment beginning with its name

http.go:130:20

129
130func (p *HTTPPool) PickPeer(key string) (ProtoGetter, bool) {
131 p.mu.Lock()
183:2discarded-error-resulterror result returned by w.Write is discarded

http.go:183:2

182 w.Header().Set("Content-Type", "application/x-protobuf")
183 w.Write(body)
184}
191:5no-package-varpackage variables introduce mutable global state

http.go:191:5

190
191var bufferPool = sync.Pool{
192 New: func() interface{} { return new(bytes.Buffer) },
192:14use-anyuse any instead of interface{}

http.go:192:14

191var bufferPool = sync.Pool{
192 New: func() interface{} { return new(bytes.Buffer) },
193}
195:22exported-declaration-commentexported function or method should have a comment beginning with its name

http.go:195:22

194
195func (h *httpGetter) Get(ctx context.Context, in *pb.GetRequest, out *pb.GetResponse) error {
196 u := fmt.Sprintf(
202:30standard-http-method-constantreplace the HTTP method literal with http.MethodGet

http.go:202:30

201 )
202 req, err := http.NewRequest("GET", u, nil)
203 if err != nil {
219:23unchecked-type-assertionuse the checked two-result form of the type assertion

http.go:219:23

218 }
219 b := bufferPool.Get().(*bytes.Buffer)
220 b.Reset()

http_test.go17

1:1formatfile is not formatted

http_test.go:1:1

1/*
2Copyright 2013 Google Inc.
  • Fix (safe): run `strider fmt http_test.go`
36:2no-package-varpackage variables introduce mutable global state

http_test.go:36:2

35var (
36 peerAddrs = flag.String("test_peer_addrs", "", "Comma-separated list of peer addresses; used by TestHTTPPool")
37 peerIndex = flag.Int("test_peer_index", -1, "Index of which peer this child is; used by TestHTTPPool")
37:2no-package-varpackage variables introduce mutable global state

http_test.go:37:2

36 peerAddrs = flag.String("test_peer_addrs", "", "Comma-separated list of peer addresses; used by TestHTTPPool")
37 peerIndex = flag.Int("test_peer_index", -1, "Index of which peer this child is; used by TestHTTPPool")
38 peerChild = flag.Bool("test_peer_child", false, "True if running as a child process; used by TestHTTPPool")
38:2no-package-varpackage variables introduce mutable global state

http_test.go:38:2

37 peerIndex = flag.Int("test_peer_index", -1, "Index of which peer this child is; used by TestHTTPPool")
38 peerChild = flag.Bool("test_peer_child", false, "True if running as a child process; used by TestHTTPPool")
39)
41:6cognitive-complexityfunction has cognitive complexity 13; maximum is 7

http_test.go:41:6

40
41func TestHTTPPool(t *testing.T) {
42 if *peerChild {
41:6test-parallelismconsider calling t.Parallel() when this test begins

http_test.go:41:6

40
41func TestHTTPPool(t *testing.T) {
42 if *peerChild {
44:3deep-exitprocess-exit calls should be confined to main or init

http_test.go:44:3

43 beChildForTestHTTPPool()
44 os.Exit(0)
45 }
76:5discarded-error-resulterror result returned by cmds[i].Process.Kill is discarded

http_test.go:76:5

75 if cmds[i].Process != nil {
76 cmds[i].Process.Kill()
77 }
100:13error-stringserror string should not be capitalized or end with punctuation

http_test.go:100:13

99 if suffix := ":" + key; !strings.HasSuffix(value, suffix) {
100 t.Errorf("Get(%q) = %q, want value ending in %q", key, value, suffix)
101 }
111:2no-naked-returnreturn values must be explicit

http_test.go:111:2

110 }
111 return
112}
117:19insecure-url-schemeURL uses insecure http scheme

http_test.go:117:19

116
117 p := NewHTTPPool("http://" + addrs[*peerIndex])
118 p.Set(addrToURL(addrs)...)
121:3discarded-error-resulterror result returned by dest.SetString is discarded

http_test.go:121:3

120 getter := GetterFunc(func(ctx context.Context, key string, dest Sink) error {
121 dest.SetString(strconv.Itoa(*peerIndex) + ":" + key)
122 return nil
126:2deep-exitprocess-exit calls should be confined to main or init

http_test.go:126:2

125
126 log.Fatal(http.ListenAndServe(addrs[*peerIndex], p))
127}
145:12insecure-url-schemeURL uses insecure http scheme

http_test.go:145:12

144 for i := range addr {
145 url[i] = "http://" + addr[i]
146 }
150:21unused-parameterparameter t is unused

http_test.go:150:21

149
150func awaitAddrReady(t *testing.T, addr string, wg *sync.WaitGroup) {
151 defer wg.Done()
152:8redefines-builtin-ididentifier max shadows a predeclared identifier

http_test.go:152:8

151 defer wg.Done()
152 const max = 1 * time.Second
153 tries := 0
158:4discarded-error-resulterror result returned by c.Close is discarded

http_test.go:158:4

157 if err == nil {
158 c.Close()
159 return

lru/lru.go18

1:1formatfile is not formatted

lru/lru.go:1:1

1/*
2Copyright 2013 Google Inc.
  • Fix (safe): run `strider fmt lru/lru.go`
30:32use-anyuse any instead of interface{}

lru/lru.go:30:32

29 // executed when an entry is purged from the cache.
30 OnEvicted func(key Key, value interface{})
31
33:12use-anyuse any instead of interface{}

lru/lru.go:33:12

32 ll *list.List
33 cache map[interface{}]*list.Element
34}
36:1doc-comment-perioddocumentation comment should end with punctuation

lru/lru.go:36:1

35
36// A Key may be any value that is comparable. See http://golang.org/ref/spec#Comparison_operators
37type Key interface{}
37:6exported-declaration-commentexported type should have a comment beginning with its name

lru/lru.go:37:6

36// A Key may be any value that is comparable. See http://golang.org/ref/spec#Comparison_operators
37type Key interface{}
38
37:10use-anyuse any instead of interface{}

lru/lru.go:37:10

36// A Key may be any value that is comparable. See http://golang.org/ref/spec#Comparison_operators
37type Key interface{}
38
41:8use-anyuse any instead of interface{}

lru/lru.go:41:8

40 key Key
41 value interface{}
42}
47:6exported-declaration-commentexported function or method should have a comment beginning with its name

lru/lru.go:47:6

46// that eviction is done by the caller.
47func New(maxEntries int) *Cache {
48 return &Cache{
51:24use-anyuse any instead of interface{}

lru/lru.go:51:24

50 ll: list.New(),
51 cache: make(map[interface{}]*list.Element),
52 }
56:36use-anyuse any instead of interface{}

lru/lru.go:56:36

55// Add adds a value to the cache.
56func (c *Cache) Add(key Key, value interface{}) {
57 if c.cache == nil {
58:22use-anyuse any instead of interface{}

lru/lru.go:58:22

57 if c.cache == nil {
58 c.cache = make(map[interface{}]*list.Element)
59 c.ll = list.New()
63:11unchecked-type-assertionuse the checked two-result form of the type assertion

lru/lru.go:63:11

62 c.ll.MoveToFront(ee)
63 ee.Value.(*entry).value = value
64 return
74:37use-anyuse any instead of interface{}

lru/lru.go:74:37

73// Get looks up a key's value from the cache.
74func (c *Cache) Get(key Key) (value interface{}, ok bool) {
75 if c.cache == nil {
76:3no-naked-returnreturn values must be explicit

lru/lru.go:76:3

75 if c.cache == nil {
76 return
77 }
80:19unchecked-type-assertionuse the checked two-result form of the type assertion

lru/lru.go:80:19

79 c.ll.MoveToFront(ele)
80 return ele.Value.(*entry).value, true
81 }
82:2no-naked-returnreturn values must be explicit

lru/lru.go:82:2

81 }
82 return
83}
108:15unchecked-type-assertionuse the checked two-result form of the type assertion

lru/lru.go:108:15

107 c.ll.Remove(e)
108 kv := e.Value.(*entry)
109 delete(c.cache, kv.key)
127:17unchecked-type-assertionuse the checked two-result form of the type assertion

lru/lru.go:127:17

126 for _, e := range c.cache {
127 kv := e.Value.(*entry)
128 c.OnEvicted(kv.key, kv.value)

lru/lru_test.go11

1:1formatfile is not formatted

lru/lru_test.go:1:1

1/*
2Copyright 2013 Google Inc.
  • Fix (safe): run `strider fmt lru/lru_test.go`
34:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

lru/lru_test.go:34:1

33
34var getTests = []struct {
35 name string
34:5no-package-varpackage variables introduce mutable global state

lru/lru_test.go:34:5

33
34var getTests = []struct {
35 name string
34:18nested-structsmove nested anonymous struct types to named declarations

lru/lru_test.go:34:18

33
34var getTests = []struct {
35 name string
36:13use-anyuse any instead of interface{}

lru/lru_test.go:36:13

35 name string
36 keyToAdd interface{}
37 keyToGet interface{}
37:13use-anyuse any instead of interface{}

lru/lru_test.go:37:13

36 keyToAdd interface{}
37 keyToGet interface{}
38 expectedOk bool
48:6test-parallelismconsider calling t.Parallel() when this test begins

lru/lru_test.go:48:6

47
48func TestGet(t *testing.T) {
49 for _, tt := range getTests {
61:6test-parallelismconsider calling t.Parallel() when this test begins

lru/lru_test.go:61:6

60
61func TestRemove(t *testing.T) {
62 lru := New(0)
70:13add-constantstring literal "myKey" appears more than twice; define a constant

lru/lru_test.go:70:13

69
70 lru.Remove("myKey")
71 if _, ok := lru.Get("myKey"); ok {
76:6test-parallelismconsider calling t.Parallel() when this test begins

lru/lru_test.go:76:6

75
76func TestEvict(t *testing.T) {
77 evictedKeys := make([]Key, 0)
78:38use-anyuse any instead of interface{}

lru/lru_test.go:78:38

77 evictedKeys := make([]Key, 0)
78 onEvictedFun := func(key Key, value interface{}) {
79 evictedKeys = append(evictedKeys, key)

peers.go10

1:1formatfile is not formatted

peers.go:1:1

1/*
2Copyright 2012 Google Inc.
  • Fix (safe): run `strider fmt peers.go`
19:9package-commentspackage should have a documentation comment

peers.go:19:9

18
19package groupcache
20
37:6exported-declaration-commentexported type should have a comment beginning with its name

peers.go:37:6

36// the peer that owns a specific key.
37type PeerPicker interface {
38 // PickPeer returns the peer that owns the specific key
47:16exported-declaration-commentexported function or method should have a comment beginning with its name

peers.go:47:16

46
47func (NoPeers) PickPeer(key string) (peer ProtoGetter, ok bool) { return }
48
47:25unused-parameterparameter key is unused

peers.go:47:25

46
47func (NoPeers) PickPeer(key string) (peer ProtoGetter, ok bool) { return }
48
47:67no-naked-returnreturn values must be explicit

peers.go:47:67

46
47func (NoPeers) PickPeer(key string) (peer ProtoGetter, ok bool) { return }
48
49:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

peers.go:49:1

48
49var (
50 portPicker func(groupName string) PeerPicker
50:2no-package-varpackage variables introduce mutable global state

peers.go:50:2

49var (
50 portPicker func(groupName string) PeerPicker
51)
57:6exported-declaration-commentexported function or method should have a comment beginning with its name

peers.go:57:6

56// called exactly once, but not both.
57func RegisterPeerPicker(fn func() PeerPicker) {
58 if portPicker != nil {
69:6exported-declaration-commentexported function or method should have a comment beginning with its name

peers.go:69:6

68// called exactly once, but not both.
69func RegisterPerGroupPeerPicker(fn func(groupName string) PeerPicker) {
70 if portPicker != nil {

singleflight/singleflight.go5

26:6use-anyuse any instead of interface{}

singleflight/singleflight.go:26:6

25 wg sync.WaitGroup
26 val interface{}
27 err error
32:6exported-declaration-commentexported type should have a comment beginning with its name

singleflight/singleflight.go:32:6

31// units of work can be executed with duplicate suppression.
32type Group struct {
33 mu sync.Mutex // protects m
41:17exported-declaration-commentexported function or method should have a comment beginning with its name

singleflight/singleflight.go:41:17

40// original to complete and receives the same results.
41func (g *Group) Do(key string, fn func() (interface{}, error)) (interface{}, error) {
42 g.mu.Lock()
41:43use-anyuse any instead of interface{}

singleflight/singleflight.go:41:43

40// original to complete and receives the same results.
41func (g *Group) Do(key string, fn func() (interface{}, error)) (interface{}, error) {
42 g.mu.Lock()
41:65use-anyuse any instead of interface{}

singleflight/singleflight.go:41:65

40// original to complete and receives the same results.
41func (g *Group) Do(key string, fn func() (interface{}, error)) (interface{}, error) {
42 g.mu.Lock()

singleflight/singleflight_test.go13

28:6test-parallelismconsider calling t.Parallel() when this test begins

singleflight/singleflight_test.go:28:6

27
28func TestDo(t *testing.T) {
29 var g Group
30:32use-anyuse any instead of interface{}

singleflight/singleflight_test.go:30:32

29 var g Group
30 v, err := g.Do("key", func() (interface{}, error) {
31 return "bar", nil
34:12error-stringserror string should not be capitalized or end with punctuation

singleflight/singleflight_test.go:34:12

33 if got, want := fmt.Sprintf("%v (%T)", v, v), "bar (string)"; got != want {
34 t.Errorf("Do = %v; want %v", got, want)
35 }
37:12error-stringserror string should not be capitalized or end with punctuation

singleflight/singleflight_test.go:37:12

36 if err != nil {
37 t.Errorf("Do error = %v", err)
38 }
41:6test-parallelismconsider calling t.Parallel() when this test begins

singleflight/singleflight_test.go:41:6

40
41func TestDoErr(t *testing.T) {
42 var g Group
44:32use-anyuse any instead of interface{}

singleflight/singleflight_test.go:44:32

43 someErr := errors.New("some error")
44 v, err := g.Do("key", func() (interface{}, error) {
45 return nil, someErr
48:12error-stringserror string should not be capitalized or end with punctuation

singleflight/singleflight_test.go:48:12

47 if err != someErr {
48 t.Errorf("Do error = %v; want someErr", err)
49 }
55:6test-parallelismconsider calling t.Parallel() when this test begins

singleflight/singleflight_test.go:55:6

54
55func TestDoDupSuppress(t *testing.T) {
56 var g Group
59:16use-anyuse any instead of interface{}

singleflight/singleflight_test.go:59:16

58 var calls int32
59 fn := func() (interface{}, error) {
60 atomic.AddInt32(&calls, 1)
69:19add-constantstring literal "key" appears more than twice; define a constant

singleflight/singleflight_test.go:69:19

68 go func() {
69 v, err := g.Do("key", fn)
70 if err != nil {
71:14error-stringserror string should not be capitalized or end with punctuation

singleflight/singleflight_test.go:71:14

70 if err != nil {
71 t.Errorf("Do error: %v", err)
72 }
73:8unchecked-type-assertionuse the checked two-result form of the type assertion

singleflight/singleflight_test.go:73:8

72 }
73 if v.(string) != "bar" {
74 t.Errorf("got %q; want %q", v, "bar")
74:36add-constantstring literal "bar" appears more than twice; define a constant

singleflight/singleflight_test.go:74:36

73 if v.(string) != "bar" {
74 t.Errorf("got %q; want %q", v, "bar")
75 }

sinks.go25

1:1formatfile is not formatted

sinks.go:1:1

1/*
2Copyright 2012 Google Inc.
  • Fix (safe): run `strider fmt sinks.go`
17:9package-commentspackage should have a documentation comment

sinks.go:17:9

16
17package groupcache
18
22:2deprecated-api-usagegithub.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead.

sinks.go:22:2

21
22 "github.com/golang/protobuf/proto"
23)
29:6exported-declaration-commentexported type should have a comment beginning with its name

sinks.go:29:6

28// on success.
29type Sink interface {
30 // SetString sets the value to s.
73:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

sinks.go:73:1

72
73type stringSink struct {
74 sp *string
76:2task-commentTODO comment should be resolved or linked to an owned work item

sinks.go:76:2

75 v ByteView
76 // TODO(bradfitz): track whether any Sets were called.
77}
80:2task-commentTODO comment should be resolved or linked to an owned work item

sinks.go:80:2

79func (s *stringSink) view() (ByteView, error) {
80 // TODO(bradfitz): return an error if no Set was called
81 return s.v, nil
84:22exported-declaration-commentexported function or method should have a comment beginning with its name

sinks.go:84:22

83
84func (s *stringSink) SetString(v string) error {
85 s.v.b = nil
91:22exported-declaration-commentexported function or method should have a comment beginning with its name

sinks.go:91:22

90
91func (s *stringSink) SetBytes(v []byte) error {
92 return s.SetString(string(v))
95:22exported-declaration-commentexported function or method should have a comment beginning with its name

sinks.go:95:22

94
95func (s *stringSink) SetProto(m proto.Message) error {
96 b, err := proto.Marshal(m)
135:24exported-declaration-commentexported function or method should have a comment beginning with its name

sinks.go:135:24

134
135func (s *byteViewSink) SetProto(m proto.Message) error {
136 b, err := proto.Marshal(m)
144:24exported-declaration-commentexported function or method should have a comment beginning with its name

sinks.go:144:24

143
144func (s *byteViewSink) SetBytes(b []byte) error {
145 *s.dst = ByteView{b: cloneBytes(b)}
149:24exported-declaration-commentexported function or method should have a comment beginning with its name

sinks.go:149:24

148
149func (s *byteViewSink) SetString(v string) error {
150 *s.dst = ByteView{s: v}
172:21exported-declaration-commentexported function or method should have a comment beginning with its name

sinks.go:172:21

171
172func (s *protoSink) SetBytes(b []byte) error {
173 err := proto.Unmarshal(b, s.dst)
182:21exported-declaration-commentexported function or method should have a comment beginning with its name

sinks.go:182:21

181
182func (s *protoSink) SetString(v string) error {
183 b := []byte(v)
193:21exported-declaration-commentexported function or method should have a comment beginning with its name

sinks.go:193:21

192
193func (s *protoSink) SetProto(m proto.Message) error {
194 b, err := proto.Marshal(m)
198:2task-commentTODO comment should be resolved or linked to an owned work item

sinks.go:198:2

197 }
198 // TODO(bradfitz): optimize for same-task case more and write
199 // right through? would need to document ownership rules at
214:6exported-declaration-commentexported function or method should have a comment beginning with its name

sinks.go:214:6

213// it to *dst. The memory is not retained by groupcache.
214func AllocatingByteSliceSink(dst *[]byte) Sink {
215 return &allocBytesSink{dst: dst}
237:26exported-declaration-commentexported function or method should have a comment beginning with its name

sinks.go:237:26

236
237func (s *allocBytesSink) SetProto(m proto.Message) error {
238 b, err := proto.Marshal(m)
245:26exported-declaration-commentexported function or method should have a comment beginning with its name

sinks.go:245:26

244
245func (s *allocBytesSink) SetBytes(b []byte) error {
246 return s.setBytesOwned(cloneBytes(b))
259:26exported-declaration-commentexported function or method should have a comment beginning with its name

sinks.go:259:26

258
259func (s *allocBytesSink) SetString(v string) error {
260 if s.dst == nil {
273:6exported-declaration-commentexported function or method should have a comment beginning with its name

sinks.go:273:6

272// is shrunk to fit the number of bytes available.
273func TruncatingByteSliceSink(dst *[]byte) Sink {
274 return &truncBytesSink{dst: dst}
286:26exported-declaration-commentexported function or method should have a comment beginning with its name

sinks.go:286:26

285
286func (s *truncBytesSink) SetProto(m proto.Message) error {
287 b, err := proto.Marshal(m)
294:26exported-declaration-commentexported function or method should have a comment beginning with its name

sinks.go:294:26

293
294func (s *truncBytesSink) SetBytes(b []byte) error {
295 return s.setBytesOwned(cloneBytes(b))
311:26exported-declaration-commentexported function or method should have a comment beginning with its name

sinks.go:311:26

310
311func (s *truncBytesSink) SetString(v string) error {
312 if s.dst == nil {

testpb/test.pb.go57

1:1formatfile is not formatted

testpb/test.pb.go:1:1

1// Code generated by protoc-gen-go.
2// source: test.proto
  • Fix (safe): run `strider fmt testpb/test.pb.go`
5:9filename-formatfilename does not match the supported Go filename format

testpb/test.pb.go:5:9

4
5package testpb
6
5:9package-commentspackage should have a documentation comment

testpb/test.pb.go:5:9

4
5package testpb
6
7:8redundant-import-aliasimport alias is identical to the package name

testpb/test.pb.go:7:8

6
7import proto "github.com/golang/protobuf/proto"
8import json "encoding/json"
7:14deprecated-api-usagegithub.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead.

testpb/test.pb.go:7:14

6
7import proto "github.com/golang/protobuf/proto"
8import json "encoding/json"
8:8redundant-import-aliasimport alias is identical to the package name

testpb/test.pb.go:8:8

7import proto "github.com/golang/protobuf/proto"
8import json "encoding/json"
9import math "math"
9:8redundant-import-aliasimport alias is identical to the package name

testpb/test.pb.go:9:8

8import json "encoding/json"
9import math "math"
10
16:6exported-declaration-commentexported type should have a comment beginning with its name

testpb/test.pb.go:16:6

15
16type TestMessage struct {
17 Name *string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
19:2var-namingidentifier should use MixedCaps rather than underscores

testpb/test.pb.go:19:2

18 City *string `protobuf:"bytes,2,opt,name=city" json:"city,omitempty"`
19 XXX_unrecognized []byte `json:"-"`
20}
22:23exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:22:23

21
22func (m *TestMessage) Reset() { *m = TestMessage{} }
23func (m *TestMessage) String() string { return proto.CompactTextString(m) }
24:21exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:24:21

23func (m *TestMessage) String() string { return proto.CompactTextString(m) }
24func (*TestMessage) ProtoMessage() {}
25
26:23exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:26:23

25
26func (m *TestMessage) GetName() string {
27 if m != nil && m.Name != nil {
33:23exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:33:23

32
33func (m *TestMessage) GetCity() string {
34 if m != nil && m.City != nil {
40:1top-level-declaration-ordertop-level declarations should be ordered as const, var, type, then func

testpb/test.pb.go:40:1

39
40type TestRequest struct {
41 Lower *string `protobuf:"bytes,1,req,name=lower" json:"lower,omitempty"`
40:6exported-declaration-commentexported type should have a comment beginning with its name

testpb/test.pb.go:40:6

39
40type TestRequest struct {
41 Lower *string `protobuf:"bytes,1,req,name=lower" json:"lower,omitempty"`
43:2var-namingidentifier should use MixedCaps rather than underscores

testpb/test.pb.go:43:2

42 RepeatCount *int32 `protobuf:"varint,2,opt,name=repeat_count,def=1" json:"repeat_count,omitempty"`
43 XXX_unrecognized []byte `json:"-"`
44}
46:23exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:46:23

45
46func (m *TestRequest) Reset() { *m = TestRequest{} }
47func (m *TestRequest) String() string { return proto.CompactTextString(m) }
48:21exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:48:21

47func (m *TestRequest) String() string { return proto.CompactTextString(m) }
48func (*TestRequest) ProtoMessage() {}
49
50:7exported-declaration-commentexported declaration should have a comment beginning with its name

testpb/test.pb.go:50:7

49
50const Default_TestRequest_RepeatCount int32 = 1
51
50:7var-namingidentifier should use MixedCaps rather than underscores

testpb/test.pb.go:50:7

49
50const Default_TestRequest_RepeatCount int32 = 1
51
52:23exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:52:23

51
52func (m *TestRequest) GetLower() string {
53 if m != nil && m.Lower != nil {
59:23exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:59:23

58
59func (m *TestRequest) GetRepeatCount() int32 {
60 if m != nil && m.RepeatCount != nil {
66:6exported-declaration-commentexported type should have a comment beginning with its name

testpb/test.pb.go:66:6

65
66type TestResponse struct {
67 Value *string `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"`
68:2var-namingidentifier should use MixedCaps rather than underscores

testpb/test.pb.go:68:2

67 Value *string `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"`
68 XXX_unrecognized []byte `json:"-"`
69}
71:24exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:71:24

70
71func (m *TestResponse) Reset() { *m = TestResponse{} }
72func (m *TestResponse) String() string { return proto.CompactTextString(m) }
73:22exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:73:22

72func (m *TestResponse) String() string { return proto.CompactTextString(m) }
73func (*TestResponse) ProtoMessage() {}
74
75:24exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:75:24

74
75func (m *TestResponse) GetValue() string {
76 if m != nil && m.Value != nil {
82:6exported-declaration-commentexported type should have a comment beginning with its name

testpb/test.pb.go:82:6

81
82type CacheStats struct {
83 Items *int64 `protobuf:"varint,1,opt,name=items" json:"items,omitempty"`
88:2var-namingidentifier should use MixedCaps rather than underscores

testpb/test.pb.go:88:2

87 Evicts *int64 `protobuf:"varint,5,opt,name=evicts" json:"evicts,omitempty"`
88 XXX_unrecognized []byte `json:"-"`
89}
91:22exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:91:22

90
91func (m *CacheStats) Reset() { *m = CacheStats{} }
92func (m *CacheStats) String() string { return proto.CompactTextString(m) }
93:20exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:93:20

92func (m *CacheStats) String() string { return proto.CompactTextString(m) }
93func (*CacheStats) ProtoMessage() {}
94
95:22exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:95:22

94
95func (m *CacheStats) GetItems() int64 {
96 if m != nil && m.Items != nil {
102:22exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:102:22

101
102func (m *CacheStats) GetBytes() int64 {
103 if m != nil && m.Bytes != nil {
109:22exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:109:22

108
109func (m *CacheStats) GetGets() int64 {
110 if m != nil && m.Gets != nil {
116:22exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:116:22

115
116func (m *CacheStats) GetHits() int64 {
117 if m != nil && m.Hits != nil {
123:22exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:123:22

122
123func (m *CacheStats) GetEvicts() int64 {
124 if m != nil && m.Evicts != nil {
130:6exported-declaration-commentexported type should have a comment beginning with its name

testpb/test.pb.go:130:6

129
130type StatsResponse struct {
131 Gets *int64 `protobuf:"varint,1,opt,name=gets" json:"gets,omitempty"`
142:2var-namingidentifier should use MixedCaps rather than underscores

testpb/test.pb.go:142:2

141 LocalLoads *int64 `protobuf:"varint,11,opt,name=local_loads" json:"local_loads,omitempty"`
142 XXX_unrecognized []byte `json:"-"`
143}
145:25exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:145:25

144
145func (m *StatsResponse) Reset() { *m = StatsResponse{} }
146func (m *StatsResponse) String() string { return proto.CompactTextString(m) }
147:23exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:147:23

146func (m *StatsResponse) String() string { return proto.CompactTextString(m) }
147func (*StatsResponse) ProtoMessage() {}
148
149:25exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:149:25

148
149func (m *StatsResponse) GetGets() int64 {
150 if m != nil && m.Gets != nil {
156:25exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:156:25

155
156func (m *StatsResponse) GetCacheHits() int64 {
157 if m != nil && m.CacheHits != nil {
163:25exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:163:25

162
163func (m *StatsResponse) GetFills() int64 {
164 if m != nil && m.Fills != nil {
170:25exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:170:25

169
170func (m *StatsResponse) GetTotalAlloc() uint64 {
171 if m != nil && m.TotalAlloc != nil {
177:25exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:177:25

176
177func (m *StatsResponse) GetMainCache() *CacheStats {
178 if m != nil {
184:25exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:184:25

183
184func (m *StatsResponse) GetHotCache() *CacheStats {
185 if m != nil {
191:25exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:191:25

190
191func (m *StatsResponse) GetServerIn() int64 {
192 if m != nil && m.ServerIn != nil {
198:25exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:198:25

197
198func (m *StatsResponse) GetLoads() int64 {
199 if m != nil && m.Loads != nil {
205:25exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:205:25

204
205func (m *StatsResponse) GetPeerLoads() int64 {
206 if m != nil && m.PeerLoads != nil {
212:25exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:212:25

211
212func (m *StatsResponse) GetPeerErrors() int64 {
213 if m != nil && m.PeerErrors != nil {
219:25exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:219:25

218
219func (m *StatsResponse) GetLocalLoads() int64 {
220 if m != nil && m.LocalLoads != nil {
226:6exported-declaration-commentexported type should have a comment beginning with its name

testpb/test.pb.go:226:6

225
226type Empty struct {
227 XXX_unrecognized []byte `json:"-"`
226:6max-public-structsfile declares more than 5 exported structs

testpb/test.pb.go:226:6

225
226type Empty struct {
227 XXX_unrecognized []byte `json:"-"`
227:2var-namingidentifier should use MixedCaps rather than underscores

testpb/test.pb.go:227:2

226type Empty struct {
227 XXX_unrecognized []byte `json:"-"`
228}
230:17exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:230:17

229
230func (m *Empty) Reset() { *m = Empty{} }
231func (m *Empty) String() string { return proto.CompactTextString(m) }
232:15exported-declaration-commentexported function or method should have a comment beginning with its name

testpb/test.pb.go:232:15

231func (m *Empty) String() string { return proto.CompactTextString(m) }
232func (*Empty) ProtoMessage() {}
233
234:6no-initreplace init with explicit initialization

testpb/test.pb.go:234:6

233
234func init() {
235}