From 5290a0b549813c60610e4b941b0b3d09b3fa135f Mon Sep 17 00:00:00 2001 From: Alessio Date: Mon, 14 Jun 2021 13:08:38 -0700 Subject: [PATCH] Add linting --- .build.yml | 18 ++++++++++++++++++ scraper/api_types.go | 2 +- scraper/guest_token_test.go | 2 +- scraper/retweet_test.go | 3 +++ scraper/user_test.go | 3 +++ 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/.build.yml b/.build.yml index 9a425a2..8bd1a44 100644 --- a/.build.yml +++ b/.build.yml @@ -27,3 +27,21 @@ tasks: cd twitter_offline_engine/scraper go test -bench=. + + - install_golangci-lint: | + SECONDS=0 + + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b /usr/local/go/bin v1.40.1 + sudo ln /usr/local/go/bin/golangci-lint /usr/bin/golangci-lint + + duration=$SECONDS + echo "Task completed in $(($duration / 60))m$(($duration % 60))s." + + - run_lint: | + SECONDS=0 + + cd twitter_offline_engine/scraper + golangci-lint run + + duration=$SECONDS + echo "Task completed in $(($duration / 60))m$(($duration % 60))s." diff --git a/scraper/api_types.go b/scraper/api_types.go index 7072093..3cff651 100644 --- a/scraper/api_types.go +++ b/scraper/api_types.go @@ -142,7 +142,7 @@ type TweetResponse struct { Cursor struct { Value string `json:"value"` } `json:"cursor"` - } `json:"operation` + } `json:"operation"` } `json:"content"` } `json:"entries"` } `json:"addEntries"` diff --git a/scraper/guest_token_test.go b/scraper/guest_token_test.go index 941145b..952831a 100644 --- a/scraper/guest_token_test.go +++ b/scraper/guest_token_test.go @@ -22,6 +22,6 @@ func TestGetGuestToken(t *testing.T) { // other than the first use the cache. func BenchmarkGetGuestToken(b *testing.B) { for i := 0; i < b.N; i++ { - scraper.GetGuestToken() + _, _ = scraper.GetGuestToken() } } diff --git a/scraper/retweet_test.go b/scraper/retweet_test.go index 81d4327..30e127d 100644 --- a/scraper/retweet_test.go +++ b/scraper/retweet_test.go @@ -20,6 +20,9 @@ func TestParseSingleRetweet(t *testing.T) { } retweet, err := scraper.ParseSingleRetweet(api_tweet) + if err != nil { + t.Errorf(err.Error()) + } if retweet.RetweetID != scraper.TweetID("1404270043018448896") { t.Errorf("Expected %q, got %q", scraper.TweetID("1404270043018448896"), retweet.RetweetID) diff --git a/scraper/user_test.go b/scraper/user_test.go index 372646d..1b571f2 100644 --- a/scraper/user_test.go +++ b/scraper/user_test.go @@ -21,6 +21,9 @@ func TestParseSingleUser(t *testing.T) { apiUser := user_resp.ConvertToAPIUser() user, err := scraper.ParseSingleUser(apiUser) + if err != nil { + t.Errorf(err.Error()) + } if user.ID != "44067298" { t.Errorf("Expected %q, got %q", "44067298", user.ID)