diff options
| author | Paul Buetow <pbuetow@mimecast.com> | 2021-12-08 09:52:07 +0000 |
|---|---|---|
| committer | Paul Buetow <pbuetow@mimecast.com> | 2021-12-08 09:52:07 +0000 |
| commit | bdf066311ae1ec552f2f4bff6f269817b8052718 (patch) | |
| tree | 85e8cde460eb2219b51d5150936928fe49646e7f | |
| parent | 6031ce78df6cda9c8b924b231554bb4e0c077358 (diff) | |
Reduce cognitive code complexity
| -rw-r--r-- | internal/mapr/whereclause.go | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/internal/mapr/whereclause.go b/internal/mapr/whereclause.go index d9f32eb..740df71 100644 --- a/internal/mapr/whereclause.go +++ b/internal/mapr/whereclause.go @@ -11,14 +11,7 @@ func (q *Query) WhereClause(fields map[string]string) bool { for _, wc := range q.Where { var ok bool if wc.Operation > FloatOperation { - var lValue, rValue float64 - if lValue, ok = whereClauseFloatValue(fields, wc.lString, wc.lFloat, wc.lType); !ok { - return false - } - if rValue, ok = whereClauseFloatValue(fields, wc.rString, wc.rFloat, wc.rType); !ok { - return false - } - if ok = wc.floatClause(lValue, rValue); !ok { + if !whereClauseFloatValues(fields, wc) { return false } continue @@ -38,6 +31,23 @@ func (q *Query) WhereClause(fields map[string]string) bool { return true } +func whereClauseFloatValues(fields map[string]string, wc whereCondition) bool { + var lValue, rValue float64 + var ok bool + + if lValue, ok = whereClauseFloatValue(fields, wc.lString, wc.lFloat, wc.lType); !ok { + return false + } + if rValue, ok = whereClauseFloatValue(fields, wc.rString, wc.rFloat, wc.rType); !ok { + return false + } + if ok = wc.floatClause(lValue, rValue); !ok { + return false + } + + return true +} + func whereClauseFloatValue(fields map[string]string, str string, float float64, t fieldType) (float64, bool) { |
