Skip to content

Commit

Permalink
pin golangci-lint version to latest available, fix reported errors
Browse files Browse the repository at this point in the history
  • Loading branch information
paskal committed May 9, 2024
1 parent 877765c commit 048d4b9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
version: v1.58
working-directory: backend/app

- name: golangci-lint on example directory
uses: golangci/golangci-lint-action@v3
with:
version: latest
version: v1.58
args: --config ../../.golangci.yml
working-directory: backend/_example/memory_store

Expand Down
17 changes: 8 additions & 9 deletions backend/.golangci.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
run:
timeout: 5m
output:
format: tab
skip-dirs:
- vendor

linters-settings:
govet:
check-shadowing: true
maligned:
suggest-new: true
enable:
- shadow
goconst:
min-len: 2
min-occurrences: 2
Expand All @@ -31,11 +26,13 @@ linters-settings:
linters:
enable:
- bodyclose
- megacheck
- gosimple
- staticcheck
- unused
- revive
- govet
- unconvert
- gas
- gosec
- gocyclo
- dupl
- misspell
Expand All @@ -54,6 +51,8 @@ linters:
disable-all: true

issues:
exclude-dirs:
- vendor
exclude-rules:
- text: "at least one file in a package should have a package comment"
linters:
Expand Down
2 changes: 1 addition & 1 deletion backend/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func getDump() string {
return string(stacktrace[:length])
}

// nolint:gochecknoinits // can't avoid it in this place
//nolint:gochecknoinits // can't avoid it in this place
func init() {
// catch SIGQUIT and print stack traces
sigChan := make(chan os.Signal, 1)
Expand Down
8 changes: 4 additions & 4 deletions backend/app/store/engine/bolt.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,11 @@ func (b *BoltDB) Close() error {
}

// Last returns up to max last comments for given siteID
func (b *BoltDB) lastComments(siteID string, max int, since time.Time) (comments []store.Comment, err error) {
func (b *BoltDB) lastComments(siteID string, maximum int, since time.Time) (comments []store.Comment, err error) {
comments = []store.Comment{}

if max > lastLimit || max == 0 {
max = lastLimit
if maximum > lastLimit || maximum == 0 {
maximum = lastLimit
}

bdb, err := b.db(siteID)
Expand Down Expand Up @@ -466,7 +466,7 @@ func (b *BoltDB) lastComments(siteID string, max int, since time.Time) (comments
continue
}
comments = append(comments, comment)
if len(comments) >= max {
if len(comments) >= maximum {
break
}
}
Expand Down
6 changes: 3 additions & 3 deletions backend/app/store/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ func (f *CommentFormatter) FormatText(txt string, raw bool) (res string) {
}

// Shortens all the automatic links in HTML: auto link has equal "href" and "text" attributes.
func (f *CommentFormatter) shortenAutoLinks(commentHTML string, max int) (resHTML string) {
func (f *CommentFormatter) shortenAutoLinks(commentHTML string, maximum int) (resHTML string) {
doc, err := goquery.NewDocumentFromReader(strings.NewReader(commentHTML))
if err != nil {
return commentHTML
}
doc.Find("a").Each(func(_ int, s *goquery.Selection) {
if href, ok := s.Attr("href"); ok {
if href != s.Text() || len(href) < max+3 || max < 3 {
if href != s.Text() || len(href) < maximum+3 || maximum < 3 {
return
}
commentURL, e := url.Parse(href)
Expand All @@ -77,7 +77,7 @@ func (f *CommentFormatter) shortenAutoLinks(commentHTML string, max int) (resHTM
return
}

short := string([]rune(href)[:max-3])
short := string([]rune(href)[:maximum-3])
if len(short) < len(host) {
short = host
}
Expand Down

0 comments on commit 048d4b9

Please sign in to comment.