Skip to content

Commit

Permalink
🎨 Remove the other too long lines (lll)
Browse files Browse the repository at this point in the history
H1rono committed Jul 19, 2024
1 parent fe274f4 commit 8d2e8b2
Showing 2 changed files with 44 additions and 10 deletions.
49 changes: 40 additions & 9 deletions service/webhook.go
Original file line number Diff line number Diff line change
@@ -87,9 +87,16 @@ func WebhookEventHandler(c echo.Context, reqBody, resBody []byte) {
}
splitedPath := strings.Split(c.Request().URL.Path, "/")

message += fmt.Sprintf("## :comment:[申請](%s/requests/%s)", "https://jomon.trap.jp", splitedPath[3])
message += fmt.Sprintf(
"## :comment:[申請](%s/requests/%s)",
"https://jomon.trap.jp",
splitedPath[3])

Check warning on line 93 in service/webhook.go

Codecov / codecov/patch

service/webhook.go#L90-L93

Added lines #L90 - L93 were not covered by tests
message += "に対する"
message += fmt.Sprintf("[コメント](%s/requests/%s/comments/%s)", "https://jomon.trap.jp", splitedPath[3], resApp.ID)
message += fmt.Sprintf(
"[コメント](%s/requests/%s/comments/%s)",
"https://jomon.trap.jp",
splitedPath[3],
resApp.ID)

Check warning on line 99 in service/webhook.go

Codecov / codecov/patch

service/webhook.go#L95-L99

Added lines #L95 - L99 were not covered by tests
message += "が作成されました\n\n"
message += resApp.Comment + "\n"
} else {
@@ -104,7 +111,11 @@ func WebhookEventHandler(c echo.Context, reqBody, resBody []byte) {
message += "## :receipt:申請が更新されました\n"
}

message += fmt.Sprintf("### [%s](%s/applications/%s)", resApp.Title, "https://jomon.trap.jp", resApp.ID) + "\n"
message += fmt.Sprintf(
"### [%s](%s/applications/%s)\n",
resApp.Title,
"https://jomon.trap.jp",
resApp.ID)

Check warning on line 118 in service/webhook.go

Codecov / codecov/patch

service/webhook.go#L114-L118

Added lines #L114 - L118 were not covered by tests

amount := 0
for _, target := range resApp.Targets {
@@ -133,25 +144,45 @@ func WebhookEventHandler(c echo.Context, reqBody, resBody []byte) {
return
}
if c.Request().Method == http.MethodPost {
message += fmt.Sprintf("## :scroll:[入出金記録](%s/transactions/%s)が新規作成されました\n", "https://jomon.trap.jp", resApp.ID)
message += fmt.Sprintf(
"## :scroll:[入出金記録](%s/transactions/%s)が新規作成されました\n",
"https://jomon.trap.jp",
resApp.ID)

Check warning on line 150 in service/webhook.go

Codecov / codecov/patch

service/webhook.go#L147-L150

Added lines #L147 - L150 were not covered by tests
} else if c.Request().Method == http.MethodPut {
message += fmt.Sprintf("## :scroll:[入出金記録](%s/transactions/%s)が修正されました\n", "https://jomon.trap.jp", resApp.ID)
message += fmt.Sprintf(
"## :scroll:[入出金記録](%s/transactions/%s)が修正されました\n",
"https://jomon.trap.jp",
resApp.ID)

Check warning on line 155 in service/webhook.go

Codecov / codecov/patch

service/webhook.go#L152-L155

Added lines #L152 - L155 were not covered by tests
}
if len(resApps) == 1 {
if resApp.Amount < 0 {
message += fmt.Sprintf("- `%s`への支払い\n - 支払い金額: %d円\n", resApp.Target, -resApp.Amount)
message += fmt.Sprintf(
"- `%s`への支払い\n - 支払い金額: %d円\n",
resApp.Target,
-resApp.Amount)

Check warning on line 162 in service/webhook.go

Codecov / codecov/patch

service/webhook.go#L159-L162

Added lines #L159 - L162 were not covered by tests
} else {
message += fmt.Sprintf("- `%s`からの振込\n - 受け取り金額: %d円\n", resApp.Target, resApp.Amount)
message += fmt.Sprintf(
"- `%s`からの振込\n - 受け取り金額: %d円\n",
resApp.Target,
resApp.Amount)

Check warning on line 167 in service/webhook.go

Codecov / codecov/patch

service/webhook.go#L164-L167

Added lines #L164 - L167 were not covered by tests
}
} else {
targets := make([]string, len(resApps))
for i, resApp := range resApps {
targets[i] = resApp.Target
}
if resApp.Amount < 0 {
message += fmt.Sprintf("- %sへの支払い\n - 支払い金額: 計%d円(一人当たりへの支払い金額: %d円)\n", strings.Join(targets, " "), -len(resApps)*resApp.Amount, -resApp.Amount)
message += fmt.Sprintf(
"- %sへの支払い\n - 支払い金額: 計%d円(一人当たりへの支払い金額: %d円)\n",
strings.Join(targets, " "),
-len(resApps)*resApp.Amount,
-resApp.Amount)

Check warning on line 179 in service/webhook.go

Codecov / codecov/patch

service/webhook.go#L175-L179

Added lines #L175 - L179 were not covered by tests
} else {
message += fmt.Sprintf("- %sからの振込\n - 受け取り金額: 計%d円(一人当たりからの受け取り金額: %d円)\n", strings.Join(targets, " "), len(resApps)*resApp.Amount, resApp.Amount)
message += fmt.Sprintf(
"- %sからの振込\n - 受け取り金額: 計%d円(一人当たりからの受け取り金額: %d円)\n",
strings.Join(targets, " "),
len(resApps)*resApp.Amount,
resApp.Amount)

Check warning on line 185 in service/webhook.go

Codecov / codecov/patch

service/webhook.go#L181-L185

Added lines #L181 - L185 were not covered by tests
}
}
if resApp.Group != nil {
5 changes: 4 additions & 1 deletion storage/swift.go
Original file line number Diff line number Diff line change
@@ -12,7 +12,10 @@ type Swift struct {
conn *swift.Connection
}

func NewSwiftStorage(container string, userName string, apiKey string, tenant string, tenantID string, authURL string) (*Swift, error) {
func NewSwiftStorage(
container string, userName string, apiKey string,
tenant string, tenantID string, authURL string,
) (*Swift, error) {

Check warning on line 18 in storage/swift.go

Codecov / codecov/patch

storage/swift.go#L18

Added line #L18 was not covered by tests
conn := &swift.Connection{
AuthUrl: authURL,
UserName: userName,

0 comments on commit 8d2e8b2

Please sign in to comment.