Skip to content

Commit 9e277f7

Browse files
committed
all: use "reports whether" consistently instead of "returns whether"
Follow-up for CL 147037 and after Brad noticed the "returns whether" pattern during the review of CL 150621. Go documentation style for boolean funcs is to say: // Foo reports whether ... func Foo() bool (rather than "returns whether") Created with: $ perl -i -npe 's/returns whether/reports whether/' $(git grep -l "returns whether" | grep -v vendor) Change-Id: I15fe9ff99180ad97750cd05a10eceafdb12dc0b4 Reviewed-on: https://go-review.googlesource.com/c/150918 Run-TryBot: Tobias Klauser <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent b397248 commit 9e277f7

Some content is hidden

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

51 files changed

+64
-64
lines changed

src/bytes/buffer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (b *Buffer) String() string {
6868
return string(b.buf[b.off:])
6969
}
7070

71-
// empty returns whether the unread portion of the buffer is empty.
71+
// empty reports whether the unread portion of the buffer is empty.
7272
func (b *Buffer) empty() bool { return len(b.buf) <= b.off }
7373

7474
// Len returns the number of bytes of the unread portion of the buffer;

src/cmd/cgo/gcc.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ func (p *Package) mangleName(n *Name) {
718718

719719
// rewriteCalls rewrites all calls that pass pointers to check that
720720
// they follow the rules for passing pointers between Go and C.
721-
// This returns whether the package needs to import unsafe as _cgo_unsafe.
721+
// This reports whether the package needs to import unsafe as _cgo_unsafe.
722722
func (p *Package) rewriteCalls(f *File) bool {
723723
needsUnsafe := false
724724
// Walk backward so that in C.f1(C.f2()) we rewrite C.f2 first.
@@ -941,7 +941,7 @@ func (p *Package) rewriteCall(f *File, call *Call) (string, bool) {
941941
return sb.String(), needsUnsafe
942942
}
943943

944-
// needsPointerCheck returns whether the type t needs a pointer check.
944+
// needsPointerCheck reports whether the type t needs a pointer check.
945945
// This is true if t is a pointer and if the value to which it points
946946
// might contain a pointer.
947947
func (p *Package) needsPointerCheck(f *File, t ast.Expr, arg ast.Expr) bool {
@@ -958,7 +958,7 @@ func (p *Package) needsPointerCheck(f *File, t ast.Expr, arg ast.Expr) bool {
958958

959959
// hasPointer is used by needsPointerCheck. If top is true it returns
960960
// whether t is or contains a pointer that might point to a pointer.
961-
// If top is false it returns whether t is or contains a pointer.
961+
// If top is false it reports whether t is or contains a pointer.
962962
// f may be nil.
963963
func (p *Package) hasPointer(f *File, t ast.Expr, top bool) bool {
964964
switch t := t.(type) {
@@ -1172,7 +1172,7 @@ func (p *Package) checkAddr(sb, sbCheck *bytes.Buffer, arg ast.Expr, i int) bool
11721172
return true
11731173
}
11741174

1175-
// isType returns whether the expression is definitely a type.
1175+
// isType reports whether the expression is definitely a type.
11761176
// This is conservative--it returns false for an unknown identifier.
11771177
func (p *Package) isType(t ast.Expr) bool {
11781178
switch t := t.(type) {
@@ -1214,7 +1214,7 @@ func (p *Package) isType(t ast.Expr) bool {
12141214
return false
12151215
}
12161216

1217-
// isConst returns whether x is an untyped constant expression.
1217+
// isConst reports whether x is an untyped constant expression.
12181218
func (p *Package) isConst(f *File, x ast.Expr) bool {
12191219
switch x := x.(type) {
12201220
case *ast.BasicLit:
@@ -2827,7 +2827,7 @@ func (c *typeConv) Struct(dt *dwarf.StructType, pos token.Pos) (expr *ast.Struct
28272827
return
28282828
}
28292829

2830-
// dwarfHasPointer returns whether the DWARF type dt contains a pointer.
2830+
// dwarfHasPointer reports whether the DWARF type dt contains a pointer.
28312831
func (c *typeConv) dwarfHasPointer(dt dwarf.Type, pos token.Pos) bool {
28322832
switch dt := dt.(type) {
28332833
default:

src/cmd/cgo/out.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ func (p *Package) writeExportHeader(fgcch io.Writer) {
12031203
fmt.Fprintf(fgcch, "%s\n", p.gccExportHeaderProlog())
12041204
}
12051205

1206-
// gccgoUsesNewMangling returns whether gccgo uses the new collision-free
1206+
// gccgoUsesNewMangling reports whether gccgo uses the new collision-free
12071207
// packagepath mangling scheme (see determineGccgoManglingScheme for more
12081208
// info).
12091209
func gccgoUsesNewMangling() bool {

src/cmd/compile/internal/gc/reflect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ func dcommontype(lsym *obj.LSym, t *types.Type) int {
915915
return ot
916916
}
917917

918-
// typeHasNoAlg returns whether t does not have any associated hash/eq
918+
// typeHasNoAlg reports whether t does not have any associated hash/eq
919919
// algorithms because t, or some component of t, is marked Noalg.
920920
func typeHasNoAlg(t *types.Type) bool {
921921
a, bad := algtype1(t)

src/cmd/compile/internal/mips/ssa.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ import (
1414
"cmd/internal/obj/mips"
1515
)
1616

17-
// isFPreg returns whether r is an FP register
17+
// isFPreg reports whether r is an FP register
1818
func isFPreg(r int16) bool {
1919
return mips.REG_F0 <= r && r <= mips.REG_F31
2020
}
2121

22-
// isHILO returns whether r is HI or LO register
22+
// isHILO reports whether r is HI or LO register
2323
func isHILO(r int16) bool {
2424
return r == mips.REG_HI || r == mips.REG_LO
2525
}

src/cmd/compile/internal/mips64/ssa.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ import (
1414
"cmd/internal/obj/mips"
1515
)
1616

17-
// isFPreg returns whether r is an FP register
17+
// isFPreg reports whether r is an FP register
1818
func isFPreg(r int16) bool {
1919
return mips.REG_F0 <= r && r <= mips.REG_F31
2020
}
2121

22-
// isHILO returns whether r is HI or LO register
22+
// isHILO reports whether r is HI or LO register
2323
func isHILO(r int16) bool {
2424
return r == mips.REG_HI || r == mips.REG_LO
2525
}

src/cmd/compile/internal/ssa/biasedsparsemap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (s *biasedSparseMap) size() int {
4343
return s.s.size()
4444
}
4545

46-
// contains returns whether x is a key in s
46+
// contains reports whether x is a key in s
4747
func (s *biasedSparseMap) contains(x uint) bool {
4848
if s.s == nil {
4949
return false

src/cmd/compile/internal/ssa/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ type Frontend interface {
164164
// given name.
165165
Syslook(string) *obj.LSym
166166

167-
// UseWriteBarrier returns whether write barrier is enabled
167+
// UseWriteBarrier reports whether write barrier is enabled
168168
UseWriteBarrier() bool
169169

170170
// SetWBPos indicates that a write barrier has been inserted

src/cmd/compile/internal/ssa/magic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ import "math/big"
8383
// a+b has n+1 bits in it. Nevertheless, can be done
8484
// in 2 instructions on x86.)
8585

86-
// umagicOK returns whether we should strength reduce a n-bit divide by c.
86+
// umagicOK reports whether we should strength reduce a n-bit divide by c.
8787
func umagicOK(n uint, c int64) bool {
8888
// Convert from ConstX auxint values to the real uint64 constant they represent.
8989
d := uint64(c) << (64 - n) >> (64 - n)

src/cmd/compile/internal/ssa/numberlines.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func isPoorStatementOp(op Op) bool {
2020
return false
2121
}
2222

23-
// LosesStmtMark returns whether a prog with op as loses its statement mark on the way to DWARF.
23+
// LosesStmtMark reports whether a prog with op as loses its statement mark on the way to DWARF.
2424
// The attributes from some opcodes are lost in translation.
2525
// TODO: this is an artifact of how funcpctab combines information for instructions at a single PC.
2626
// Should try to fix it there.

src/cmd/compile/internal/ssa/rewrite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ func canMergeLoad(target, load *Value) bool {
320320
return true
321321
}
322322

323-
// isSameSym returns whether sym is the same as the given named symbol
323+
// isSameSym reports whether sym is the same as the given named symbol
324324
func isSameSym(sym interface{}, name string) bool {
325325
s, ok := sym.(fmt.Stringer)
326326
return ok && s.String() == name

src/cmd/compile/internal/ssa/value.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ func (v *Value) Fatalf(msg string, args ...interface{}) {
300300
v.Block.Func.fe.Fatalf(v.Pos, msg, args...)
301301
}
302302

303-
// isGenericIntConst returns whether v is a generic integer constant.
303+
// isGenericIntConst reports whether v is a generic integer constant.
304304
func (v *Value) isGenericIntConst() bool {
305305
return v != nil && (v.Op == OpConst64 || v.Op == OpConst32 || v.Op == OpConst16 || v.Op == OpConst8)
306306
}

src/cmd/compile/internal/ssa/writebarrier.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"strings"
1212
)
1313

14-
// needwb returns whether we need write barrier for store op v.
14+
// needwb reports whether we need write barrier for store op v.
1515
// v must be Store/Move/Zero.
1616
func needwb(v *Value) bool {
1717
t, ok := v.Aux.(*types.Type)

src/cmd/compile/internal/types/type.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,7 @@ func Haspointers1(t *Type, ignoreNotInHeap bool) bool {
14571457
return true
14581458
}
14591459

1460-
// HasHeapPointer returns whether t contains a heap pointer.
1460+
// HasHeapPointer reports whether t contains a heap pointer.
14611461
// This is used for write barrier insertion, so it ignores
14621462
// pointers to go:notinheap types.
14631463
func (t *Type) HasHeapPointer() bool {

src/cmd/internal/obj/arm64/asm7.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ func isaddcon(v int64) bool {
11831183
return v <= 0xFFF
11841184
}
11851185

1186-
// isbitcon returns whether a constant can be encoded into a logical instruction.
1186+
// isbitcon reports whether a constant can be encoded into a logical instruction.
11871187
// bitcon has a binary form of repetition of a bit sequence of length 2, 4, 8, 16, 32, or 64,
11881188
// which itself is a rotate (w.r.t. the length of the unit) of a sequence of ones.
11891189
// special cases: 0 and -1 are not bitcon.

src/cmd/internal/objabi/reloctype.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ const (
198198
R_WASMIMPORT
199199
)
200200

201-
// IsDirectJump returns whether r is a relocation for a direct jump.
201+
// IsDirectJump reports whether r is a relocation for a direct jump.
202202
// A direct jump is a CALL or JMP instruction that takes the target address
203203
// as immediate. The address is embedded into the instruction, possibly
204204
// with limited width.

src/cmd/link/internal/ld/data.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import (
4848
"sync"
4949
)
5050

51-
// isRuntimeDepPkg returns whether pkg is the runtime package or its dependency
51+
// isRuntimeDepPkg reports whether pkg is the runtime package or its dependency
5252
func isRuntimeDepPkg(pkg string) bool {
5353
switch pkg {
5454
case "runtime",

src/cmd/link/internal/ld/lib.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ const (
158158
MINFUNC = 16 // minimum size for a function
159159
)
160160

161-
// DynlinkingGo returns whether we are producing Go code that can live
161+
// DynlinkingGo reports whether we are producing Go code that can live
162162
// in separate shared libraries linked together at runtime.
163163
func (ctxt *Link) DynlinkingGo() bool {
164164
if !ctxt.Loaded {
@@ -167,12 +167,12 @@ func (ctxt *Link) DynlinkingGo() bool {
167167
return ctxt.BuildMode == BuildModeShared || ctxt.linkShared || ctxt.BuildMode == BuildModePlugin || ctxt.CanUsePlugins()
168168
}
169169

170-
// CanUsePlugins returns whether a plugins can be used
170+
// CanUsePlugins reports whether a plugins can be used
171171
func (ctxt *Link) CanUsePlugins() bool {
172172
return ctxt.Syms.ROLookup("plugin.Open", sym.SymVerABIInternal) != nil
173173
}
174174

175-
// UseRelro returns whether to make use of "read only relocations" aka
175+
// UseRelro reports whether to make use of "read only relocations" aka
176176
// relro.
177177
func (ctxt *Link) UseRelro() bool {
178178
switch ctxt.BuildMode {

src/cmd/pprof/readlineui.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func colorize(msg string) string {
101101
return colorEscape + msg + colorResetEscape
102102
}
103103

104-
// IsTerminal returns whether the UI is known to be tied to an
104+
// IsTerminal reports whether the UI is known to be tied to an
105105
// interactive terminal (as opposed to being redirected to a file).
106106
func (r *readlineUI) IsTerminal() bool {
107107
const stdout = 1

src/cmd/trace/annotations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ func (task *taskDesc) overlappingInstant(ev *trace.Event) bool {
538538
return false
539539
}
540540

541-
// overlappingDuration returns whether the durational event, ev, overlaps with
541+
// overlappingDuration reports whether the durational event, ev, overlaps with
542542
// any of the task's region if ev is a goroutine-local event, or overlaps with
543543
// the task's lifetime if ev is a global event. It returns the overlapping time
544544
// as well.

src/crypto/tls/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ const (
240240
RequireAndVerifyClientCert
241241
)
242242

243-
// requiresClientCert returns whether the ClientAuthType requires a client
243+
// requiresClientCert reports whether the ClientAuthType requires a client
244244
// certificate to be provided.
245245
func requiresClientCert(c ClientAuthType) bool {
246246
switch c {

src/crypto/tls/handshake_server_tls13.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ func (hs *serverHandshakeStateTLS13) doHelloRetryRequest(selectedGroup CurveID)
464464
return nil
465465
}
466466

467-
// illegalClientHelloChange returns whether the two ClientHello messages are
467+
// illegalClientHelloChange reports whether the two ClientHello messages are
468468
// different, with the exception of the changes allowed before and after a
469469
// HelloRetryRequest. See RFC 8446, Section 4.1.2.
470470
func illegalClientHelloChange(ch, ch1 *clientHelloMsg) bool {

src/crypto/x509/pkix/pkix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ func (n Name) String() string {
227227
return n.ToRDNSequence().String()
228228
}
229229

230-
// oidInAttributeTypeAndValue returns whether a type with the given OID exists
230+
// oidInAttributeTypeAndValue reports whether a type with the given OID exists
231231
// in atv.
232232
func oidInAttributeTypeAndValue(oid asn1.ObjectIdentifier, atv []AttributeTypeAndValue) bool {
233233
for _, a := range atv {

src/crypto/x509/verify.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ nextIntermediate:
858858
return
859859
}
860860

861-
// validHostname returns whether host is a valid hostname that can be matched or
861+
// validHostname reports whether host is a valid hostname that can be matched or
862862
// matched against according to RFC 6125 2.2, with some leniency to accommodate
863863
// legacy values.
864864
func validHostname(host string) bool {

src/crypto/x509/x509.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,7 @@ var (
16411641
oidAuthorityInfoAccessIssuers = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 48, 2}
16421642
)
16431643

1644-
// oidNotInExtensions returns whether an extension with the given oid exists in
1644+
// oidNotInExtensions reports whether an extension with the given oid exists in
16451645
// extensions.
16461646
func oidInExtensions(oid asn1.ObjectIdentifier, extensions []pkix.Extension) bool {
16471647
for _, e := range extensions {

src/database/sql/sql.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2821,7 +2821,7 @@ func (ci *ColumnType) ScanType() reflect.Type {
28212821
return ci.scanType
28222822
}
28232823

2824-
// Nullable returns whether the column may be null.
2824+
// Nullable reports whether the column may be null.
28252825
// If a driver does not support this property ok will be false.
28262826
func (ci *ColumnType) Nullable() (nullable, ok bool) {
28272827
return ci.nullable, ci.hasNullable

src/debug/dwarf/line.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ func (r *LineReader) SeekPC(pc uint64, entry *LineEntry) error {
590590
}
591591
}
592592

593-
// pathIsAbs returns whether path is an absolute path (or "full path
593+
// pathIsAbs reports whether path is an absolute path (or "full path
594594
// name" in DWARF parlance). This is in "whatever form makes sense for
595595
// the host system", so this accepts both UNIX-style and DOS-style
596596
// absolute paths. We avoid the filepath package because we want this

src/go/printer/nodes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ func (p *printer) possibleSelectorExpr(expr ast.Expr, prec1, depth int) bool {
976976
return false
977977
}
978978

979-
// selectorExpr handles an *ast.SelectorExpr node and returns whether x spans
979+
// selectorExpr handles an *ast.SelectorExpr node and reports whether x spans
980980
// multiple lines.
981981
func (p *printer) selectorExpr(x *ast.SelectorExpr, depth int, isMethod bool) bool {
982982
p.expr1(x.X, token.HighestPrec, depth)

src/internal/goroot/gc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"sync"
1515
)
1616

17-
// IsStandardPackage returns whether path is a standard package,
17+
// IsStandardPackage reports whether path is a standard package,
1818
// given goroot and compiler.
1919
func IsStandardPackage(goroot, compiler, path string) bool {
2020
switch compiler {
@@ -95,7 +95,7 @@ func (gd *gccgoDirs) init() {
9595
gd.dirs = append(gd.dirs, lastDirs...)
9696
}
9797

98-
// isStandard returns whether path is a standard library for gccgo.
98+
// isStandard reports whether path is a standard library for gccgo.
9999
func (gd *gccgoDirs) isStandard(path string) bool {
100100
// Quick check: if the first path component has a '.', it's not
101101
// in the standard library. This skips most GOPATH directories.

src/internal/goroot/gccgo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"path/filepath"
1212
)
1313

14-
// IsStandardPackage returns whether path is a standard package,
14+
// IsStandardPackage reports whether path is a standard package,
1515
// given goroot and compiler.
1616
func IsStandardPackage(goroot, compiler, path string) bool {
1717
switch compiler {

src/net/http/cookie.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func readCookies(h Header, filter string) []*Cookie {
263263
return cookies
264264
}
265265

266-
// validCookieDomain returns whether v is a valid cookie domain-value.
266+
// validCookieDomain reports whether v is a valid cookie domain-value.
267267
func validCookieDomain(v string) bool {
268268
if isCookieDomainName(v) {
269269
return true
@@ -274,13 +274,13 @@ func validCookieDomain(v string) bool {
274274
return false
275275
}
276276

277-
// validCookieExpires returns whether v is a valid cookie expires-value.
277+
// validCookieExpires reports whether v is a valid cookie expires-value.
278278
func validCookieExpires(t time.Time) bool {
279279
// IETF RFC 6265 Section 5.1.1.5, the year must not be less than 1601
280280
return t.Year() >= 1601
281281
}
282282

283-
// isCookieDomainName returns whether s is a valid domain name or a valid
283+
// isCookieDomainName reports whether s is a valid domain name or a valid
284284
// domain name with a leading dot '.'. It is almost a direct copy of
285285
// package net's isDomainName.
286286
func isCookieDomainName(s string) bool {

src/net/http/h2_bundle.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/net/http/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3082,7 +3082,7 @@ func (srv *Server) ListenAndServeTLS(certFile, keyFile string) error {
30823082
}
30833083

30843084
// setupHTTP2_ServeTLS conditionally configures HTTP/2 on
3085-
// srv and returns whether there was an error setting it up. If it is
3085+
// srv and reports whether there was an error setting it up. If it is
30863086
// not configured for policy reasons, nil is returned.
30873087
func (srv *Server) setupHTTP2_ServeTLS() error {
30883088
srv.nextProtoOnce.Do(srv.onceSetNextProtoDefaults)

0 commit comments

Comments
 (0)