Skip to content

Commit

Permalink
try newer golangci-lint (#112)
Browse files Browse the repository at this point in the history
* try newer

* additional changes required

* some cleanup, some disable of rules
  • Loading branch information
mschoch committed May 26, 2022
1 parent f34c4ac commit d519200
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.30
version: v1.45.2
9 changes: 2 additions & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ linters-settings:
min-complexity: 20 # increased from 15 to get us going, but not make things worse
goimports:
local-prefixes: github.com/golangci/golangci-lint
golint:
min-confidence: 0
gomnd:
settings:
mnd:
Expand Down Expand Up @@ -71,27 +69,23 @@ linters:
- dogsled
- dupl
- errcheck
- exportloopref
- funlen
- gochecknoinits
- goconst
- gocritic
- gocyclo
- gofmt
- goimports
- golint
- gomnd
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- interfacer
- lll
- misspell
- nakedret
- nolintlint
- rowserrcheck
- scopelint
- staticcheck
- structcheck
- stylecheck
Expand Down Expand Up @@ -127,6 +121,7 @@ issues:
- gocyclo
- dupl
- gochecknoinits
- gocritic
- path: cmd/bluge/cmd
linters:
- gochecknoinits
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/caio/go-tdigest v3.1.0+incompatible
github.com/leesper/go_rng v0.0.0-20190531154944-a612b043e353 // indirect
github.com/spf13/cobra v0.0.5
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150
golang.org/x/text v0.3.0
gonum.org/v1/gonum v0.7.0 // indirect
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86h
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181221143128-b4a75ba826a6/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5 h1:LfCXLvNmTYH9kEmVgqbnsWfruoXZIrh4YBgqVHtDvw0=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 h1:xHms4gcpe1YE7A3yIllJXP16CMAGuqwO2lX1mTyyRRc=
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down
1 change: 1 addition & 0 deletions index/directory_fs_nix.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd
// +build darwin dragonfly freebsd linux netbsd openbsd

package index
Expand Down
1 change: 1 addition & 0 deletions index/lock/lock_nix.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd
// +build darwin dragonfly freebsd linux netbsd openbsd

package lock
Expand Down
4 changes: 2 additions & 2 deletions index/mergeplan/merge_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestSimplePlan(t *testing.T) {
tests := []struct {
Desc string
Segments []Segment
Options *Options
options *Options
ExpectPlan *MergePlan
ExpectErr error
}{
Expand Down Expand Up @@ -139,7 +139,7 @@ func TestSimplePlan(t *testing.T) {

for testi, test := range tests {
test := test
plan, err := Plan(test.Segments, test.Options)
plan, err := Plan(test.Segments, test.options)
if err != test.ExpectErr {
testj, _ := json.Marshal(&test)
t.Errorf("testi: %d, test: %s, got err: %v",
Expand Down
9 changes: 7 additions & 2 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@ func (q *GeoBoundingBoxQuery) Field() string {
return q.field
}

const (
minLon = -180
maxLon = 180
)

func (q *GeoBoundingBoxQuery) Searcher(i search.Reader, options search.SearcherOptions) (search.Searcher, error) {
field := q.field
if q.field == "" {
Expand All @@ -533,14 +538,14 @@ func (q *GeoBoundingBoxQuery) Searcher(i search.Reader, options search.SearcherO
// cross date line, rewrite as two parts

leftSearcher, err := searcher.NewGeoBoundingBoxSearcher(i,
-180, q.bottomRight[1], q.bottomRight[0], q.topLeft[1],
minLon, q.bottomRight[1], q.bottomRight[0], q.topLeft[1],
field, q.boost.Value(), q.scorer, similarity.NewCompositeSumScorer(),
options, true, geoPrecisionStep)
if err != nil {
return nil, err
}
rightSearcher, err := searcher.NewGeoBoundingBoxSearcher(i,
q.topLeft[0], q.bottomRight[1], 180, q.topLeft[1],
q.topLeft[0], q.bottomRight[1], maxLon, q.topLeft[1],
field, q.boost.Value(), q.scorer, similarity.NewCompositeSumScorer(),
options, true, geoPrecisionStep)
if err != nil {
Expand Down
7 changes: 1 addition & 6 deletions search/searcher/search_disjunction.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,7 @@ func optimizeCompositeSearcher(optimizationKind string,
return nil, err
}

tfr, ok := optimized.(segment.PostingsIterator)
if !ok {
return nil, nil
}

return newTermSearcherFromReader(indexReader, tfr,
return newTermSearcherFromReader(indexReader, optimized,
[]byte(optimizationKind), "*", 1.0, similarity.ConstantScorer(1), options)
}

Expand Down

0 comments on commit d519200

Please sign in to comment.