GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#5)
by
unknown
02:01
created

devto.decodeResponse   A

Complexity

Conditions 2

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 6
nop 1
dl 0
loc 7
ccs 0
cts 5
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
package devto
2
3
import (
4
	"encoding/json"
5
	"fmt"
6
	"io/ioutil"
7
	"net/http"
8
)
9
10 1
func non2xx(res *http.Response) bool { return res.StatusCode/100 != 2 }
11
12
// attempt to deserialize the error response; if it succeeds,
13
// the error will be an ErrorResponse, otherwise it will be
14
// an error indicating that the error response could not be
15
// deserialized.
16
func unmarshalErrorResponse(res *http.Response) error {
17 1
	var e ErrorResponse
18 1
	if err := json.NewDecoder(res.Body).Decode(&e); err != nil {
19
		return fmt.Errorf(
20
			`unexpected error deserializing %d response: "%v"`,
21
			res.StatusCode,
22
			err,
23
		)
24
	}
25 1
	return &e
26
}
27
28
func decodeResponse(r *http.Response) []byte {
29
	c, err := ioutil.ReadAll(r.Body)
30
	if err != nil {
31
		return []byte("")
32
	}
33
	defer r.Body.Close()
34
	return c
35
}
36