Skip to content

Commit

Permalink
Merge pull request #784 from traPtitech/more-golangci-lint
Browse files Browse the repository at this point in the history
golangci-lintのルール増やす
  • Loading branch information
H1rono authored Jul 23, 2024
2 parents 5c20e25 + 9848a4f commit 1db6bd3
Show file tree
Hide file tree
Showing 51 changed files with 1,981 additions and 474 deletions.
34 changes: 34 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,37 @@ linters:
- unused
# https://golangci-lint.run/usage/linters/#disabled-by-default
- gofmt
- asasalint
- asciicheck
- contextcheck
- dogsled
- durationcheck
- errchkjson
- errname
- errorlint
- exhaustive
- fatcontext
- forbidigo
- forcetypeassert
- gocheckcompilerdirectives
- importas
- inamedparam
- intrange
- ireturn
- lll
- loggercheck
- makezero
- mirror
- musttag
- nilnil
- predeclared
- reassign
- thelper
- unconvert
- usestdlibvars
- wastedassign
- whitespace
linters-settings:
lll:
line-length: 100
tab-width: 4
24 changes: 20 additions & 4 deletions model/admin_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,17 @@ func TestEntRepository_GetAdmins(t *testing.T) {

t.Run("Success", func(t *testing.T) {
t.Parallel()
user1, err := repo.CreateUser(ctx, random.AlphaNumeric(t, 20), random.AlphaNumeric(t, 30), true)
user1, err := repo.CreateUser(
ctx,
random.AlphaNumeric(t, 20),
random.AlphaNumeric(t, 30),
true)
require.NoError(t, err)
user2, err := repo.CreateUser(ctx, random.AlphaNumeric(t, 20), random.AlphaNumeric(t, 30), true)
user2, err := repo.CreateUser(
ctx,
random.AlphaNumeric(t, 20),
random.AlphaNumeric(t, 30),
true)
require.NoError(t, err)

got, err := repo.GetAdmins(ctx)
Expand Down Expand Up @@ -54,7 +62,11 @@ func TestEntRepository_AddAdmins(t *testing.T) {

t.Run("Success", func(t *testing.T) {
t.Parallel()
user, err := repo.CreateUser(ctx, random.AlphaNumeric(t, 20), random.AlphaNumeric(t, 30), false)
user, err := repo.CreateUser(
ctx,
random.AlphaNumeric(t, 20),
random.AlphaNumeric(t, 30),
false)
require.NoError(t, err)

err = repo.AddAdmins(ctx, []uuid.UUID{user.ID})
Expand All @@ -74,7 +86,11 @@ func TestEntRepository_DeleteAdmins(t *testing.T) {

t.Run("Success", func(t *testing.T) {
t.Parallel()
user, err := repo.CreateUser(ctx, random.AlphaNumeric(t, 20), random.AlphaNumeric(t, 30), true)
user, err := repo.CreateUser(
ctx,
random.AlphaNumeric(t, 20),
random.AlphaNumeric(t, 30),
true)
require.NoError(t, err)

err = repo.DeleteAdmins(ctx, []uuid.UUID{user.ID})
Expand Down
8 changes: 6 additions & 2 deletions model/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ type Comment struct {

type CommentRepository interface {
GetComments(ctx context.Context, requestID uuid.UUID) ([]*Comment, error)
CreateComment(ctx context.Context, comment string, requestID uuid.UUID, userID uuid.UUID) (*Comment, error)
UpdateComment(ctx context.Context, comment string, requestID uuid.UUID, commentID uuid.UUID) (*Comment, error)
CreateComment(
ctx context.Context, comment string, requestID uuid.UUID, userID uuid.UUID,
) (*Comment, error)
UpdateComment(
ctx context.Context, comment string, requestID uuid.UUID, commentID uuid.UUID,
) (*Comment, error)
DeleteComment(ctx context.Context, requestID uuid.UUID, commentID uuid.UUID) error
}
16 changes: 12 additions & 4 deletions model/comment_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (
"github.com/traPtitech/Jomon/ent/request"
)

func (repo *EntRepository) GetComments(ctx context.Context, requestID uuid.UUID) ([]*Comment, error) {
func (repo *EntRepository) GetComments(
ctx context.Context, requestID uuid.UUID,
) ([]*Comment, error) {
_, err := repo.client.Request.
Query().
Where(request.IDEQ(requestID)).
Expand Down Expand Up @@ -38,7 +40,9 @@ func (repo *EntRepository) GetComments(ctx context.Context, requestID uuid.UUID)
return modelcomments, nil
}

func (repo *EntRepository) CreateComment(ctx context.Context, comment string, requestID uuid.UUID, userID uuid.UUID) (*Comment, error) {
func (repo *EntRepository) CreateComment(
ctx context.Context, comment string, requestID uuid.UUID, userID uuid.UUID,
) (*Comment, error) {
created, err := repo.client.Comment.
Create().
SetComment(comment).
Expand All @@ -51,7 +55,9 @@ func (repo *EntRepository) CreateComment(ctx context.Context, comment string, re
return ConvertEntCommentToModelComment(created, userID), nil
}

func (repo *EntRepository) UpdateComment(ctx context.Context, commentContent string, requestID uuid.UUID, commentID uuid.UUID) (*Comment, error) {
func (repo *EntRepository) UpdateComment(
ctx context.Context, commentContent string, requestID uuid.UUID, commentID uuid.UUID,
) (*Comment, error) {
updated, err := repo.client.Comment.
UpdateOneID(commentID).
SetComment(commentContent).
Expand All @@ -72,7 +78,9 @@ func (repo *EntRepository) UpdateComment(ctx context.Context, commentContent str
return ConvertEntCommentToModelComment(updated, updatedWithUser.Edges.User.ID), nil
}

func (repo *EntRepository) DeleteComment(ctx context.Context, requestID uuid.UUID, commentID uuid.UUID) error {
func (repo *EntRepository) DeleteComment(
ctx context.Context, requestID uuid.UUID, commentID uuid.UUID,
) error {
c, err := repo.client.Comment.
Query().
Where(
Expand Down
Loading

0 comments on commit 1db6bd3

Please sign in to comment.