Cleanup semgrep errors
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing

This commit is contained in:
Peter Stuifzand 2021-08-10 23:45:05 +02:00
parent 61e4a84848
commit e30933090b
Signed by: peter
GPG Key ID: 374322D56E5209E8
5 changed files with 10 additions and 33 deletions

View File

@ -119,11 +119,7 @@ func (h *mainHandler) renderTemplate(w io.Writer, filename string, data interfac
if err != nil {
return err
}
err = t.ExecuteTemplate(w, filename, data)
if err != nil {
return err
}
return nil
return t.ExecuteTemplate(w, filename, data)
}
func getSessionCookie(w http.ResponseWriter, r *http.Request) string {
@ -154,11 +150,7 @@ func loadSession(sessionVar string, conn redis.Conn) (session, error) {
}
err = redis.ScanStruct(data, &sess)
if err != nil {
return sess, err
}
return sess, nil
return sess, err
}
func saveSession(sessionVar string, sess *session, conn redis.Conn) error {

View File

@ -114,12 +114,7 @@ func (b *memoryBackend) load() error {
}
defer f.Close()
jw := json.NewDecoder(f)
err = jw.Decode(b)
if err != nil {
return err
}
return nil
return jw.Decode(b)
}
func (b *memoryBackend) refreshChannels() {
@ -558,12 +553,7 @@ func (b *memoryBackend) MarkRead(channel string, uids []string) error {
return err
}
err = b.updateChannelUnreadCount(channel)
if err != nil {
return err
}
return nil
return b.updateChannelUnreadCount(channel)
}
func (b *memoryBackend) Events() (chan sse.Message, error) {
@ -586,12 +576,7 @@ func (b *memoryBackend) ProcessContent(channel, fetchURL, contentType string, bo
}
}
err = b.updateChannelUnreadCount(channel)
if err != nil {
return err
}
return nil
return b.updateChannelUnreadCount(channel)
}
// Fetch3 fills stuff

View File

@ -1,6 +1,7 @@
package main
import (
"errors"
"fmt"
"os"
@ -11,7 +12,7 @@ import (
var index bleve.Index
func initSearch() error {
if _, err := os.Stat("items.bleve"); os.IsNotExist(err) {
if _, err := os.Stat("items.bleve"); errors.Is(err, os.ErrNotExist) {
mapping := bleve.NewIndexMapping()
index, err = bleve.New("items.bleve", mapping)
if err != nil {

View File

@ -85,8 +85,7 @@ func (timeline *redisSortedSetTimeline) Items(before, after string) (microsub.Ti
item := microsub.Item{}
err := json.Unmarshal(obj, &item)
if err != nil {
// FIXME: what should we do if one of the items doen't unmarshal?
log.Println(err)
log.Printf("item doesn not unmarshal: %v", err)
continue
}
item.Read = false

View File

@ -21,12 +21,12 @@ import (
func GetHubURL(client *http.Client, topic string) (string, error) {
hubURL, err := parseLinkHeaders(client, topic)
if err == nil {
return hubURL, err
return hubURL, nil
}
hubURL, err = parseBodyLinks(client, topic)
if err == nil {
return hubURL, err
return hubURL, nil
}
return "", fmt.Errorf("no hub url found for topic %s", topic)