diff options
author | alandonovan <adonovan@google.com> | 2018-12-03 17:05:15 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-03 17:05:15 -0500 |
commit | 5c7d5aa7ed56b35691775864b8a5e97329a916e5 (patch) | |
tree | a701287ac7181208ded8e2f49b2e44c955e28700 | |
parent | 29f9100bbc031184c76d7b14b183f97319d8cf04 (diff) | |
download | starlark-go-5c7d5aa7ed56b35691775864b8a5e97329a916e5.tar.gz |
fix nits found by various static tools (#11)
-rw-r--r-- | internal/chunkedfile/chunkedfile.go | 1 | ||||
-rw-r--r-- | internal/compile/compile.go | 2 | ||||
-rw-r--r-- | repl/repl.go | 2 | ||||
-rw-r--r-- | starlark/int.go | 2 | ||||
-rw-r--r-- | starlark/library.go | 32 | ||||
-rw-r--r-- | starlark/value.go | 2 | ||||
-rw-r--r-- | syntax/scan.go | 1 |
7 files changed, 5 insertions, 37 deletions
diff --git a/internal/chunkedfile/chunkedfile.go b/internal/chunkedfile/chunkedfile.go index b0e908d..a13cea9 100644 --- a/internal/chunkedfile/chunkedfile.go +++ b/internal/chunkedfile/chunkedfile.go @@ -58,7 +58,6 @@ func Read(filename string, report Reporter) (chunks []Chunk) { } linenum := 1 for i, chunk := range strings.Split(string(data), "\n---\n") { - chunk := string(chunk) if debug { fmt.Printf("chunk %d at line %d: %s\n", i, linenum, chunk) } diff --git a/internal/compile/compile.go b/internal/compile/compile.go index 144044f..c30807b 100644 --- a/internal/compile/compile.go +++ b/internal/compile/compile.go @@ -1,4 +1,4 @@ -// The compile package defines the Starlark bytecode compiler. +// Package compile defines the Starlark bytecode compiler. // It is an internal package of the Starlark interpreter and is not directly accessible to clients. // // The compiler generates byte code with optional uint32 operands for a diff --git a/repl/repl.go b/repl/repl.go index 2448192..feccbe4 100644 --- a/repl/repl.go +++ b/repl/repl.go @@ -1,4 +1,4 @@ -// The repl package provides a read/eval/print loop for Starlark. +// Package repl provides a read/eval/print loop for Starlark. // // It supports readline-style command editing, // and interrupts through Control-C. diff --git a/starlark/int.go b/starlark/int.go index 7440a85..02efa4c 100644 --- a/starlark/int.go +++ b/starlark/int.go @@ -55,7 +55,7 @@ func MakeUint64(x uint64) Int { // See comment in MakeInt64 for an explanation of this optimization. return Int{new(big.Int).SetBits([]big.Word{big.Word(x)})} } - return Int{new(big.Int).SetUint64(uint64(x))} + return Int{new(big.Int).SetUint64(x)} } var ( diff --git a/starlark/library.go b/starlark/library.go index 26f1379..152ac16 100644 --- a/starlark/library.go +++ b/starlark/library.go @@ -137,20 +137,6 @@ var ( } ) -func builtinMethodOf(recv Value, name string) builtinMethod { - switch recv.(type) { - case String: - return stringMethods[name] - case *List: - return listMethods[name] - case *Dict: - return dictMethods[name] - case *Set: - return setMethods[name] - } - return nil -} - func builtinAttr(recv Value, name string, methods map[string]builtinMethod) (Value, error) { method := methods[name] if method == nil { @@ -283,7 +269,7 @@ func UnpackPositionalArgs(fnname string, args Tuple, kwargs []Tuple, min int, va } func unpackOneArg(v Value, ptr interface{}) error { - ok := true + var ok bool switch ptr := ptr.(type) { case *Value: *ptr = v @@ -1805,14 +1791,6 @@ func string_lower(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, return String(strings.ToLower(string(recv.(String)))), nil } -// https://github.com/google/starlark-go/blob/master/doc/spec.md#string·lstrip -func string_lstrip(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) { - if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil { - return nil, err - } - return String(strings.TrimLeftFunc(string(recv.(String)), unicode.IsSpace)), nil -} - // https://github.com/google/starlark-go/blob/master/doc/spec.md#string·partition func string_partition(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) { recv := string(recv_.(String)) @@ -1863,14 +1841,6 @@ func string_rindex(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value return string_find_impl(fnname, string(recv.(String)), args, kwargs, false, true) } -// https://github.com/google/starlark-go/blob/master/doc/spec.md#string·rstrip -func string_rstrip(fnname string, recv Value, args Tuple, kwargs []Tuple) (Value, error) { - if err := UnpackPositionalArgs(fnname, args, kwargs, 0); err != nil { - return nil, err - } - return String(strings.TrimRightFunc(string(recv.(String)), unicode.IsSpace)), nil -} - // https://github.com/google/starlark-go/starlark/blob/master/doc/spec.md#string·startswith // https://github.com/google/starlark-go/starlark/blob/master/doc/spec.md#string·endswith func string_startswith(fnname string, recv_ Value, args Tuple, kwargs []Tuple) (Value, error) { diff --git a/starlark/value.go b/starlark/value.go index 0b1e6e1..9653e73 100644 --- a/starlark/value.go +++ b/starlark/value.go @@ -424,7 +424,7 @@ func (s String) Index(i int) Value { return s[i : i+1] } func (s String) Slice(start, end, step int) Value { if step == 1 { - return String(s[start:end]) + return s[start:end] } sign := signum(step) diff --git a/syntax/scan.go b/syntax/scan.go index 9949ce9..37bd38e 100644 --- a/syntax/scan.go +++ b/syntax/scan.go @@ -377,7 +377,6 @@ type tokenValue struct { float float64 // decoded float string string // decoded string pos Position // start position of token - triple bool // was string triple quoted? } // startToken marks the beginning of the next input token. |