Add more linters to improve code readability (#19989)

Add nakedret, unconvert, wastedassign, stylecheck and nolintlint linters to improve code readability

- nakedret - https://github.com/alexkohler/nakedret - nakedret is a Go static analysis tool to find naked returns in functions greater than a specified function length.
- unconvert - https://github.com/mdempsky/unconvert - Remove unnecessary type conversions
- wastedassign - https://github.com/sanposhiho/wastedassign -  wastedassign finds wasted assignment statements.
- notlintlint -  Reports ill-formed or insufficient nolint directives
- stylecheck - https://staticcheck.io/docs/checks/#ST - keep style consistent
  - excluded: [ST1003 - Poorly chosen identifier](https://staticcheck.io/docs/checks/#ST1003) and [ST1005 - Incorrectly formatted error string](https://staticcheck.io/docs/checks/#ST1005)
This commit is contained in:
Wim 2022-06-20 12:02:49 +02:00 committed by GitHub
parent 3289abcefc
commit cb50375e2b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
147 changed files with 402 additions and 397 deletions

View file

@ -14,32 +14,32 @@ import (
)
// LoadProject load the project the issue was assigned to
func (i *Issue) LoadProject() (err error) {
return i.loadProject(db.DefaultContext)
func (issue *Issue) LoadProject() (err error) {
return issue.loadProject(db.DefaultContext)
}
func (i *Issue) loadProject(ctx context.Context) (err error) {
if i.Project == nil {
func (issue *Issue) loadProject(ctx context.Context) (err error) {
if issue.Project == nil {
var p project_model.Project
if _, err = db.GetEngine(ctx).Table("project").
Join("INNER", "project_issue", "project.id=project_issue.project_id").
Where("project_issue.issue_id = ?", i.ID).
Where("project_issue.issue_id = ?", issue.ID).
Get(&p); err != nil {
return err
}
i.Project = &p
issue.Project = &p
}
return
return err
}
// ProjectID return project id if issue was assigned to one
func (i *Issue) ProjectID() int64 {
return i.projectID(db.DefaultContext)
func (issue *Issue) ProjectID() int64 {
return issue.projectID(db.DefaultContext)
}
func (i *Issue) projectID(ctx context.Context) int64 {
func (issue *Issue) projectID(ctx context.Context) int64 {
var ip project_model.ProjectIssue
has, err := db.GetEngine(ctx).Where("issue_id=?", i.ID).Get(&ip)
has, err := db.GetEngine(ctx).Where("issue_id=?", issue.ID).Get(&ip)
if err != nil || !has {
return 0
}
@ -47,13 +47,13 @@ func (i *Issue) projectID(ctx context.Context) int64 {
}
// ProjectBoardID return project board id if issue was assigned to one
func (i *Issue) ProjectBoardID() int64 {
return i.projectBoardID(db.DefaultContext)
func (issue *Issue) ProjectBoardID() int64 {
return issue.projectBoardID(db.DefaultContext)
}
func (i *Issue) projectBoardID(ctx context.Context) int64 {
func (issue *Issue) projectBoardID(ctx context.Context) int64 {
var ip project_model.ProjectIssue
has, err := db.GetEngine(ctx).Where("issue_id=?", i.ID).Get(&ip)
has, err := db.GetEngine(ctx).Where("issue_id=?", issue.ID).Get(&ip)
if err != nil || !has {
return 0
}