[GODRIVER-1066] linter issues Created: 16/May/19  Updated: 19/Oct/22  Resolved: 04/Oct/21

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: 1.0.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Pierre Durand Assignee: Matt Dale
Resolution: Done Votes: 0
Labels: jeff+
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to GODRIVER-2157 Detect bit alignment issues when usin... Closed
is related to GODRIVER-2156 Enable all remaining golangci-lint li... Closed
Epic Link: Improve Testing Suite
Quarter: FY23Q4

 Description   

I've noticed that there is a lot of real bugs in the code.

I've detected them with https://github.com/golangci/golangci-lint

and this config:

 

run:
  deadline: "10m"
linters:
  disable-all: true
  enable:
    - "deadcode"
    - "errcheck"
    - "gofmt"
    - "goimports"
    - "golint"
    - "govet"
    - "ineffassign"
    - "megacheck"
    - "misspell"
    - "nakedret"
    - "structcheck"
    - "unconvert"
    - "unparam"
    - "varcheck"
issues:
  exclude-use-default: false
  max-per-linter: 0
  max-same-issues: 0

 

Example of bugs:

bson/primitive/primitive.go:58:38: SA4000: identical expressions on the left and right side of the '==' operator (staticcheck)bson/primitive/primitive.go:58:38: SA4000: identical expressions on the left and right side of the '==' operator (staticcheck) return rp.Pattern == rp2.Pattern && rp.Options == rp.Options

Maybe it should be "rp2" ?

bson/bsonrw/extjson_parser.go:136:6: ineffectual assignment to `err` (ineffassign)bson/bsonrw/extjson_parser.go:136:6: ineffectual assignment to `err` (ineffassign) err = ejp.err

The error is assigned, but never checked.

 



 Comments   
Comment by Githook User [ 01/Oct/21 ]

Author:

{'name': 'Matt Dale', 'email': '9760375+matthewdale@users.noreply.github.com', 'username': 'matthewdale'}

Message: GODRIVER-1066 Use golangci-lint to replace and expand linters. (#731)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/22266fc3c85143417f31fb860e9a0cb87ce18b0e

Comment by Matt Dale [ 16/Sep/21 ]

pierrre sorry about the hilariously slow response, but thank you for the suggestion! A version of your suggested change is now in code review: https://github.com/mongodb/mongo-go-driver/pull/731

Generated at Thu Feb 08 08:35:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.