Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gosimple linter #348

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ linters:
- errcheck # Mandatory. Do not disable.
- ineffassign # Mandatory. Do not disable.
- staticcheck # Mandatory. Do not disable.
- gosimple
- gosec
- bodyclose # https://github.com/timakin/bodyclose
- gomodguard
Expand Down
12 changes: 4 additions & 8 deletions bounces.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,8 @@ func (ci *BouncesIterator) Next(ctx context.Context, items *[]Bounce) bool {
cpy := make([]Bounce, len(ci.Items))
copy(cpy, ci.Items)
*items = cpy
if len(ci.Items) == 0 {
return false
}
return true

return len(ci.Items) != 0
}

// First retrieves the first page of items from the api. Returns false if there
Expand Down Expand Up @@ -134,10 +132,8 @@ func (ci *BouncesIterator) Previous(ctx context.Context, items *[]Bounce) bool {
cpy := make([]Bounce, len(ci.Items))
copy(cpy, ci.Items)
*items = cpy
if len(ci.Items) == 0 {
return false
}
return true

return len(ci.Items) != 0
}

func (ci *BouncesIterator) fetch(ctx context.Context, url string) error {
Expand Down
6 changes: 2 additions & 4 deletions credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,8 @@ func (ri *CredentialsIterator) Previous(ctx context.Context, items *[]Credential
cpy := make([]Credential, len(ri.Items))
copy(cpy, ri.Items)
*items = cpy
if len(ri.Items) == 0 {
return false
}
return true

return len(ri.Items) != 0
}

func (ri *CredentialsIterator) fetch(ctx context.Context, skip, limit int) error {
Expand Down
6 changes: 2 additions & 4 deletions domains.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,8 @@ func (ri *DomainsIterator) Previous(ctx context.Context, items *[]Domain) bool {
cpy := make([]Domain, len(ri.Items))
copy(cpy, ri.Items)
*items = cpy
if len(ri.Items) == 0 {
return false
}
return true

return len(ri.Items) != 0
}

func (ri *DomainsIterator) fetch(ctx context.Context, skip, limit int) error {
Expand Down
8 changes: 3 additions & 5 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,8 @@ func (ei *EventIterator) Previous(ctx context.Context, events *[]Event) bool {
return false
}
*events, ei.err = ParseEvents(ei.Items)
if len(ei.Items) == 0 {
return false
}
return true

return len(ei.Items) != 0
}

func (ei *EventIterator) fetch(ctx context.Context, url string) error {
Expand Down Expand Up @@ -248,7 +246,7 @@ func (ep *EventPoller) Poll(ctx context.Context, events *[]Event) bool {

// Attempt to get a page of events
var page []Event
if ep.it.Next(ctx, &page) == false {
if !ep.it.Next(ctx, &page) {
if ep.it.Err() == nil && len(page) == 0 {
// No events, sleep for our poll interval
goto SLEEP
Expand Down
2 changes: 1 addition & 1 deletion httphelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ func (r *httpRequest) generateUrlWithParameters() (string, error) {
}

q := uri.Query()
if r.Parameters != nil && len(r.Parameters) > 0 {
if len(r.Parameters) > 0 {
for name, values := range r.Parameters {
for _, value := range values {
q.Add(name, value)
Expand Down
12 changes: 4 additions & 8 deletions mailing_lists.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,8 @@ func (li *ListsIterator) Next(ctx context.Context, items *[]MailingList) bool {
cpy := make([]MailingList, len(li.Items))
copy(cpy, li.Items)
*items = cpy
if len(li.Items) == 0 {
return false
}
return true

return len(li.Items) != 0
}

// First retrieves the first page of items from the api. Returns false if there
Expand Down Expand Up @@ -156,10 +154,8 @@ func (li *ListsIterator) Previous(ctx context.Context, items *[]MailingList) boo
cpy := make([]MailingList, len(li.Items))
copy(cpy, li.Items)
*items = cpy
if len(li.Items) == 0 {
return false
}
return true

return len(li.Items) != 0
}

func (li *ListsIterator) fetch(ctx context.Context, url string) error {
Expand Down
12 changes: 4 additions & 8 deletions members.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,8 @@ func (li *MemberListIterator) Next(ctx context.Context, items *[]Member) bool {
return false
}
*items = li.Lists
if len(li.Lists) == 0 {
return false
}
return true

return len(li.Lists) != 0
}

// First retrieves the first page of items from the api. Returns false if there
Expand Down Expand Up @@ -141,10 +139,8 @@ func (li *MemberListIterator) Previous(ctx context.Context, items *[]Member) boo
return false
}
*items = li.Lists
if len(li.Lists) == 0 {
return false
}
return true

return len(li.Lists) != 0
}

func (li *MemberListIterator) fetch(ctx context.Context, url string) error {
Expand Down
8 changes: 3 additions & 5 deletions routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type ForwardedMessage struct {
// }
// forwardRoute := mailgun.ExtractForwardedMessage(r.PostForm)
// fmt.Printf("Forwarded message: %#v", forwardRoute)
//}
// }
func ExtractForwardedMessage(formValues url.Values) ForwardedMessage {
forwardedMessage := ForwardedMessage{}
forwardedMessage.BodyPlain = formValues.Get("body-plain")
Expand Down Expand Up @@ -236,10 +236,8 @@ func (ri *RoutesIterator) Previous(ctx context.Context, items *[]Route) bool {
cpy := make([]Route, len(ri.Items))
copy(cpy, ri.Items)
*items = cpy
if len(ri.Items) == 0 {
return false
}
return true

return len(ri.Items) != 0
}

func (ri *RoutesIterator) fetch(ctx context.Context, skip, limit int) error {
Expand Down
12 changes: 4 additions & 8 deletions spam_complaints.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ func (ci *ComplaintsIterator) Next(ctx context.Context, items *[]Complaint) bool
cpy := make([]Complaint, len(ci.Items))
copy(cpy, ci.Items)
*items = cpy
if len(ci.Items) == 0 {
return false
}
return true

return len(ci.Items) != 0
}

// First retrieves the first page of items from the api. Returns false if there
Expand Down Expand Up @@ -125,10 +123,8 @@ func (ci *ComplaintsIterator) Previous(ctx context.Context, items *[]Complaint)
cpy := make([]Complaint, len(ci.Items))
copy(cpy, ci.Items)
*items = cpy
if len(ci.Items) == 0 {
return false
}
return true

return len(ci.Items) != 0
}

func (ci *ComplaintsIterator) fetch(ctx context.Context, url string) error {
Expand Down
6 changes: 2 additions & 4 deletions subaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,8 @@ func (ri *SubaccountsIterator) Previous(ctx context.Context, items *[]Subaccount
cpy := make([]Subaccount, len(ri.Items))
copy(cpy, ri.Items)
*items = cpy
if len(ri.Items) == 0 {
return false
}
return true

return len(ri.Items) != 0
}

func (ri *SubaccountsIterator) fetch(ctx context.Context, skip, limit int) error {
Expand Down
12 changes: 4 additions & 8 deletions tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,8 @@ func (ti *TagIterator) Next(ctx context.Context, items *[]Tag) bool {
return false
}
*items = ti.Items
if len(ti.Items) == 0 {
return false
}
return true

return len(ti.Items) != 0
}

// Previous returns the previous page in the list of tags
Expand All @@ -120,10 +118,8 @@ func (ti *TagIterator) Previous(ctx context.Context, items *[]Tag) bool {
return false
}
*items = ti.Items
if len(ti.Items) == 0 {
return false
}
return true

return len(ti.Items) != 0
}

// First returns the first page in the list of tags
Expand Down
12 changes: 4 additions & 8 deletions template.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,8 @@ func (ti *TemplatesIterator) Next(ctx context.Context, items *[]Template) bool {
cpy := make([]Template, len(ti.Items))
copy(cpy, ti.Items)
*items = cpy
if len(ti.Items) == 0 {
return false
}
return true

return len(ti.Items) != 0
}

// First retrieves the first page of items from the api. Returns false if there
Expand Down Expand Up @@ -227,10 +225,8 @@ func (ti *TemplatesIterator) Previous(ctx context.Context, items *[]Template) bo
cpy := make([]Template, len(ti.Items))
copy(cpy, ti.Items)
*items = cpy
if len(ti.Items) == 0 {
return false
}
return true

return len(ti.Items) != 0
}

func (ti *TemplatesIterator) fetch(ctx context.Context, url string) error {
Expand Down
12 changes: 4 additions & 8 deletions template_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,8 @@ func (li *TemplateVersionsIterator) Next(ctx context.Context, items *[]TemplateV
cpy := make([]TemplateVersion, len(li.Template.Versions))
copy(cpy, li.Template.Versions)
*items = cpy
if len(li.Template.Versions) == 0 {
return false
}
return true

return len(li.Template.Versions) != 0
}

// First retrieves the first page of items from the api. Returns false if there
Expand Down Expand Up @@ -202,10 +200,8 @@ func (li *TemplateVersionsIterator) Previous(ctx context.Context, items *[]Templ
cpy := make([]TemplateVersion, len(li.Template.Versions))
copy(cpy, li.Template.Versions)
*items = cpy
if len(li.Template.Versions) == 0 {
return false
}
return true

return len(li.Template.Versions) != 0
}

func (li *TemplateVersionsIterator) fetch(ctx context.Context, url string) error {
Expand Down
12 changes: 4 additions & 8 deletions unsubscribes.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@ func (ci *UnsubscribesIterator) Next(ctx context.Context, items *[]Unsubscribe)
cpy := make([]Unsubscribe, len(ci.Items))
copy(cpy, ci.Items)
*items = cpy
if len(ci.Items) == 0 {
return false
}
return true

return len(ci.Items) != 0
}

// First retrieves the first page of items from the api. Returns false if there
Expand Down Expand Up @@ -118,10 +116,8 @@ func (ci *UnsubscribesIterator) Previous(ctx context.Context, items *[]Unsubscri
cpy := make([]Unsubscribe, len(ci.Items))
copy(cpy, ci.Items)
*items = cpy
if len(ci.Items) == 0 {
return false
}
return true

return len(ci.Items) != 0
}

func (ci *UnsubscribesIterator) fetch(ctx context.Context, url string) error {
Expand Down