mirror of
https://github.com/miniflux/v2.git
synced 2025-07-22 17:18:37 +00:00
fix: address minor issues detected by Go linters
This commit is contained in:
parent
febb7b1748
commit
31f0afe1ac
10 changed files with 31 additions and 25 deletions
|
@ -116,12 +116,12 @@ type Atom03Content struct {
|
|||
func (a *Atom03Content) Content() string {
|
||||
content := ""
|
||||
|
||||
switch {
|
||||
case a.Mode == "xml":
|
||||
switch a.Mode {
|
||||
case "xml":
|
||||
content = a.InnerXML
|
||||
case a.Mode == "escaped":
|
||||
case "escaped":
|
||||
content = a.CharData
|
||||
case a.Mode == "base64":
|
||||
case "base64":
|
||||
b, err := base64.StdEncoding.DecodeString(a.CharData)
|
||||
if err == nil {
|
||||
content = string(b)
|
||||
|
|
|
@ -77,7 +77,9 @@ func (h *Handler) Import(userID int64, data io.Reader) error {
|
|||
Category: category,
|
||||
}
|
||||
|
||||
h.store.CreateFeed(feed)
|
||||
if err := h.store.CreateFeed(feed); err != nil {
|
||||
return fmt.Errorf(`opml: unable to create this feed: %q`, subscription.FeedURL)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ func (r *RSSAdapter) BuildFeed(baseURL string) *model.Feed {
|
|||
}
|
||||
|
||||
// Try to find the feed URL from the Atom links.
|
||||
for _, atomLink := range r.rss.Channel.AtomLinks.Links {
|
||||
for _, atomLink := range r.rss.Channel.Links {
|
||||
atomLinkHref := strings.TrimSpace(atomLink.Href)
|
||||
if atomLinkHref != "" && atomLink.Rel == "self" {
|
||||
if absoluteFeedURL, err := urllib.AbsoluteURL(feed.FeedURL, atomLinkHref); err == nil {
|
||||
|
@ -189,7 +189,7 @@ func findEntryURL(rssItem *RSSItem) string {
|
|||
}
|
||||
}
|
||||
|
||||
for _, atomLink := range rssItem.AtomLinks.Links {
|
||||
for _, atomLink := range rssItem.Links {
|
||||
if atomLink.Href != "" && (strings.EqualFold(atomLink.Rel, "alternate") || atomLink.Rel == "") {
|
||||
return strings.TrimSpace(atomLink.Href)
|
||||
}
|
||||
|
@ -253,8 +253,8 @@ func findEntryAuthor(rssItem *RSSItem) string {
|
|||
author = rssItem.ItunesAuthor
|
||||
case rssItem.DublinCoreCreator != "":
|
||||
author = rssItem.DublinCoreCreator
|
||||
case rssItem.AtomAuthor.PersonName() != "":
|
||||
author = rssItem.AtomAuthor.PersonName()
|
||||
case rssItem.PersonName() != "":
|
||||
author = rssItem.PersonName()
|
||||
case strings.Contains(rssItem.Author.Inner, "<![CDATA["):
|
||||
author = rssItem.Author.Data
|
||||
default:
|
||||
|
|
|
@ -283,9 +283,10 @@ func isPixelTracker(tagName string, attributes []html.Attribute) bool {
|
|||
|
||||
for _, attribute := range attributes {
|
||||
if attribute.Val == "1" {
|
||||
if attribute.Key == "height" {
|
||||
switch attribute.Key {
|
||||
case "height":
|
||||
hasHeight = true
|
||||
} else if attribute.Key == "width" {
|
||||
case "width":
|
||||
hasWidth = true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,10 +49,10 @@ func parseImageCandidate(input string) (*ImageCandidate, error) {
|
|||
parts := strings.Split(strings.TrimSpace(input), " ")
|
||||
nbParts := len(parts)
|
||||
|
||||
switch {
|
||||
case nbParts == 1:
|
||||
switch nbParts {
|
||||
case 1:
|
||||
return &ImageCandidate{ImageURL: parts[0]}, nil
|
||||
case nbParts == 2:
|
||||
case 2:
|
||||
if !isValidWidthOrDensityDescriptor(parts[1]) {
|
||||
return nil, fmt.Errorf(`srcset: invalid descriptor`)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue