Skip to content

all: simplify and clarify some expressions#260

Merged
shantuo merged 5 commits intogoogle:masterfrom
cristaloleg:master
Aug 6, 2018
Merged

all: simplify and clarify some expressions#260
shantuo merged 5 commits intogoogle:masterfrom
cristaloleg:master

Conversation

@cristaloleg
Copy link
Copy Markdown
Contributor

@cristaloleg cristaloleg commented Jul 30, 2018

Changes were suggested by go-critic linter.
Full log:

check-package: $GOPATH/src/github.com/google/go-cloud/runtimevar/filevar/filevar.go:162:7: boolExprSimplify: can simplify `!(event.Op&(fsnotify.Create|fsnotify.Write|fsnotify.Remove|fsnotify.Rename) != 0)` to `event.Op&(fsnotify.Create|fsnotify.Write|fsnotify.Remove|fsnotify.Rename) == 0`

check-package: $GOPATH/src/github.com/google/go-cloud/wire/internal/wire/parse.go:705:3: typeSwitchVar: case 1 can benefit from type switch with assignment
check-package: $GOPATH/src/github.com/google/go-cloud/wire/internal/wire/parse.go:705:3: typeSwitchVar: case 2 can benefit from type switch with assignment

check-package: $GOPATH/src/github.com/google/go-cloud/wire/internal/wire/wire.go:484:2: ifElseChain: should rewrite if-else to switch statement

check-package: $GOPATH/src/github.com/google/go-cloud/wire/internal/wire/wire.go:369:61: namedConst: use token.NoPos instead of 0
check-package: $GOPATH/src/github.com/google/go-cloud/wire/internal/wire/wire.go:439:73: namedConst: use token.NoPos instead of 0

Comment thread blob/fileblob/fileblob.go Outdated
return nil, fmt.Errorf("open file blob %s: extension %q is reserved and cannot be used", key, attrsExt)
}
if err := os.MkdirAll(filepath.Dir(path), 0777); err != nil {
if err := os.MkdirAll(filepath.Dir(path), os.ModePerm); err != nil {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't change 0777 to os.ModePerm.
This is a false positive from namedConst checker.

@quasilyte
Copy link
Copy Markdown

All of these are false positives, please, revert related changes:

check-package: $GOPATH/src/github.com/google/go-cloud/blob/fileblob/fileblob.go:163:44: namedConst: use os.ModePerm instead of 511
check-package: $GOPATH/src/github.com/google/go-cloud/blob/fileblob/fileblob_test.go:147:49: namedConst: use os.ModePerm instead of 511
check-package: $GOPATH/src/github.com/google/go-cloud/blob/fileblob/fileblob_test.go:182:30: namedConst: use os.ModePerm instead of 511
check-package: $GOPATH/src/github.com/google/go-cloud/blob/fileblob/fileblob_test.go:186:52: namedConst: use os.ModePerm instead of 511
check-package: $GOPATH/src/github.com/google/go-cloud/blob/fileblob/fileblob_test.go:364:30: namedConst: use os.ModePerm instead of 511
check-package: $GOPATH/src/github.com/google/go-cloud/blob/fileblob/fileblob_test.go:451:30: namedConst: use os.ModePerm instead of 511
check-package: $GOPATH/src/github.com/google/go-cloud/blob/fileblob/fileblob_test.go:455:52: namedConst: use os.ModePerm instead of 511
check-package: $GOPATH/src/github.com/google/go-cloud/wire/internal/wire/wire_test.go:491:60: namedConst: use os.ModePerm instead of 511
check-package: $GOPATH/src/github.com/google/go-cloud/wire/internal/wire/wire_test.go:537:44: namedConst: use os.ModePerm instead of 511

(Basically, everything with os.ModePerm is a bad advice.)

func (d dirInfo) Name() string { return d.name }
func (d dirInfo) Size() int64 { return 0 }
func (d dirInfo) Mode() os.FileMode { return os.ModeDir | 0777 }
func (d dirInfo) Mode() os.FileMode { return os.ModeDir | os.ModePerm }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. I guess this is the only place where you might want to use os.ModePerm, since it looks like 0777 is used as a perm bits mask (purpose that os.ModePerm serves; it's a mask, not a 0777 perm value).

@zombiezen
Copy link
Copy Markdown
Contributor

@shantuo Are you merging this in?

@googlebot
Copy link
Copy Markdown

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@vangent vangent self-requested a review August 4, 2018 02:39
@shantuo shantuo requested a review from ijt August 6, 2018 19:19
@shantuo
Copy link
Copy Markdown
Contributor

shantuo commented Aug 6, 2018

Hi @ijt please also approve to pass the check.

@zombiezen zombiezen added the cla: yes Google CLA has been signed! label Aug 6, 2018
@googlebot
Copy link
Copy Markdown

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

@shantuo shantuo merged commit f1de731 into google:master Aug 6, 2018
@cristaloleg
Copy link
Copy Markdown
Contributor Author

cristaloleg commented Aug 6, 2018

Thanks to everyone 👍

zombiezen pushed a commit to google/wire that referenced this pull request Nov 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Google CLA has been signed!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants