Skip to content

Commit

Permalink
Fix ineffective assignments (#258)
Browse files Browse the repository at this point in the history
* `return nil, err` after assigning to `err` (rather than ignoring it)
* removed initialization of a variable just before it's re-assigned

Both of these issues were found in the Go Repord Card:
https://goreportcard.com/report/github.com/google/starlark-go#ineffassign
  • Loading branch information
mbrukman authored and adonovan committed Jan 26, 2020
1 parent c14ca49 commit 40bc3a5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion syntax/scan.go
Expand Up @@ -276,6 +276,7 @@ func readSource(filename string, src interface{}) ([]byte, error) {
data, err := ioutil.ReadAll(src)
if err != nil {
err = &os.PathError{Op: "read", Path: filename, Err: err}
return nil, err
}
return data, nil
case nil:
Expand Down Expand Up @@ -1018,7 +1019,7 @@ func (sc *scanner) scanNumber(val *tokenValue, c rune) Token {
val.int, err = strconv.ParseInt(s, 0, 64)
if err != nil {
num := new(big.Int)
var ok bool = true
var ok bool
val.bigInt, ok = num.SetString(s, 0)
if ok {
err = nil
Expand Down

0 comments on commit 40bc3a5

Please sign in to comment.