Skip to content

Commit

Permalink
Fix: linter
Browse files Browse the repository at this point in the history
  • Loading branch information
nao1215 committed Feb 25, 2023
1 parent 232d1b4 commit 6594557
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/spf13/cobra"
)

var listCmd = &cobra.Command{
var listCmd = &cobra.Command{ //nolint
Use: "list",
Short: "List up GitHub pull request information",
Long: `List up GitHub repository or pull request information.
Expand All @@ -28,7 +28,7 @@ func init() { //nolint
*/
}

func list(cmd *cobra.Command, args []string) error {
func list(cmd *cobra.Command, args []string) error { //nolint
leadTime, err := di.NewLeadTime()
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ func Execute() int {
rootCmd.CompletionOptions.DisableDefaultCmd = true
if err := rootCmd.Execute(); err != nil {
log.Error(err)

return 1
}

return 0
}
5 changes: 3 additions & 2 deletions cmd/stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/spf13/cobra"
)

var statCmd = &cobra.Command{
var statCmd = &cobra.Command{ //nolint
Use: "stat",
Short: "Print GitHub pull request leadtime statics",
Long: `Print GitHub pull request leadtime statics`,
Expand All @@ -22,7 +22,7 @@ func init() { //nolint
rootCmd.AddCommand(statCmd)
}

func stat(cmd *cobra.Command, args []string) error {
func stat(cmd *cobra.Command, args []string) error { //nolint
leadTime, err := di.NewLeadTime()
if err != nil {
return err
Expand Down Expand Up @@ -64,5 +64,6 @@ func stat(cmd *cobra.Command, args []string) error {
fmt.Printf(" Lead Time(Sum) = %d[min]\n", output.LeadTime.Sum())
fmt.Printf(" Lead Time(Ave) = %.2f[min]\n", output.LeadTime.Ave())
fmt.Printf(" Lead Time(Median) = %.2f[min]\n", output.LeadTime.Median())

return nil
}
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func NewGitHubConfig() (*GitHubConfig, error) {
if err := env.Parse(cfg); err != nil {
return nil, ErrNotSetGitHubAccessToken
}

return cfg, nil
}

Expand Down
6 changes: 3 additions & 3 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"github.com/nao1215/leadtime/domain/model"
)

func TestNewGitHubConfig(t *testing.T) {
func TestNewGitHubConfig(t *testing.T) { //nolint
const token = model.Token("test_token")

t.Run("Get github config", func(t *testing.T) {
t.Run("Get github config", func(t *testing.T) { //nolint
t.Setenv("LT_GITHUB_ACCESS_TOKEN", token.String())

want := &GitHubConfig{
Expand All @@ -28,7 +28,7 @@ func TestNewGitHubConfig(t *testing.T) {
}
})

t.Run("if user does not set github access token", func(t *testing.T) {
t.Run("if user does not set github access token", func(t *testing.T) { //nolint
_, got := NewGitHubConfig()
if !errors.Is(got, ErrNotSetGitHubAccessToken) {
t.Errorf("mismatch want=%v, got=%v", ErrNotSetGitHubAccessToken, got)
Expand Down
2 changes: 1 addition & 1 deletion domain/usecase/pull_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (pr *PRUsecaseListInput) Valid() error {

// isEmptyRepositoryName check whether repository name is empty.
// true means empty, false means not empty.
func (pr *PRUsecaseListInput) isEmptyRepositoryName() bool {
func (pr *PRUsecaseListInput) isEmptyRepositoryName() bool { //nolist
return pr.Repository == ""
}

Expand Down
7 changes: 5 additions & 2 deletions infrastructure/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,12 @@ func (c *GitHubRepository) ListRepositories(ctx context.Context) ([]*model.Repos

// ListPullRequests return List the pull requests.
func (c *GitHubRepository) ListPullRequests(ctx context.Context, owner, repo string) ([]*model.PullRequest, error) {
const pagingLimit = 20

pullReqs := make([]*model.PullRequest, 0)
opts := &github.PullRequestListOptions{
State: "all",
ListOptions: github.ListOptions{PerPage: 20},
ListOptions: github.ListOptions{PerPage: pagingLimit},
}

for {
Expand Down Expand Up @@ -115,7 +116,9 @@ func (c *GitHubRepository) ListPullRequests(ctx context.Context, owner, repo str
// ListCommitsInPR return List the commits in the PR.
// oreder is newest to oldest.
func (c *GitHubRepository) ListCommitsInPR(ctx context.Context, owner, repo string, number int) ([]*model.Commit, error) {
opts := &github.ListOptions{PerPage: 20}
const pagingLimit = 20

opts := &github.ListOptions{PerPage: pagingLimit}

commitsInPR := make([]*model.Commit, 0)
for {
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

// osExit is wrapper for os.Exit(). It's for unit test.
var osExit = os.Exit
var osExit = os.Exit //nolint

func main() {
osExit(cmd.Execute())
Expand Down

0 comments on commit 6594557

Please sign in to comment.