Skip to content

Commit

Permalink
Fixed no lint directives
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Aug 15, 2022
1 parent 76a7e76 commit d783a1f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
9 changes: 4 additions & 5 deletions mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ func (c *Client) CreateInBatchesMongo(
bulkOptions := options.BulkWrite().SetOrdered(true)
count := 0

switch reflect.TypeOf(models).Kind() { //nolint:exhaustive // we only get slices
case reflect.Slice:
if reflect.TypeOf(models).Kind() == reflect.Slice {
s := reflect.ValueOf(models)
for i := 0; i < s.Len(); i++ {
m := mongo.NewInsertOneModel()
Expand Down Expand Up @@ -507,11 +506,11 @@ func processMongoConditions(conditions *map[string]interface{},
for key, condition := range *conditions {
if key == conditionAnd || key == conditionOr {
var slice []map[string]interface{}
a, _ := json.Marshal(condition) // nolint: errchkjson // this check might break the current code
a, _ := json.Marshal(condition) //nolint:errchkjson // this check might break the current code
_ = json.Unmarshal(a, &slice)
var newConditions []map[string]interface{}
for _, c := range slice {
newConditions = append(newConditions, *processMongoConditions(&c, customProcessor)) // nolint: scopelint,gosec // ignore for now
newConditions = append(newConditions, *processMongoConditions(&c, customProcessor)) //nolint:scopelint,gosec // ignore for now
}
(*conditions)[key] = newConditions
}
Expand All @@ -523,7 +522,7 @@ func processMongoConditions(conditions *map[string]interface{},
// processMetadataConditions will process metadata conditions
func processMetadataConditions(conditions *map[string]interface{}) {
// marshal / unmarshal into standard map[string]interface{}
m, _ := json.Marshal((*conditions)[metadataField]) // nolint: errchkjson // this check might break the current code
m, _ := json.Marshal((*conditions)[metadataField]) //nolint:errchkjson // this check might break the current code
var r map[string]interface{}
_ = json.Unmarshal(m, &r)

Expand Down
4 changes: 2 additions & 2 deletions mongodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ func TestClient_getMongoQueryConditions(t *testing.T) {
func processObjectMetadataConditions(conditions *map[string]interface{}) {

// marshal / unmarshal into standard map[string]interface{}
m, _ := json.Marshal((*conditions)[objectMetadataField]) // nolint: errchkjson // this check might break the current code
m, _ := json.Marshal((*conditions)[objectMetadataField]) //nolint:errchkjson // this check might break the current code
var r map[string]interface{}
_ = json.Unmarshal(m, &r)

Expand Down Expand Up @@ -448,7 +448,7 @@ func processObjectMetadataConditions(conditions *map[string]interface{}) {
func processObjectOutputValueConditions(conditions *map[string]interface{}) {
fieldName := "object_output_value"

m, _ := json.Marshal((*conditions)[fieldName]) // nolint: errchkjson // this check might break the current code
m, _ := json.Marshal((*conditions)[fieldName]) //nolint:errchkjson // this check might break the current code
var r map[string]interface{}
_ = json.Unmarshal(m, &r)

Expand Down
14 changes: 7 additions & 7 deletions where.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ func processConditions(client ClientInterface, tx CustomWhereInterface, conditio
switch v.Kind() { //nolint:exhaustive // not all cases are needed
case reflect.Map:
if _, ok := condition.(map[string]interface{}); ok {
processConditions(client, tx, condition.(map[string]interface{}), engine, varNum, &key) // nolint: scopelint // ignore for now
processConditions(client, tx, condition.(map[string]interface{}), engine, varNum, &key) //nolint:scopelint // ignore for now
} else {
c, _ := json.Marshal(condition) // nolint: errchkjson // this check might break the current code
c, _ := json.Marshal(condition) //nolint:errchkjson // this check might break the current code
var cc map[string]interface{}
_ = json.Unmarshal(c, &cc)
processConditions(client, tx, cc, engine, varNum, &key) // nolint: scopelint // ignore for now
processConditions(client, tx, cc, engine, varNum, &key) //nolint:scopelint // ignore for now
}
default:
varName := "var" + strconv.Itoa(*varNum)
Expand Down Expand Up @@ -188,7 +188,7 @@ func whereObject(engine Engine, k string, v interface{}) string {
queryParts := make([]string, 0)

// we don't know the type, we handle the rangeValue as a map[string]interface{}
vJSON, _ := json.Marshal(v) // nolint: errchkjson // this check might break the current code
vJSON, _ := json.Marshal(v) //nolint:errchkjson // this check might break the current code

var rangeV map[string]interface{}
_ = json.Unmarshal(vJSON, &rangeV)
Expand All @@ -200,11 +200,11 @@ func whereObject(engine Engine, k string, v interface{}) string {
rangeValue = "\"" + escapeDBString(rangeValue.(string)) + "\""
queryParts = append(queryParts, "JSON_EXTRACT("+k+", '$."+rangeKey+"') = "+rangeValue.(string))
default:
metadataJSON, _ := json.Marshal(vv) // nolint: errchkjson // this check might break the current code
metadataJSON, _ := json.Marshal(vv) //nolint:errchkjson // this check might break the current code
var metadata map[string]interface{}
_ = json.Unmarshal(metadataJSON, &metadata)
for kk, vvv := range metadata {
mJSON, _ := json.Marshal(vvv) // nolint: errchkjson // this check might break the current code
mJSON, _ := json.Marshal(vvv) //nolint:errchkjson // this check might break the current code
vvv = string(mJSON)
queryParts = append(queryParts, "JSON_EXTRACT("+k+", '$."+rangeKey+"."+kk+"') = "+vvv.(string))
}
Expand All @@ -214,7 +214,7 @@ func whereObject(engine Engine, k string, v interface{}) string {
case string:
rangeValue = "\"" + escapeDBString(rangeValue.(string)) + "\""
default:
metadataJSON, _ := json.Marshal(vv) // nolint: errchkjson // this check might break the current code
metadataJSON, _ := json.Marshal(vv) //nolint:errchkjson // this check might break the current code
rangeValue = string(metadataJSON)
}
queryParts = append(queryParts, k+"::jsonb @> '{\""+rangeKey+"\":"+rangeValue.(string)+"}'::jsonb")
Expand Down

0 comments on commit d783a1f

Please sign in to comment.