Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pin golangci-lint version to latest available, fix reported errors #129

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: latest
version: v1.58

- name: submit coverage
run: |
Expand Down
12 changes: 6 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
linters-settings:
govet:
check-shadowing: true
enable:
- shadow
misspell:
locale: US
gocritic:
Expand All @@ -17,12 +18,12 @@ linters:
disable-all: true
enable:
- bodyclose
- megacheck
- staticcheck
- revive
- govet
- unconvert
- unused
- gas
- gosec
- misspell
- unparam
- typecheck
Expand All @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions app/proc/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ 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)
return
}

// 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)
}

Expand Down
4 changes: 2 additions & 2 deletions app/proc/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions app/proc/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions app/proc/twitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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] == ' ' {
Expand Down
4 changes: 2 additions & 2 deletions app/youtube/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down
Loading