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
Pull Request — master (#2)
by Victor Hugo
01:42
created

devto.*WebURL.UnmarshalJSON   A

Complexity

Conditions 2

Size

Total Lines 9
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 8
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
ccs 7
cts 7
cp 1
crap 2
1
package devto
2
3
import (
4
	"net/url"
5
	"strings"
6
	"time"
7
)
8
9
//User contains information about a devto account
10
type User struct {
11
	Name            string  `json:"name,omitempty"`
12
	Username        string  `json:"username,omitempty"`
13
	TwitterUsername string  `json:"twitter_username,omitempty"`
14
	GithubUsername  string  `json:"github_username,omitempty"`
15
	WebsiteURL      *WebURL `json:"website_url,omitempty"`
16
	ProfileImage    *WebURL `json:"profile_image,omitempty"`
17
	ProfileImage90  *WebURL `json:"profile_image_90,omitempty"`
18
}
19
20
//Organization describes a company or group that
21
//publishes content to devto.
22
type Organization struct {
23
	Name           string  `json:"name,omitempty"`
24
	Username       string  `json:"username,omitempty"`
25
	Slug           string  `json:"slug,omitempty"`
26
	ProfileImage   *WebURL `json:"profile_image,omitempty"`
27
	ProfileImage90 *WebURL `json:"profile_image_90,omitempty"`
28
}
29
30
//Tags are a group of topics related to an article
31
type Tags []string
32
33
//Article contains all the information related to a single
34
//information resource from devto.
35
type Article struct {
36
	TypeOf                 string       `json:"type_of,omitempty"`
37
	ID                     uint32       `json:"id,omitempty"`
38
	Title                  string       `json:"title,omitempty"`
39
	Description            string       `json:"description,omitempty"`
40
	CoverImage             *WebURL      `json:"cover_image,omitempty"`
41
	SocialImage            *WebURL      `json:"social_image,omitempty"`
42
	PublishedAt            *time.Time   `json:"published_at,omitempty"`
43
	EditedAt               *time.Time   `json:"edited_at,omitempty"`
44
	CrossPostedAt          *time.Time   `json:"crossposted_at,omitempty"`
45
	LastCommentAt          *time.Time   `json:"last_comment_at,omitempty"`
46
	TagList                Tags         `json:"tag_list,omitempty"`
47
	Tags                   string       `json:"tags,omitempty"`
48
	Slug                   string       `json:"slug,omitempty"`
49
	Path                   *WebURL      `json:"path,omitempty"`
50
	URL                    *WebURL      `json:"url,omitempty"`
51
	CanonicalURL           *WebURL      `json:"canonical_url,omitempty"`
52
	CommentsCount          uint         `json:"comments_count,omitempty"`
53
	PositiveReactionsCount uint         `json:"positive_reactions_count,omitempty"`
54
	PublishedTimestamp     *time.Time   `json:"published_timestamp,omitempty"`
55
	User                   User         `json:"user,omitempty"`
56
	Organization           Organization `json:"organization,omitempty"`
57
	BodyHTML               string       `json:"body_html,omitempty"`
58
	BodyMarkdown           string       `json:"body_markdown,omitempty"`
59
	Published              bool         `json:"published,omitempty"`
60
}
61
62
//ArticleListOptions holds the query values to pass as
63
//query string parameter to the Articles List action.
64
type ArticleListOptions struct {
65
	Tags     string `url:"tag,omitempty"`
66
	Username string `url:"username,omitempty"`
67
	State    string `url:"state,omitempty"`
68
	Top      string `url:"top,omitempty"`
69
	Page     int    `url:"page,omitempty"`
70
}
71
72
type WebURL struct {
73
	*url.URL
74
}
75
76
//UnmarshalJSON overrides the default unmarshal behaviour
77
//for URL
78
func (s *WebURL) UnmarshalJSON(b []byte) error {
79 1
	c := string(b)
80 1
	c = strings.Trim(c, "\"")
81 1
	uri, err := url.Parse(c)
82 1
	if err != nil {
83 1
		return err
84
	}
85 1
	s.URL = uri
86 1
	return nil
87
}
88