diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac55399f..9d4339d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,36 +5,6 @@ on: - master jobs: - - linters: - name: Linter Check - runs-on: ubuntu-latest - steps: - - name: Set up Go - uses: actions/setup-go@v1 - with: - go-version: 1.16 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Checkout - uses: actions/checkout@v1 - with: - fetch-depth: 3 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Install linters - run: | - cd /tmp && go get -u golang.org/x/lint/golint - sudo npm install -g jshint - env: - GO111MODULE: off - - name: Run golint - run: | - export PATH=/home/runner/go/bin:$PATH - make lint - - name: Run jshint - run: jshint ui/static/js/*.js - unit-tests: name: Unit Tests runs-on: ${{ matrix.os }} @@ -45,17 +15,11 @@ jobs: go-version: [1.16] steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: ${{ matrix.go-version }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Checkout - uses: actions/checkout@v1 - with: - fetch-depth: 3 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: actions/checkout@v2 - name: Run unit tests run: make test @@ -74,17 +38,11 @@ jobs: options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 steps: - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.16 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Checkout - uses: actions/checkout@v1 - with: - fetch-depth: 3 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: actions/checkout@v2 - name: Install Postgres client run: sudo apt-get install -y postgresql-client - name: Run integration tests diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml new file mode 100644 index 00000000..de7fe68e --- /dev/null +++ b/.github/workflows/linters.yml @@ -0,0 +1,30 @@ +name: Linters +on: + pull_request: + branches: + - master + +jobs: + jshint: + name: Javascript Linter + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install jshint + run: | + sudo npm install -g jshint + - name: Run jshint + run: jshint ui/static/js/*.js + + golangci: + name: Golang Linter + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: 1.16 + - uses: golangci/golangci-lint-action@v2 + with: + args: --skip-dirs tests --disable errcheck --enable sqlclosecheck --enable misspell --enable gofmt --enable goimports --enable whitespace + skip-go-installation: true diff --git a/client/client.go b/client/client.go index b5ab34da..03729767 100644 --- a/client/client.go +++ b/client/client.go @@ -345,7 +345,7 @@ func (c *Client) MarkFeedAsRead(feedID int64) error { // RefreshAllFeeds refreshes all feeds. func (c *Client) RefreshAllFeeds() error { - _, err := c.request.Put(fmt.Sprintf("/v1/feeds/refresh"), nil) + _, err := c.request.Put("/v1/feeds/refresh", nil) return err } diff --git a/client/request.go b/client/request.go index 0e2e885b..c6b5eb9e 100644 --- a/client/request.go +++ b/client/request.go @@ -82,9 +82,9 @@ func (r *request) execute(method, path string, data interface{}) (io.ReadCloser, } if data != nil { - switch data.(type) { + switch data := data.(type) { case io.ReadCloser: - request.Body = data.(io.ReadCloser) + request.Body = data default: request.Body = io.NopCloser(bytes.NewBuffer(r.toJSON(data))) } diff --git a/http/client/response_test.go b/http/client/response_test.go index 0dbd4d72..dfcf17e5 100644 --- a/http/client/response_test.go +++ b/http/client/response_test.go @@ -96,7 +96,7 @@ func TestToString(t *testing.T) { r := &Response{Body: strings.NewReader(input)} if r.BodyAsString() != input { - t.Error(`Unexpected ouput`) + t.Error(`Unexpected output`) } } diff --git a/http/route/route.go b/http/route/route.go index e7b1dc28..0a0ec3b6 100644 --- a/http/route/route.go +++ b/http/route/route.go @@ -19,13 +19,12 @@ func Path(router *mux.Router, name string, args ...interface{}) string { } var pairs []string - for _, param := range args { - switch param.(type) { + for _, arg := range args { + switch param := arg.(type) { case string: - pairs = append(pairs, param.(string)) + pairs = append(pairs, param) case int64: - val := param.(int64) - pairs = append(pairs, strconv.FormatInt(val, 10)) + pairs = append(pairs, strconv.FormatInt(param, 10)) } } diff --git a/model/user.go b/model/user.go index 347104b7..1163fedc 100644 --- a/model/user.go +++ b/model/user.go @@ -56,7 +56,7 @@ type UserModificationRequest struct { KeyboardShortcuts *bool `json:"keyboard_shortcuts"` ShowReadingTime *bool `json:"show_reading_time"` EntrySwipe *bool `json:"entry_swipe"` - DisplayMode *string `json:"display_mode"` + DisplayMode *string `json:"display_mode"` } // Patch updates the User object with the modification request. diff --git a/reader/atom/atom_10.go b/reader/atom/atom_10.go index f31d89fa..de2ccc77 100644 --- a/reader/atom/atom_10.go +++ b/reader/atom/atom_10.go @@ -157,7 +157,7 @@ func (a *atom10Entry) entryHash() string { func (a *atom10Entry) entryEnclosures() model.EnclosureList { enclosures := make(model.EnclosureList, 0) - duplicates := make(map[string]bool, 0) + duplicates := make(map[string]bool) for _, mediaThumbnail := range a.AllMediaThumbnails() { if _, found := duplicates[mediaThumbnail.URL]; !found { diff --git a/reader/rss/rss.go b/reader/rss/rss.go index 7324cc5a..01caada4 100644 --- a/reader/rss/rss.go +++ b/reader/rss/rss.go @@ -292,7 +292,7 @@ func (r *rssItem) entryURL() string { func (r *rssItem) entryEnclosures() model.EnclosureList { enclosures := make(model.EnclosureList, 0) - duplicates := make(map[string]bool, 0) + duplicates := make(map[string]bool) for _, mediaThumbnail := range r.AllMediaThumbnails() { if _, found := duplicates[mediaThumbnail.URL]; !found { diff --git a/storage/entry_query_builder.go b/storage/entry_query_builder.go index b87b2e7f..cc6fca10 100644 --- a/storage/entry_query_builder.go +++ b/storage/entry_query_builder.go @@ -374,7 +374,7 @@ func (e *EntryQueryBuilder) buildSorting() string { } if e.direction != "" { - parts = append(parts, fmt.Sprintf(`%s`, e.direction)) + parts = append(parts, e.direction) } if e.limit > 0 { diff --git a/storage/feed_query_builder.go b/storage/feed_query_builder.go index 66547c87..dbb338ec 100644 --- a/storage/feed_query_builder.go +++ b/storage/feed_query_builder.go @@ -106,7 +106,7 @@ func (f *FeedQueryBuilder) buildSorting() string { } if f.direction != "" { - parts = append(parts, fmt.Sprintf(`%s`, f.direction)) + parts = append(parts, f.direction) } if len(parts) > 0 { diff --git a/template/functions.go b/template/functions.go index 33519e95..7ae17d24 100644 --- a/template/functions.go +++ b/template/functions.go @@ -136,10 +136,7 @@ func truncate(str string, max int) string { func isEmail(str string) bool { _, err := mail.ParseAddress(str) - if err != nil { - return false - } - return true + return err == nil } func elapsedTime(printer *locale.Printer, tz string, t time.Time) string { diff --git a/tests/tests.go b/tests/tests.go index 07f50635..1227f03d 100644 --- a/tests/tests.go +++ b/tests/tests.go @@ -2,6 +2,8 @@ // Use of this source code is governed by the Apache 2.0 // license that can be found in the LICENSE file. +// +build integration + package tests import ( diff --git a/tests/user_test.go b/tests/user_test.go index 36eca265..a41949dd 100644 --- a/tests/user_test.go +++ b/tests/user_test.go @@ -212,7 +212,7 @@ func TestGetUserByID(t *testing.T) { func TestGetUserByUsername(t *testing.T) { username := getRandomUsername() client := miniflux.New(testBaseURL, testAdminUsername, testAdminPassword) - user, err := client.CreateUser(username, testStandardPassword, false) + _, err := client.CreateUser(username, testStandardPassword, false) if err != nil { t.Fatal(err) } @@ -222,7 +222,7 @@ func TestGetUserByUsername(t *testing.T) { t.Fatal(`Should returns a 404`) } - user, err = client.UserByUsername(username) + user, err := client.UserByUsername(username) if err != nil { t.Fatal(err) }