From 28cf4a77e12fecc0ae3675f76850b86d53a3da49 Mon Sep 17 00:00:00 2001 From: Martin Angers Date: Fri, 11 Apr 2014 12:04:03 -0400 Subject: [PATCH] more linting --- filter.go | 19 ++++++++----------- query.go | 3 +-- traversal.go | 5 ++--- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/filter.go b/filter.go index 7b21de0..c79cafe 100644 --- a/filter.go +++ b/filter.go @@ -23,7 +23,7 @@ func (s *Selection) FilterFunction(f func(int, *Selection) bool) *Selection { return pushStack(s, winnowFunction(s, f, true)) } -// Not removes elements from the Selection that pass the function's test. +// NotFunction removes elements from the Selection that pass the function's test. // It returns a new Selection object with the matching elements removed. func (s *Selection) NotFunction(f func(int, *Selection) bool) *Selection { return pushStack(s, winnowFunction(s, f, false)) @@ -35,7 +35,7 @@ func (s *Selection) FilterNodes(nodes ...*html.Node) *Selection { return pushStack(s, winnowNodes(s, nodes, true)) } -// Not removes elements from the Selection that match the specified nodes. +// NotNodes removes elements from the Selection that match the specified nodes. // It returns a new Selection object with the matching elements removed. func (s *Selection) NotNodes(nodes ...*html.Node) *Selection { return pushStack(s, winnowNodes(s, nodes, false)) @@ -51,9 +51,8 @@ func (s *Selection) FilterSelection(sel *Selection) *Selection { return pushStack(s, winnowNodes(s, sel.Nodes, true)) } -// Not removes elements from the Selection that match a node in the specified -// Selection object. -// It returns a new Selection object with the matching elements removed. +// NotSelection removes elements from the Selection that match a node in the specified +// Selection object. It returns a new Selection object with the matching elements removed. func (s *Selection) NotSelection(sel *Selection) *Selection { if sel == nil { return pushStack(s, winnowNodes(s, nil, false)) @@ -115,13 +114,11 @@ func winnow(sel *Selection, selector string, keep bool) []*html.Node { // Optimize if keep is requested if keep { return cs.Filter(sel.Nodes) - } else { - // Use grep - return grep(sel, func(i int, s *Selection) bool { - return !cs.Match(s.Get(0)) - }) } - return nil + // Use grep + return grep(sel, func(i int, s *Selection) bool { + return !cs.Match(s.Get(0)) + }) } // Filter based on an array of nodes, and the indicator to keep (Filter) or diff --git a/query.go b/query.go index a76fe60..8d079a0 100644 --- a/query.go +++ b/query.go @@ -18,9 +18,8 @@ func (s *Selection) Is(selector string) bool { cs := cascadia.MustCompile(selector) if len(s.Nodes) == 1 { return cs.Match(s.Nodes[0]) - } else { - return len(cs.Filter(s.Nodes)) > 0 } + return len(cs.Filter(s.Nodes)) > 0 } return false diff --git a/traversal.go b/traversal.go index e4950d6..6ccff8a 100644 --- a/traversal.go +++ b/traversal.go @@ -488,10 +488,9 @@ func getChildrenWithSiblingType(parent *html.Node, st siblingType, skipNode *htm } if ret == nil || ret.Type == html.ElementNode || st == siblingAllIncludingNonElements { return - } else { - // Not a valid node, try again from this one - cur = ret } + // Not a valid node, try again from this one + cur = ret } panic("Unreachable code reached.") }