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.
Passed
Push — master ( b5116a...3bd38f )
by
unknown
05:35
created

providers.doAction   D

Complexity

Conditions 13

Size

Total Lines 56
Code Lines 44

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 13
eloc 44
nop 2
dl 0
loc 56
rs 4.2
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

Complexity

Complex classes like providers.doAction often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

1
package providers
2
3
import (
4
	"bytes"
5
	"io/ioutil"
6
	"net/http"
7
	"strconv"
8
)
9
10
func mockResponse(statusCode int, content string) (res *http.Response) {
11
	status := strconv.Itoa(statusCode)
12
	res = &http.Response{
13
		Proto:      "HTTP/1.1",
14
		ProtoMajor: 1,
15
		Header:     map[string][]string{"sdk": {"test"}},
16
		StatusCode: statusCode,
17
		Status:     status + " " + http.StatusText(statusCode),
18
	}
19
	res.Body = ioutil.NopCloser(bytes.NewReader([]byte(content)))
20
	return
21
}
22