1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Obey the linter; make the linter happy

Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
Chris Cummer 2020-10-07 16:06:57 -07:00
parent 3c63eee8d3
commit 450483791f
3 changed files with 31 additions and 31 deletions

View File

@ -56,7 +56,7 @@ func (widget *Widget) content() (string, string, bool) {
return title, str, false return title, str, false
} }
func (widget *Widget) displayMyPullRequests(repo *GithubRepo, username string) string { func (widget *Widget) displayMyPullRequests(repo *Repo, username string) string {
prs := repo.myPullRequests(username, widget.settings.enableStatus) prs := repo.myPullRequests(username, widget.settings.enableStatus)
prLength := len(prs) prLength := len(prs)
@ -79,7 +79,7 @@ func (widget *Widget) displayMyPullRequests(repo *GithubRepo, username string) s
return str return str
} }
func (widget *Widget) displayCustomQuery(repo *GithubRepo, filter string, perPage int) string { func (widget *Widget) displayCustomQuery(repo *Repo, filter string, perPage int) string {
res := repo.customIssueQuery(filter, perPage) res := repo.customIssueQuery(filter, perPage)
if res == nil { if res == nil {
@ -106,7 +106,7 @@ func (widget *Widget) displayCustomQuery(repo *GithubRepo, filter string, perPag
return str return str
} }
func (widget *Widget) displayMyReviewRequests(repo *GithubRepo, username string) string { func (widget *Widget) displayMyReviewRequests(repo *Repo, username string) string {
prs := repo.myReviewRequests(username) prs := repo.myReviewRequests(username)
if len(prs) == 0 { if len(prs) == 0 {
@ -123,7 +123,7 @@ func (widget *Widget) displayMyReviewRequests(repo *GithubRepo, username string)
return str return str
} }
func (widget *Widget) displayStats(repo *GithubRepo) string { func (widget *Widget) displayStats(repo *Repo) string {
prntr := message.NewPrinter(language.English) prntr := message.NewPrinter(language.English)
str := fmt.Sprintf( str := fmt.Sprintf(
@ -136,7 +136,7 @@ func (widget *Widget) displayStats(repo *GithubRepo) string {
return str return str
} }
func (widget *Widget) title(repo *GithubRepo) string { func (widget *Widget) title(repo *Repo) string {
return fmt.Sprintf( return fmt.Sprintf(
"[%s]%s - %s[white]", "[%s]%s - %s[white]",
widget.settings.common.Colors.TextTheme.Title, widget.settings.common.Colors.TextTheme.Title,

View File

@ -15,8 +15,8 @@ const (
issuesPath = "/issues" issuesPath = "/issues"
) )
// GithubRepo defines a new GithubRepo structure // Repo defines a new GitHub Repo structure
type GithubRepo struct { type Repo struct {
apiKey string apiKey string
baseURL string baseURL string
uploadURL string uploadURL string
@ -29,8 +29,8 @@ type GithubRepo struct {
} }
// NewGithubRepo returns a new Github Repo with a name, owner, apiKey, baseURL and uploadURL // NewGithubRepo returns a new Github Repo with a name, owner, apiKey, baseURL and uploadURL
func NewGithubRepo(name, owner, apiKey, baseURL, uploadURL string) *GithubRepo { func NewGithubRepo(name, owner, apiKey, baseURL, uploadURL string) *Repo {
repo := GithubRepo{ repo := Repo{
Name: name, Name: name,
Owner: owner, Owner: owner,
@ -43,22 +43,22 @@ func NewGithubRepo(name, owner, apiKey, baseURL, uploadURL string) *GithubRepo {
} }
// Open will open the GitHub Repo URL using the utils helper // Open will open the GitHub Repo URL using the utils helper
func (repo *GithubRepo) Open() { func (repo *Repo) Open() {
utils.OpenFile(*repo.RemoteRepo.HTMLURL) utils.OpenFile(*repo.RemoteRepo.HTMLURL)
} }
// Open will open the GitHub Pull Requests URL using the utils helper // OpenPulls will open the GitHub Pull Requests URL using the utils helper
func (repo *GithubRepo) OpenPulls() { func (repo *Repo) OpenPulls() {
utils.OpenFile(*repo.RemoteRepo.HTMLURL + pullRequestsPath) utils.OpenFile(*repo.RemoteRepo.HTMLURL + pullRequestsPath)
} }
// Open will open the GitHub Issues URL using the utils helper // OpenIssues will open the GitHub Issues URL using the utils helper
func (repo *GithubRepo) OpenIssues() { func (repo *Repo) OpenIssues() {
utils.OpenFile(*repo.RemoteRepo.HTMLURL + issuesPath) utils.OpenFile(*repo.RemoteRepo.HTMLURL + issuesPath)
} }
// Refresh reloads the github data via the Github API // Refresh reloads the github data via the Github API
func (repo *GithubRepo) Refresh() { func (repo *Repo) Refresh() {
prs, err := repo.loadPullRequests() prs, err := repo.loadPullRequests()
repo.Err = err repo.Err = err
repo.PullRequests = prs repo.PullRequests = prs
@ -73,7 +73,7 @@ func (repo *GithubRepo) Refresh() {
/* -------------------- Counts -------------------- */ /* -------------------- Counts -------------------- */
// IssueCount return the total amount of issues as an int // IssueCount return the total amount of issues as an int
func (repo *GithubRepo) IssueCount() int { func (repo *Repo) IssueCount() int {
if repo.RemoteRepo == nil { if repo.RemoteRepo == nil {
return 0 return 0
} }
@ -84,12 +84,12 @@ func (repo *GithubRepo) IssueCount() int {
} }
// PullRequestCount returns the total amount of pull requests as an int // PullRequestCount returns the total amount of pull requests as an int
func (repo *GithubRepo) PullRequestCount() int { func (repo *Repo) PullRequestCount() int {
return len(repo.PullRequests) return len(repo.PullRequests)
} }
// StarCount returns the total amount of stars this repo has gained as an int // StarCount returns the total amount of stars this repo has gained as an int
func (repo *GithubRepo) StarCount() int { func (repo *Repo) StarCount() int {
if repo.RemoteRepo == nil { if repo.RemoteRepo == nil {
return 0 return 0
} }
@ -99,7 +99,7 @@ func (repo *GithubRepo) StarCount() int {
/* -------------------- Unexported Functions -------------------- */ /* -------------------- Unexported Functions -------------------- */
func (repo *GithubRepo) isGitHubEnterprise() bool { func (repo *Repo) isGitHubEnterprise() bool {
if len(repo.baseURL) > 0 { if len(repo.baseURL) > 0 {
if len(repo.uploadURL) == 0 { if len(repo.uploadURL) == 0 {
repo.uploadURL = repo.baseURL repo.uploadURL = repo.baseURL
@ -109,7 +109,7 @@ func (repo *GithubRepo) isGitHubEnterprise() bool {
return false return false
} }
func (repo *GithubRepo) oauthClient() *http.Client { func (repo *Repo) oauthClient() *http.Client {
tokenService := oauth2.StaticTokenSource( tokenService := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: repo.apiKey}, &oauth2.Token{AccessToken: repo.apiKey},
) )
@ -117,7 +117,7 @@ func (repo *GithubRepo) oauthClient() *http.Client {
return oauth2.NewClient(context.Background(), tokenService) return oauth2.NewClient(context.Background(), tokenService)
} }
func (repo *GithubRepo) githubClient() (*ghb.Client, error) { func (repo *Repo) githubClient() (*ghb.Client, error) {
oauthClient := repo.oauthClient() oauthClient := repo.oauthClient()
if repo.isGitHubEnterprise() { if repo.isGitHubEnterprise() {
@ -128,7 +128,7 @@ func (repo *GithubRepo) githubClient() (*ghb.Client, error) {
} }
// myPullRequests returns a list of pull requests created by username on this repo // myPullRequests returns a list of pull requests created by username on this repo
func (repo *GithubRepo) myPullRequests(username string, showStatus bool) []*ghb.PullRequest { func (repo *Repo) myPullRequests(username string, showStatus bool) []*ghb.PullRequest {
prs := []*ghb.PullRequest{} prs := []*ghb.PullRequest{}
for _, pr := range repo.PullRequests { for _, pr := range repo.PullRequests {
@ -149,7 +149,7 @@ func (repo *GithubRepo) myPullRequests(username string, showStatus bool) []*ghb.
// individualPRs takes a list of pull requests (presumably returned from // individualPRs takes a list of pull requests (presumably returned from
// github.PullRequests.List) and fetches them individually to get more detailed // github.PullRequests.List) and fetches them individually to get more detailed
// status info on each. see: https://developer.github.com/v3/git/#checking-mergeability-of-pull-requests // status info on each. see: https://developer.github.com/v3/git/#checking-mergeability-of-pull-requests
func (repo *GithubRepo) individualPRs(prs []*ghb.PullRequest) []*ghb.PullRequest { func (repo *Repo) individualPRs(prs []*ghb.PullRequest) []*ghb.PullRequest {
github, err := repo.githubClient() github, err := repo.githubClient()
if err != nil { if err != nil {
return prs return prs
@ -170,7 +170,7 @@ func (repo *GithubRepo) individualPRs(prs []*ghb.PullRequest) []*ghb.PullRequest
// myReviewRequests returns a list of pull requests for which username has been // myReviewRequests returns a list of pull requests for which username has been
// requested to do a code review // requested to do a code review
func (repo *GithubRepo) myReviewRequests(username string) []*ghb.PullRequest { func (repo *Repo) myReviewRequests(username string) []*ghb.PullRequest {
prs := []*ghb.PullRequest{} prs := []*ghb.PullRequest{}
for _, pr := range repo.PullRequests { for _, pr := range repo.PullRequests {
@ -184,7 +184,7 @@ func (repo *GithubRepo) myReviewRequests(username string) []*ghb.PullRequest {
return prs return prs
} }
func (repo *GithubRepo) customIssueQuery(filter string, perPage int) *ghb.IssuesSearchResult { func (repo *Repo) customIssueQuery(filter string, perPage int) *ghb.IssuesSearchResult {
github, err := repo.githubClient() github, err := repo.githubClient()
if err != nil { if err != nil {
return nil return nil
@ -199,7 +199,7 @@ func (repo *GithubRepo) customIssueQuery(filter string, perPage int) *ghb.Issues
return prs return prs
} }
func (repo *GithubRepo) loadPullRequests() ([]*ghb.PullRequest, error) { func (repo *Repo) loadPullRequests() ([]*ghb.PullRequest, error) {
github, err := repo.githubClient() github, err := repo.githubClient()
if err != nil { if err != nil {
return nil, err return nil, err
@ -217,7 +217,7 @@ func (repo *GithubRepo) loadPullRequests() ([]*ghb.PullRequest, error) {
return prs, nil return prs, nil
} }
func (repo *GithubRepo) loadRemoteRepository() (*ghb.Repository, error) { func (repo *Repo) loadRemoteRepository() (*ghb.Repository, error) {
github, err := repo.githubClient() github, err := repo.githubClient()
if err != nil { if err != nil {

View File

@ -15,7 +15,7 @@ type Widget struct {
view.KeyboardWidget view.KeyboardWidget
view.TextWidget view.TextWidget
GithubRepos []*GithubRepo GithubRepos []*Repo
settings *Settings settings *Settings
Selected int Selected int
@ -110,8 +110,8 @@ func (widget *Widget) HelpText() string {
/* -------------------- Unexported Functions -------------------- */ /* -------------------- Unexported Functions -------------------- */
func (widget *Widget) buildRepoCollection(repoData []string) []*GithubRepo { func (widget *Widget) buildRepoCollection(repoData []string) []*Repo {
githubRepos := []*GithubRepo{} githubRepos := []*Repo{}
for _, repo := range repoData { for _, repo := range repoData {
split := strings.Split(repo, "/") split := strings.Split(repo, "/")
@ -130,7 +130,7 @@ func (widget *Widget) buildRepoCollection(repoData []string) []*GithubRepo {
return githubRepos return githubRepos
} }
func (widget *Widget) currentGithubRepo() *GithubRepo { func (widget *Widget) currentGithubRepo() *Repo {
if len(widget.GithubRepos) == 0 { if len(widget.GithubRepos) == 0 {
return nil return nil
} }