From cd61cb4f27763cb7c055390c58f98312bf05b615 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Tue, 15 Oct 2024 18:32:24 +0200 Subject: [PATCH] Delete unnecessary nil checks from feed --- feed.go | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/feed.go b/feed.go index 961f421..f07b3f7 100644 --- a/feed.go +++ b/feed.go @@ -156,19 +156,15 @@ func (f *Feed) Check() error { } } - if f.Categories != nil { - for i, c := range f.Categories { - if err := c.Check(); err != nil { - return fmt.Errorf("category element %v of feed %v: %v", i, f.ID.URI, err) - } + for i, c := range f.Categories { + if err := c.Check(); err != nil { + 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 { - if err := c.Check(); err != nil { - return fmt.Errorf("contributor element %v of feed %v: %v", i, f.ID.URI, err) - } + for i, c := range f.Contributors { + if err := c.Check(); err != nil { + return fmt.Errorf("contributor element %v of feed %v: %v", i, f.ID.URI, err) } } @@ -184,11 +180,9 @@ func (f *Feed) Check() error { } } - if f.Links != nil { - for i, l := range f.Links { - if err := l.Check(); err != nil { - return fmt.Errorf("link element %v of feed %v: %v", i, f.ID.URI, err) - } + for i, l := range f.Links { + if err := l.Check(); err != nil { + return fmt.Errorf("link element %v of feed %v: %v", i, f.ID.URI, err) } } if hasAlternateDuplicateLinks(f.Links) { @@ -229,19 +223,15 @@ func (f *Feed) Check() error { } } - if f.Extensions != nil { - for i, x := range f.Extensions { - if err := x.Check(); err != nil { - return fmt.Errorf("extension element %v of feed %v: %v", i, f.ID.URI, err) - } + for i, x := range f.Extensions { + if err := x.Check(); err != nil { + 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 { - if err := n.Check(); err != nil { - return fmt.Errorf("entry element %v of feed %v: %v", i, f.ID.URI, err) - } + for i, n := range f.Entries { + if err := n.Check(); err != nil { + return fmt.Errorf("entry element %v of feed %v: %v", i, f.ID.URI, err) } }