diff options
author | Martin Czygan <martin.czygan@gmail.com> | 2021-04-15 00:41:14 +0200 |
---|---|---|
committer | Martin Czygan <martin.czygan@gmail.com> | 2021-04-19 20:29:17 +0200 |
commit | aa37b39f72eda335a6bb24bb521464b548cf6627 (patch) | |
tree | ee7fd381e6f5d0472c71952549efdc9e8ea3162d /skate | |
parent | 1f7d8a8d1e2349a6ccd9383b1382f4b56eecc81f (diff) | |
download | refcat-aa37b39f72eda335a6bb24bb521464b548cf6627.tar.gz refcat-aa37b39f72eda335a6bb24bb521464b548cf6627.zip |
minor tweaks
Diffstat (limited to 'skate')
-rw-r--r-- | skate/verify.go | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/skate/verify.go b/skate/verify.go index 5eccbab..c24590e 100644 --- a/skate/verify.go +++ b/skate/verify.go @@ -139,12 +139,12 @@ func ClusterVerifyMaxSize(p []byte, maxClusterSize int) ([]byte, error) { var ( rc *ReleaseCluster buf bytes.Buffer + n int ) if err := json.Unmarshal(p, &rc); err != nil { return nil, err } - n := len(rc.Values) - if n > maxClusterSize { + if n = len(rc.Values); n > maxClusterSize { return nil, nil } // O(n^2) ahead, specifically, n * (n-1) / 2. @@ -174,22 +174,24 @@ func ClusterVerify(p []byte) ([]byte, error) { return ClusterVerifyMaxSize(p, 10) } -// RefClusterVerify deserialized a cluster document containing both converted +// RefClusterVerify deserializes a cluster document containing both converted // references and releases and returns a tabular verification result between -// one release and all references found. +// one release and all references found. This depends on refs and releases +// being distinguishable, (e.g. via .extra.skate.status == "ref"). func RefClusterVerify(p []byte) ([]byte, error) { var ( - rc *ReleaseCluster - buf bytes.Buffer + rc *ReleaseCluster + buf bytes.Buffer + pivot, re *Release + err error ) - if err := json.Unmarshal(p, &rc); err != nil { + if err = json.Unmarshal(p, &rc); err != nil { return nil, err } - pivot, err := rc.OneNonRef() - if err != nil { + if pivot, err = rc.OneNonRef(); err != nil { return nil, err } - for _, re := range rc.Values { + for _, re = range rc.Values { if re.Extra.Skate.Status != "ref" { continue } @@ -208,18 +210,19 @@ func RefClusterVerify(p []byte) ([]byte, error) { // RefClusterToBiblioRef creates a BiblioRef schema from exact and strong matches only. func RefClusterToBiblioRef(p []byte) ([]byte, error) { var ( - cr *ReleaseCluster - br *BiblioRef - buf bytes.Buffer + rc *ReleaseCluster + br *BiblioRef + buf bytes.Buffer + pivot, re *Release + err error ) - if err := json.Unmarshal(p, &cr); err != nil { + if err = json.Unmarshal(p, &rc); err != nil { return nil, err } - pivot, err := cr.OneNonRef() - if err != nil { + if pivot, err = rc.OneNonRef(); err != nil { return nil, err } - for _, re := range cr.Values { + for _, re = range rc.Values { if re.Extra.Skate.Status != "ref" { continue } |