Skip to content

Commit 8c65a4b

Browse files
authored
Remove a number of unused functions and parameters (#1402)
My editor throws up warnings about a number of unused functions and variables. I don't think any of these _should_ be removed, so this change removes them. None of the API changes are to exported methods.
2 parents 2f0ba73 + 65e7367 commit 8c65a4b

File tree

5 files changed

+11
-34
lines changed

5 files changed

+11
-34
lines changed

chat.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func (api *Client) SendMessageContext(ctx context.Context, channelID string, opt
234234
api.Debugf("Sending request: %s", redactToken(reqBody))
235235
}
236236

237-
if err = doPost(ctx, api.httpclient, req, parser(&response), api); err != nil {
237+
if err = doPost(api.httpclient, req, parser(&response), api); err != nil {
238238
return "", "", "", err
239239
}
240240

function_execute_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,22 @@ func postHandler(t *testing.T) func(rw http.ResponseWriter, r *http.Request) {
2626

2727
switch req.FunctionExecutionID {
2828
case "function-success":
29-
postSuccess(rw, r)
29+
postSuccess(rw)
3030
case "function-failure":
31-
postFailure(rw, r)
31+
postFailure(rw)
3232
}
3333
}
3434
}
3535

36-
func postSuccess(rw http.ResponseWriter, r *http.Request) {
36+
func postSuccess(rw http.ResponseWriter) {
3737
rw.Header().Set("Content-Type", "application/json")
3838
response := []byte(`{
3939
"ok": true
4040
}`)
4141
rw.Write(response)
4242
}
4343

44-
func postFailure(rw http.ResponseWriter, r *http.Request) {
44+
func postFailure(rw http.ResponseWriter) {
4545
rw.Header().Set("Content-Type", "application/json")
4646
response := []byte(`{
4747
"ok": false,

interactions_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,6 @@ func TestInteractionCallback_Container_Marshal_And_Unmarshal(t *testing.T) {
494494
IsEphemeral: false,
495495
IsAppUnfurl: false,
496496
},
497-
RawState: json.RawMessage(`{}`),
498497
}
499498

500499
actual := new(InteractionCallback)
@@ -537,7 +536,6 @@ func TestInteractionCallback_In_Thread_Container_Marshal_And_Unmarshal(t *testin
537536
IsEphemeral: false,
538537
IsAppUnfurl: false,
539538
},
540-
RawState: json.RawMessage(`{}`),
541539
}
542540

543541
actual := new(InteractionCallback)

misc.go

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,6 @@ func jsonReq(ctx context.Context, endpoint string, body interface{}) (req *http.
124124
return req, nil
125125
}
126126

127-
func parseResponseBody(body io.ReadCloser, intf interface{}, d Debug) error {
128-
response, err := io.ReadAll(body)
129-
if err != nil {
130-
return err
131-
}
132-
133-
if d.Debug() {
134-
d.Debugln("parseResponseBody", string(response))
135-
}
136-
137-
return json.Unmarshal(response, intf)
138-
}
139-
140127
func postLocalWithMultipartResponse(ctx context.Context, client httpClient, method, fpath, fieldname, token string, values url.Values, intf interface{}, d Debug) error {
141128
fullpath, err := filepath.Abs(fpath)
142129
if err != nil {
@@ -220,7 +207,7 @@ func createFormFields(mw *multipart.Writer, values url.Values) error {
220207
return nil
221208
}
222209

223-
func doPost(ctx context.Context, client httpClient, req *http.Request, parser responseParser, d Debug) error {
210+
func doPost(client httpClient, req *http.Request, parser responseParser, d Debug) error {
224211
resp, err := client.Do(req)
225212
if err != nil {
226213
return err
@@ -245,7 +232,7 @@ func postJSON(ctx context.Context, client httpClient, endpoint, token string, js
245232
req.Header.Set("Content-Type", "application/json")
246233
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
247234

248-
return doPost(ctx, client, req, newJSONParser(intf), d)
235+
return doPost(client, req, newJSONParser(intf), d)
249236
}
250237

251238
// post a url encoded form.
@@ -256,7 +243,7 @@ func postForm(ctx context.Context, client httpClient, endpoint string, values ur
256243
return err
257244
}
258245
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
259-
return doPost(ctx, client, req, newJSONParser(intf), d)
246+
return doPost(client, req, newJSONParser(intf), d)
260247
}
261248

262249
func getResource(ctx context.Context, client httpClient, endpoint, token string, values url.Values, intf interface{}, d Debug) error {
@@ -269,7 +256,7 @@ func getResource(ctx context.Context, client httpClient, endpoint, token string,
269256

270257
req.URL.RawQuery = values.Encode()
271258

272-
return doPost(ctx, client, req, newJSONParser(intf), d)
259+
return doPost(client, req, newJSONParser(intf), d)
273260
}
274261

275262
func parseAdminResponse(ctx context.Context, client httpClient, method string, teamName string, values url.Values, intf interface{}, d Debug) error {
@@ -297,14 +284,6 @@ func okJSONHandler(rw http.ResponseWriter, r *http.Request) {
297284
rw.Write(response)
298285
}
299286

300-
// timerReset safely reset a timer, see time.Timer.Reset for details.
301-
func timerReset(t *time.Timer, d time.Duration) {
302-
if !t.Stop() {
303-
<-t.C
304-
}
305-
t.Reset(d)
306-
}
307-
308287
func checkStatusCode(resp *http.Response, d Debug) error {
309288
if resp.StatusCode == http.StatusTooManyRequests && resp.Header.Get("Retry-After") != "" {
310289
retry, err := strconv.ParseInt(resp.Header.Get("Retry-After"), 10, 64)

team.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func (api *Client) accessLogsRequest(ctx context.Context, path string, values ur
116116
return response, response.Err()
117117
}
118118

119-
func (api *Client) teamProfileRequest(ctx context.Context, client httpClient, path string, values url.Values) (*TeamProfileResponse, error) {
119+
func (api *Client) teamProfileRequest(ctx context.Context, path string, values url.Values) (*TeamProfileResponse, error) {
120120
response := &TeamProfileResponse{}
121121
err := api.postMethod(ctx, path, values, response)
122122
if err != nil {
@@ -184,7 +184,7 @@ func (api *Client) GetTeamProfileContext(ctx context.Context, teamID ...string)
184184
values["team_id"] = teamID
185185
}
186186

187-
response, err := api.teamProfileRequest(ctx, api.httpclient, "team.profile.get", values)
187+
response, err := api.teamProfileRequest(ctx, "team.profile.get", values)
188188
if err != nil {
189189
return nil, err
190190
}

0 commit comments

Comments
 (0)