From f544984a1212187b38359ec7e21245718c4dbde2 Mon Sep 17 00:00:00 2001 From: Mikhail Grachev Date: Wed, 14 Nov 2018 10:08:05 +0300 Subject: [PATCH] Omit explicit bool check --- context/context.go | 6 +++--- context/context_test.go | 2 +- context/label.go | 4 ++-- context/modify.go | 4 ++-- context/path.go | 12 ++++++------ context/resolve.go | 6 +++--- context/rewrite.go | 4 ++-- context/version.go | 2 +- migrate/godep.go | 2 +- migrate/migrate.go | 4 ++-- run/filter.go | 2 +- run/license.go | 2 +- run/list.go | 2 +- vcs/bzr.go | 2 +- vcs/git.go | 2 +- vcs/hg.go | 2 +- vcs/svn.go | 2 +- vcs/vcs.go | 2 +- vendorfile/file.go | 4 ++-- 19 files changed, 33 insertions(+), 33 deletions(-) diff --git a/context/context.go b/context/context.go index 1ed5600..f5557e7 100644 --- a/context/context.go +++ b/context/context.go @@ -333,7 +333,7 @@ func (ctx *Context) findPackageChild(ck *Package) []*Package { if pkg == ck { continue } - if pkg.inVendor == false { + if !pkg.inVendor { continue } if pkg.Status.Presence == PresenceTree { @@ -351,10 +351,10 @@ func (ctx *Context) findPackageChild(ck *Package) []*Package { func (ctx *Context) findPackageParentTree(ck *Package) []string { out := make([]string, 0, 1) for _, pkg := range ctx.Package { - if pkg.inVendor == false { + if !pkg.inVendor { continue } - if pkg.IncludeTree == false || pkg == ck { + if !pkg.IncludeTree || pkg == ck { continue } // pkg.Path = github.com/usera/pkg, tree = true diff --git a/context/context_test.go b/context/context_test.go index 34d3716..54a12ec 100644 --- a/context/context_test.go +++ b/context/context_test.go @@ -1065,7 +1065,7 @@ func TestRemove(t *testing.T) { if err != nil { t.Fatal("vendor folder should still be present", err) } - if vi.IsDir() == false { + if !vi.IsDir() { t.Fatal("vendor folder is not a dir") } } diff --git a/context/label.go b/context/label.go index c20240e..c98df0e 100644 --- a/context/label.go +++ b/context/label.go @@ -74,7 +74,7 @@ func (item *labelAnalysis) fillSections(buf *bytes.Buffer) { if err != nil { value = -1 } - if isBreak(r) == false { + if !isBreak(r) { r = 0 } group.sections = append(group.sections, labelSection{ @@ -209,7 +209,7 @@ func FindLabel(version string, labels []Label) Label { } continue } - if strings.HasPrefix(label.Text, version) == false { + if !strings.HasPrefix(label.Text, version) { continue } remain := strings.TrimPrefix(label.Text, version) diff --git a/context/modify.go b/context/modify.go index 6042bfa..b3efd42 100644 --- a/context/modify.go +++ b/context/modify.go @@ -470,7 +470,7 @@ func (ctx *Context) modifyRemove(pkg *Package) error { return nil } // Protect non-project paths from being removed. - if pathos.FileHasPrefix(pkg.Dir, ctx.RootDir) == false { + if !pathos.FileHasPrefix(pkg.Dir, ctx.RootDir) { return nil } if pkg.Status.Location == LocationLocal { @@ -569,7 +569,7 @@ func (ctx *Context) Check() []*Conflict { // Operation listed in the OpIndex field. func (ctx *Context) ResloveApply(cc []*Conflict) { for _, c := range cc { - if c.Resolved == false { + if !c.Resolved { continue } for i, op := range c.Operation { diff --git a/context/path.go b/context/path.go index 2bac04b..e10e82f 100644 --- a/context/path.go +++ b/context/path.go @@ -24,7 +24,7 @@ func (ctx *Context) isStdLib(importPath string) (yes bool, err error) { if fi == nil { return } - if fi.IsDir() == false { + if !fi.IsDir() { return } @@ -54,7 +54,7 @@ func (ctx *Context) findImportDir(relative, importPath string) (dir, gopath stri if err != nil { continue } - if fi.IsDir() == false { + if !fi.IsDir() { continue } for _, gopath = range ctx.GopathList { @@ -80,7 +80,7 @@ func (ctx *Context) findImportDir(relative, importPath string) (dir, gopath stri if fi == nil { continue } - if fi.IsDir() == false { + if !fi.IsDir() { continue } @@ -117,7 +117,7 @@ func findRoot(folder, vendorPath string) (root string, err error) { for i := 0; i <= looplimit; i++ { test := filepath.Join(folder, vendorPath) _, err := os.Stat(test) - if os.IsNotExist(err) == false { + if !os.IsNotExist(err) { return folder, nil } nextFolder := filepath.Clean(filepath.Join(folder, "..")) @@ -146,7 +146,7 @@ func hasGoFileInFolder(folder string) (bool, error) { return false, err } for _, fi := range fl { - if fi.IsDir() == false && filepath.Ext(fi.Name()) == ".go" { + if !fi.IsDir() && filepath.Ext(fi.Name()) == ".go" { return true, nil } } @@ -210,7 +210,7 @@ func RemovePackage(path, root string, tree bool) error { if len(fl) > 0 { allAreLicense := true for _, fi := range fl { - if isLicenseFile(fi.Name()) == false { + if !isLicenseFile(fi.Name()) { allAreLicense = false break } diff --git a/context/resolve.go b/context/resolve.go index f59cd42..e3d1b64 100644 --- a/context/resolve.go +++ b/context/resolve.go @@ -80,7 +80,7 @@ func (ctx *Context) loadPackage() error { func (ctx *Context) getFileTags(pathname string, f *ast.File) (tags *TagSet, imports []string, err error) { _, filenameExt := filepath.Split(pathname) - if strings.HasSuffix(pathname, ".go") == false { + if !strings.HasSuffix(pathname, ".go") { return nil, nil, nil } if f == nil { @@ -151,12 +151,12 @@ func (ctx *Context) addFileImports(pathname, gopath string) (*Package, error) { importPath = pathos.SlashToImportPath(importPath) importPath = strings.Trim(importPath, "/") - if strings.HasSuffix(pathname, ".go") == false { + if !strings.HasSuffix(pathname, ".go") { return nil, nil } // No need to add the same file more than once. for _, pkg := range ctx.Package { - if pathos.FileStringEquals(pkg.Dir, dir) == false { + if !pathos.FileStringEquals(pkg.Dir, dir) { continue } for _, f := range pkg.Files { diff --git a/context/rewrite.go b/context/rewrite.go index 3ace9f2..b89b431 100644 --- a/context/rewrite.go +++ b/context/rewrite.go @@ -101,13 +101,13 @@ func (ctx *Context) rewrite() error { Tabwidth: 8, } for _, fileInfo := range filePaths { - if pathos.FileHasPrefix(fileInfo.Path, ctx.RootDir) == false { + if !pathos.FileHasPrefix(fileInfo.Path, ctx.RootDir) { continue } // Read the file into AST, modify the AST. fileset := token.NewFileSet() - f, err := parser.ParseFile(fileset, fileInfo.Path, nil, parser.ParseComments) + f, _ := parser.ParseFile(fileset, fileInfo.Path, nil, parser.ParseComments) if f == nil { return nil } diff --git a/context/version.go b/context/version.go index fec21fd..7b797b3 100644 --- a/context/version.go +++ b/context/version.go @@ -29,7 +29,7 @@ func isVersion(s string) bool { if hasPunct { return true } - if onlyHexLetter == false { + if !onlyHexLetter { return true } diff --git a/migrate/godep.go b/migrate/godep.go index 347e243..a4f7ae3 100644 --- a/migrate/godep.go +++ b/migrate/godep.go @@ -93,7 +93,7 @@ func (sysGodep) Migrate(root string) error { for _, d := range godeps.Deps { for _, pkg := range ctx.Package { - if strings.HasPrefix(pkg.Path, d.ImportPath) == false { + if !strings.HasPrefix(pkg.Path, d.ImportPath) { continue } vf := ctx.VendorFilePackagePath(pkg.Path) diff --git a/migrate/migrate.go b/migrate/migrate.go index a4e5202..628ebf7 100644 --- a/migrate/migrate.go +++ b/migrate/migrate.go @@ -112,7 +112,7 @@ func hasDirs(root string, dd ...string) bool { if err != nil { return false } - if fi.IsDir() == false { + if !fi.IsDir() { return false } } @@ -125,7 +125,7 @@ func hasFiles(root string, dd ...string) bool { if err != nil { return false } - if fi.IsDir() == true { + if fi.IsDir() { return false } } diff --git a/run/filter.go b/run/filter.go index f4becac..6bafa77 100644 --- a/run/filter.go +++ b/run/filter.go @@ -164,7 +164,7 @@ func insertListToAllNot(sg *context.StatusGroup, list []context.Status) { if len(sg.Group) == 0 { allStatusNot := true for _, s := range sg.Status { - if s.Not == false { + if !s.Not { allStatusNot = false break } diff --git a/run/license.go b/run/license.go index 76574a2..dc4d6b1 100644 --- a/run/license.go +++ b/run/license.go @@ -87,7 +87,7 @@ func (r *runner) License(w io.Writer, subCmdArgs []string) (help.HelpMessage, er } for _, item := range list { - if f.HasStatus(item) == false { + if !f.HasStatus(item) { continue } if len(f.Import) != 0 && f.FindImport(item) == nil { diff --git a/run/list.go b/run/list.go index 01cd891..97e7a7e 100644 --- a/run/list.go +++ b/run/list.go @@ -99,7 +99,7 @@ func (r *runner) List(w io.Writer, subCmdArgs []string) (help.HelpMessage, error tw := tabwriter.NewWriter(w, 0, 4, 2, ' ', 0) defer tw.Flush() for _, item := range list { - if f.HasStatus(item) == false { + if !f.HasStatus(item) { continue } if len(f.Import) != 0 && f.FindImport(item) == nil { diff --git a/vcs/bzr.go b/vcs/bzr.go index 3231230..c911f50 100644 --- a/vcs/bzr.go +++ b/vcs/bzr.go @@ -23,7 +23,7 @@ func (VcsBzr) Find(dir string) (*VcsInfo, error) { } return nil, err } - if fi.IsDir() == false { + if !fi.IsDir() { return nil, nil } diff --git a/vcs/git.go b/vcs/git.go index b219a86..d9b157a 100644 --- a/vcs/git.go +++ b/vcs/git.go @@ -23,7 +23,7 @@ func (VcsGit) Find(dir string) (*VcsInfo, error) { } return nil, err } - if fi.IsDir() == false { + if !fi.IsDir() { return nil, nil } diff --git a/vcs/hg.go b/vcs/hg.go index 93cf1eb..a4ac7b0 100644 --- a/vcs/hg.go +++ b/vcs/hg.go @@ -23,7 +23,7 @@ func (VcsHg) Find(dir string) (*VcsInfo, error) { } return nil, err } - if fi.IsDir() == false { + if !fi.IsDir() { return nil, nil } diff --git a/vcs/svn.go b/vcs/svn.go index bef8a4e..4d758c0 100644 --- a/vcs/svn.go +++ b/vcs/svn.go @@ -23,7 +23,7 @@ func (svn VcsSvn) Find(dir string) (*VcsInfo, error) { } return nil, err } - if fi.IsDir() == false { + if !fi.IsDir() { return nil, nil } diff --git a/vcs/vcs.go b/vcs/vcs.go index fc8a4e5..d794059 100644 --- a/vcs/vcs.go +++ b/vcs/vcs.go @@ -70,7 +70,7 @@ func FindVcs(root, packageDir string) (info *VcsInfo, err error) { if nextPath == path { return nil, nil } - if pathos.FileHasPrefix(nextPath, root) == false { + if !pathos.FileHasPrefix(nextPath, root) { return nil, nil } path = nextPath diff --git a/vendorfile/file.go b/vendorfile/file.go index 34c687f..e500447 100644 --- a/vendorfile/file.go +++ b/vendorfile/file.go @@ -139,7 +139,7 @@ loop: continue loop } *field = value - if value == true { + if value { break loop } } @@ -160,7 +160,7 @@ func setObject(fieldObj interface{}, object map[string]interface{}, names []stri } case bool: for i, name := range names { - if i != 0 || (hideEmpty && field == false) { + if i != 0 || (hideEmpty && !field) { delete(object, name) continue }