Skip to content

Commit

Permalink
fix: make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
muesli committed May 18, 2022
1 parent a2db594 commit 104cbb1
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 48 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/lint-soft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: lint-soft
on:
push:
pull_request:

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read

jobs:
golangci:
name: lint-soft
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: golangci-lint command line arguments.
args: --config .golangci-soft.yml --issues-exit-code=0
# Optional: show only new issues if it's a pull request. The default value is `false`.
only-new-issues: true
15 changes: 8 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ on:
push:
pull_request:

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.30
# Optional: golangci-lint command line arguments.
args: --issues-exit-code=0
# Optional: working directory, useful for monorepos
# working-directory: somedir
#args:
# Optional: show only new issues if it's a pull request. The default value is `false`.
only-new-issues: true
47 changes: 47 additions & 0 deletions .golangci-soft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
run:
tests: false

issues:
include:
- EXC0001
- EXC0005
- EXC0011
- EXC0012
- EXC0013

max-issues-per-linter: 0
max-same-issues: 0

linters:
enable:
# - dupl
- exhaustive
# - exhaustivestruct
- goconst
- godot
- godox
- gomnd
- gomoddirectives
- goprintffuncname
- ifshort
# - lll
- misspell
- nakedret
- nestif
- noctx
- nolintlint
- prealloc
- wrapcheck

# disable default linters, they are already enabled in .golangci.yml
disable:
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
18 changes: 11 additions & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,28 @@ run:
tests: false

issues:
include:
- EXC0001
- EXC0005
- EXC0011
- EXC0012
- EXC0013

max-issues-per-linter: 0
max-same-issues: 0

linters:
enable:
- bodyclose
- dupl
- exportloopref
- goconst
- godot
- godox
- goimports
- goprintffuncname
- gosec
- misspell
- prealloc
- nilerr
- predeclared
- revive
- rowserrcheck
- sqlclosecheck
- tparallel
- unconvert
- unparam
- whitespace
4 changes: 2 additions & 2 deletions gists.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var gistsQuery struct {
TotalCount githubv4.Int
Edges []struct {
Cursor githubv4.String
Node QLGist
Node qlGist
}
} `graphql:"gists(first: $count, orderBy: {field: CREATED_AT, direction: DESC})"`
} `graphql:"user(login:$username)"`
Expand All @@ -34,7 +34,7 @@ func gists(count int) []Gist {

// fmt.Printf("%+v\n", query)
for _, v := range gistsQuery.User.Gists.Edges {
gists = append(gists, GistFromQL(v.Node))
gists = append(gists, gistFromQL(v.Node))
}

// fmt.Printf("Found %d gists!\n", len(gists))
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func main() {
fmt.Println("Can't create:", err)
os.Exit(1)
}
defer f.Close()
defer f.Close() //nolint: errcheck
w = f
}

Expand Down
22 changes: 11 additions & 11 deletions repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var recentContributionsQuery struct {
}
}
} `graphql:"contributions(first: 1)"`
Repository QLRepository
Repository qlRepository
} `graphql:"commitContributionsByRepository(maxRepositories: 100)"`
}
} `graphql:"user(login:$username)"`
Expand All @@ -34,7 +34,7 @@ var recentPullRequestsQuery struct {
TotalCount githubv4.Int
Edges []struct {
Cursor githubv4.String
Node QLPullRequest
Node qlPullRequest
}
} `graphql:"pullRequests(first: $count, orderBy: {field: CREATED_AT, direction: DESC})"`
} `graphql:"user(login:$username)"`
Expand All @@ -47,7 +47,7 @@ var recentReposQuery struct {
TotalCount githubv4.Int
Edges []struct {
Cursor githubv4.String
Node QLRepository
Node qlRepository
}
} `graphql:"repositories(first: $count, privacy: PUBLIC, isFork: false, ownerAffiliations: OWNER, orderBy: {field: CREATED_AT, direction: DESC})"`
} `graphql:"user(login:$username)"`
Expand All @@ -61,8 +61,8 @@ var recentReleasesQuery struct {
Edges []struct {
Cursor githubv4.String
Node struct {
QLRepository
Releases QLRelease `graphql:"releases(first: 10, orderBy: {field: CREATED_AT, direction: DESC})"`
qlRepository
Releases qlRelease `graphql:"releases(first: 10, orderBy: {field: CREATED_AT, direction: DESC})"`
}
}
} `graphql:"repositoriesContributedTo(first: 100, after:$after includeUserRepositories: true, contributionTypes: COMMIT, privacy: PUBLIC)"`
Expand Down Expand Up @@ -91,7 +91,7 @@ func recentContributions(count int) []Contribution {
}

c := Contribution{
Repo: RepoFromQL(v.Repository),
Repo: repoFromQL(v.Repository),
OccurredAt: v.Contributions.Edges[0].Node.OccurredAt.Time,
}

Expand Down Expand Up @@ -131,7 +131,7 @@ func recentPullRequests(count int) []PullRequest {
continue
}

pullRequests = append(pullRequests, PullRequestFromQL(v.Node))
pullRequests = append(pullRequests, pullRequestFromQL(v.Node))
if len(pullRequests) == count {
break
}
Expand Down Expand Up @@ -160,7 +160,7 @@ func recentRepos(count int) []Repo {
continue
}

repos = append(repos, RepoFromQL(v.Node))
repos = append(repos, repoFromQL(v.Node))
if len(repos) == count {
break
}
Expand Down Expand Up @@ -192,7 +192,7 @@ func recentReleases(count int) []Repo {
}

for _, v := range recentReleasesQuery.User.RepositoriesContributedTo.Edges {
r := RepoFromQL(v.Node.QLRepository)
r := repoFromQL(v.Node.qlRepository)

for _, rel := range v.Node.Releases.Nodes {
if rel.IsPrerelease || rel.IsDraft {
Expand All @@ -202,15 +202,15 @@ func recentReleases(count int) []Repo {
v.Node.Releases.Nodes[0].PublishedAt.Time.IsZero() {
continue
}
r.LastRelease = ReleaseFromQL(v.Node.Releases)
r.LastRelease = releaseFromQL(v.Node.Releases)
break
}

if !r.LastRelease.PublishedAt.IsZero() {
repos = append(repos, r)
}

after = &v.Cursor
after = githubv4.NewString(v.Cursor)
}
}

Expand Down
1 change: 1 addition & 0 deletions rss.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/mmcdole/gofeed"
)

// RSSEntry represents a single RSS entry.
type RSSEntry struct {
Title string
URL string
Expand Down
8 changes: 4 additions & 4 deletions sponsors.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ var sponsorsQuery struct {
CreatedAt githubv4.DateTime
SponsorEntity struct {
Typename githubv4.String `graphql:"__typename"`
User QLUser `graphql:"... on User"`
Organization QLUser `graphql:"... on Organization"`
User qlUser `graphql:"... on User"`
Organization qlUser `graphql:"... on Organization"`
}
}
}
Expand All @@ -45,12 +45,12 @@ func sponsors(count int) []Sponsor {
switch v.Node.SponsorEntity.Typename {
case "User":
sponsors = append(sponsors, Sponsor{
User: UserFromQL(v.Node.SponsorEntity.User),
User: userFromQL(v.Node.SponsorEntity.User),
CreatedAt: v.Node.CreatedAt.Time,
})
case "Organization":
sponsors = append(sponsors, Sponsor{
User: UserFromQL(v.Node.SponsorEntity.Organization),
User: userFromQL(v.Node.SponsorEntity.Organization),
CreatedAt: v.Node.CreatedAt.Time,
})
}
Expand Down
4 changes: 2 additions & 2 deletions stars.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var recentStarsQuery struct {
Edges []struct {
Cursor githubv4.String
StarredAt githubv4.DateTime
Node QLRepository
Node qlRepository
}
} `graphql:"starredRepositories(first: $count, orderBy: {field: STARRED_AT, direction: DESC})"`
} `graphql:"user(login:$username)"`
Expand All @@ -34,7 +34,7 @@ func recentStars(count int) []Star {
for _, v := range recentStarsQuery.User.Stars.Edges {
starredRepos = append(starredRepos, Star{
StarredAt: v.StarredAt.Time,
Repo: RepoFromQL(v.Node),
Repo: repoFromQL(v.Node),
})
}

Expand Down
Loading

0 comments on commit 104cbb1

Please sign in to comment.