diff options
-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 } |