diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0987e0c..a7c650a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v4 with: - version: latest + version: v1.58 - name: submit coverage run: | diff --git a/.golangci.yml b/.golangci.yml index d72b95c..e30fee4 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,7 @@ linters-settings: govet: - check-shadowing: true + enable: + - shadow misspell: locale: US gocritic: @@ -17,12 +18,12 @@ linters: disable-all: true enable: - bodyclose - - megacheck + - staticcheck - revive - govet - unconvert - unused - - gas + - gosec - misspell - unparam - typecheck @@ -38,12 +39,11 @@ linters: fast: false run: - modules-download-mode: vendor - skip-dirs: - - vendor concurrency: 4 issues: + exclude-dirs: + - vendor exclude-rules: - text: "weak cryptographic primitive" linters: diff --git a/app/proc/processor.go b/app/proc/processor.go index 4abdfd3..189c3b7 100644 --- a/app/proc/processor.go +++ b/app/proc/processor.go @@ -65,7 +65,7 @@ func (p *Processor) processFeeds(ctx context.Context) { time.Sleep(p.Conf.System.UpdateInterval) } -func (p *Processor) processFeed(name, url, telegramChannel string, max int, filter config.Filter) { +func (p *Processor) processFeed(name, url, telegramChannel string, maximum int, filter config.Filter) { rss, err := feed.Parse(url) if err != nil { log.Printf("[WARN] failed to parse %s, %v", url, err) @@ -73,8 +73,8 @@ func (p *Processor) processFeed(name, url, telegramChannel string, max int, filt } // up to MaxItems (5) items from each feed - upto := max - if len(rss.ItemList) <= max { + upto := maximum + if len(rss.ItemList) <= maximum { upto = len(rss.ItemList) } diff --git a/app/proc/store.go b/app/proc/store.go index be1d34e..9e7ef97 100644 --- a/app/proc/store.go +++ b/app/proc/store.go @@ -65,7 +65,7 @@ func (b BoltDB) Save(fmFeed string, item feed.Item) (bool, error) { } // Load from bold for given feed, up to max -func (b BoltDB) Load(fmFeed string, max int, skipJunk bool) ([]feed.Item, error) { +func (b BoltDB) Load(fmFeed string, maximum int, skipJunk bool) ([]feed.Item, error) { var result []feed.Item err := b.DB.View(func(tx *bolt.Tx) error { @@ -83,7 +83,7 @@ func (b BoltDB) Load(fmFeed string, max int, skipJunk bool) ([]feed.Item, error) if skipJunk && item.Junk { continue } - if len(result) >= max { + if len(result) >= maximum { break } result = append(result, item) diff --git a/app/proc/telegram.go b/app/proc/telegram.go index 80ccbd0..edd5e6d 100644 --- a/app/proc/telegram.go +++ b/app/proc/telegram.go @@ -195,9 +195,9 @@ func (r recipient) Recipient() string { } // CropText shrinks the provided string, removing HTML tags in case it's exceeding the limit -func CropText(inp string, max int) string { - if len([]rune(inp)) > max { - return CleanText(inp, max) +func CropText(inp string, maximum int) string { + if len([]rune(inp)) > maximum { + return CleanText(inp, maximum) } return inp } diff --git a/app/proc/twitter.go b/app/proc/twitter.go index e55ba01..0f22027 100644 --- a/app/proc/twitter.go +++ b/app/proc/twitter.go @@ -56,11 +56,11 @@ func (t *TwitterClient) Send(item feed.Item) error { } // CleanText removes html tags and shrinks result -func CleanText(inp string, max int) string { +func CleanText(inp string, maximum int) string { res := striphtmltags.StripTags(inp) - if len([]rune(res)) > max { + if len([]rune(res)) > maximum { // 4 symbols reserved for space and three dots on the end - snippet := []rune(res)[:max-4] + snippet := []rune(res)[:maximum-4] // go back in snippet and found first space for i := len(snippet) - 1; i >= 0; i-- { if snippet[i] == ' ' { diff --git a/app/youtube/store/store.go b/app/youtube/store/store.go index ae0cf4c..7b92bff 100644 --- a/app/youtube/store/store.go +++ b/app/youtube/store/store.go @@ -87,7 +87,7 @@ func (s *BoltDB) Exist(entry feed.Entry) (bool, error) { } // Load entries from bolt for a given channel, up to max in reverse order (from newest to oldest) -func (s *BoltDB) Load(channelID string, max int) ([]feed.Entry, error) { +func (s *BoltDB) Load(channelID string, maximum int) ([]feed.Entry, error) { var result []feed.Entry err := s.View(func(tx *bolt.Tx) error { @@ -102,7 +102,7 @@ func (s *BoltDB) Load(channelID string, max int) ([]feed.Entry, error) { log.Printf("[WARN] failed to unmarshal %s, %q: %v", channelID, string(v), err) continue } - if len(result) >= max { + if len(result) >= maximum { break } result = append(result, item)