Skip to content

Commit

Permalink
graph/formats/cytoscapejs: address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kortschak committed Oct 17, 2018
1 parent 76d94d7 commit be42955
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions graph/formats/cytoscapejs/cytoscapejs.go
Expand Up @@ -34,7 +34,7 @@ type Element struct {
Scratch interface{} `json:"scratch,omitempty"`
}

// ElemType is described an Element type.
// ElemType describes an Element type.
type ElemType int

const (
Expand All @@ -46,15 +46,15 @@ const (
// Type returns the element type of the receiver. It returns an error if the Element Group
// is invalid or does not match the Element Data, or if the Elelement Data is an incomplete
// edge.
func (e Element) Tyoe() (ElemType, error) {
func (e Element) Type() (ElemType, error) {
et := InvalidElement
switch {
case e.Data.Source == "" && e.Data.Target == "":
et = NodeElement
case e.Data.Source != "" && e.Data.Target != "":
et = EdgeElement
default:
return et, errors.New("cytoscapejs: invalid element")
return et, errors.New("cytoscapejs: invalid element: incomplete edge")
}
switch {
case e.Group == "":
Expand All @@ -64,7 +64,7 @@ func (e Element) Tyoe() (ElemType, error) {
case e.Group == "edge" && et == EdgeElement:
return NodeElement, nil
default:
return InvalidElement, errors.New("cytoscapejs: invalid element")
return InvalidElement, errors.New("cytoscapejs: invalid element: mismatched group")
}
}

Expand Down
2 changes: 1 addition & 1 deletion graph/formats/cytoscapejs/cytoscapejs_test.go
Expand Up @@ -63,7 +63,7 @@ func TestUnmarshalElements(t *testing.T) {
}
var gotNodes, gotEdges int
for _, e := range got {
typ, err := e.Tyoe()
typ, err := e.Type()
if err != nil {
t.Errorf("unexpected error finding element type for %+v: %v", e, err)
}
Expand Down

0 comments on commit be42955

Please sign in to comment.