diff options
author | Wim <wim@42.be> | 2022-06-20 12:02:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-20 12:02:49 +0200 |
commit | cb50375e2b6abf0c79d4891e5e1ea775b9759cd2 (patch) | |
tree | 938af0f442baf79cebd114692aff5ad6af37f987 /models/repo | |
parent | 3289abcefc563d6ea16c1dbd19680b874a58a6d3 (diff) | |
download | gitea-cb50375e2b6abf0c79d4891e5e1ea775b9759cd2.tar.gz gitea-cb50375e2b6abf0c79d4891e5e1ea775b9759cd2.zip |
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)
Diffstat (limited to 'models/repo')
-rw-r--r-- | models/repo/archiver.go | 2 | ||||
-rw-r--r-- | models/repo/repo.go | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/models/repo/archiver.go b/models/repo/archiver.go index dc64cce49b..fd07d8554d 100644 --- a/models/repo/archiver.go +++ b/models/repo/archiver.go @@ -112,5 +112,5 @@ func FindRepoArchives(opts FindRepoArchiversOption) ([]*RepoArchiver, error) { func SetArchiveRepoState(repo *Repository, isArchived bool) (err error) { repo.IsArchived = isArchived _, err = db.GetEngine(db.DefaultContext).Where("id = ?", repo.ID).Cols("is_archived").NoAutoTime().Update(repo) - return + return err } diff --git a/models/repo/repo.go b/models/repo/repo.go index f6097d2d6a..8ef405a665 100644 --- a/models/repo/repo.go +++ b/models/repo/repo.go @@ -280,7 +280,7 @@ func (repo *Repository) CommitLink(commitID string) (result string) { } else { result = repo.HTMLURL() + "/commit/" + url.PathEscape(commitID) } - return + return result } // APIURL returns the repository API URL @@ -325,7 +325,7 @@ func (repo *Repository) UnitEnabled(tp unit.Type) (result bool) { }); err != nil { log.Error("repo.UnitEnabled: %v", err) } - return + return result } // UnitEnabled if this repository has the given unit enabled @@ -546,7 +546,7 @@ func (repo *Repository) DescriptionHTML(ctx context.Context) template.HTML { log.Error("Failed to render description for %s (ID: %d): %v", repo.Name, repo.ID, err) return template.HTML(markup.Sanitize(repo.Description)) } - return template.HTML(markup.Sanitize(string(desc))) + return template.HTML(markup.Sanitize(desc)) } // CloneLink represents different types of clone URLs of repository. |