Delete unnecessary nil checks from feed

This commit is contained in:
Jason Streifling 2024-10-15 18:32:24 +02:00
parent f2c6fce7c9
commit cd61cb4f27

10
feed.go
View File

@ -156,21 +156,17 @@ func (f *Feed) Check() error {
} }
} }
if f.Categories != nil {
for i, c := range f.Categories { for i, c := range f.Categories {
if err := c.Check(); err != nil { if err := c.Check(); err != nil {
return fmt.Errorf("category element %v of feed %v: %v", i, f.ID.URI, err) return fmt.Errorf("category element %v of feed %v: %v", i, f.ID.URI, err)
} }
} }
}
if f.Contributors != nil {
for i, c := range f.Contributors { for i, c := range f.Contributors {
if err := c.Check(); err != nil { if err := c.Check(); err != nil {
return fmt.Errorf("contributor element %v of feed %v: %v", i, f.ID.URI, err) return fmt.Errorf("contributor element %v of feed %v: %v", i, f.ID.URI, err)
} }
} }
}
if f.Generator != nil { if f.Generator != nil {
if err := f.Generator.Check(); err != nil { if err := f.Generator.Check(); err != nil {
@ -184,13 +180,11 @@ func (f *Feed) Check() error {
} }
} }
if f.Links != nil {
for i, l := range f.Links { for i, l := range f.Links {
if err := l.Check(); err != nil { if err := l.Check(); err != nil {
return fmt.Errorf("link element %v of feed %v: %v", i, f.ID.URI, err) return fmt.Errorf("link element %v of feed %v: %v", i, f.ID.URI, err)
} }
} }
}
if hasAlternateDuplicateLinks(f.Links) { if hasAlternateDuplicateLinks(f.Links) {
return errors.New("links with with a rel attribute value of \"alternate\" and duplicate type and hreflang attribute values found") return errors.New("links with with a rel attribute value of \"alternate\" and duplicate type and hreflang attribute values found")
} }
@ -229,21 +223,17 @@ func (f *Feed) Check() error {
} }
} }
if f.Extensions != nil {
for i, x := range f.Extensions { for i, x := range f.Extensions {
if err := x.Check(); err != nil { if err := x.Check(); err != nil {
return fmt.Errorf("extension element %v of feed %v: %v", i, f.ID.URI, err) return fmt.Errorf("extension element %v of feed %v: %v", i, f.ID.URI, err)
} }
} }
}
if f.Entries != nil {
for i, n := range f.Entries { for i, n := range f.Entries {
if err := n.Check(); err != nil { if err := n.Check(); err != nil {
return fmt.Errorf("entry element %v of feed %v: %v", i, f.ID.URI, err) return fmt.Errorf("entry element %v of feed %v: %v", i, f.ID.URI, err)
} }
} }
}
return nil return nil
} }