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.
Test Setup Failed
Pull Request — master (#1)
by Victor Hugo
01:16
created

devto.NewClient   A

Complexity

Conditions 4

Size

Total Lines 18
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 12
dl 0
loc 18
rs 9.8
c 0
b 0
f 0
nop 3
1
package devto
2
3
import (
4
	"context"
5
	"errors"
6
	"net/http"
7
)
8
9
//Configuration constants
10
const (
11
	BaseURL      string = "https://dev.to/api"
12
	APIVersion   string = "0.5.1"
13
	APIKeyHeader string = "api-key"
14
)
15
16
//devto client errors
17
var (
18
	ErrMissingConfig = errors.New("missing configuration")
19
)
20
21
type httpClient interface {
22
	Do(req *http.Request) (res *http.Response, err error)
23
}
24
25
//Client is the main data structure for performing actions
26
//against dev.to API
27
type Client struct {
28
	Context    context.Context
29
	HTTPClient httpClient
30
	Config     *Config
31
}
32
33
//NewClient takes a context, a configuration pointer and optionally a
34
//base http client (bc) to build an Client instance.
35
func NewClient(ctx context.Context, conf *Config, bc httpClient) (dev *Client, err error) {
36
	if bc == nil {
37
		bc = http.DefaultClient
38
	}
39
40
	if ctx == nil {
41
		ctx = context.Background()
42
	}
43
44
	if conf == nil {
45
		return nil, ErrMissingConfig
46
	}
47
48
	return &Client{
49
		Context:    ctx,
50
		HTTPClient: bc,
51
		Config:     conf,
52
	}, nil
53
}
54