summaryrefslogtreecommitdiffstats
path: root/modules/setting
diff options
context:
space:
mode:
authorWim <wim@42.be>2022-06-20 12:02:49 +0200
committerGitHub <noreply@github.com>2022-06-20 12:02:49 +0200
commitcb50375e2b6abf0c79d4891e5e1ea775b9759cd2 (patch)
tree938af0f442baf79cebd114692aff5ad6af37f987 /modules/setting
parent3289abcefc563d6ea16c1dbd19680b874a58a6d3 (diff)
downloadgitea-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 'modules/setting')
-rw-r--r--modules/setting/database.go4
-rw-r--r--modules/setting/federation.go2
-rw-r--r--modules/setting/i18n.go4
-rw-r--r--modules/setting/log.go2
-rw-r--r--modules/setting/service.go2
5 files changed, 7 insertions, 7 deletions
diff --git a/modules/setting/database.go b/modules/setting/database.go
index a90ace5b4b..87d56fbc93 100644
--- a/modules/setting/database.go
+++ b/modules/setting/database.go
@@ -107,7 +107,7 @@ func InitDBConfig() {
// DBConnStr returns database connection string
func DBConnStr() (string, error) {
- connStr := ""
+ var connStr string
Param := "?"
if strings.Contains(Database.Name, Param) {
Param = "&"
@@ -168,7 +168,7 @@ func getPostgreSQLConnectionString(dbHost, dbUser, dbPasswd, dbName, dbParam, db
connStr = fmt.Sprintf("postgres://%s:%s@%s:%s/%s%ssslmode=%s",
url.PathEscape(dbUser), url.PathEscape(dbPasswd), host, port, dbName, dbParam, dbsslMode)
}
- return
+ return connStr
}
// ParseMSSQLHostPort splits the host into host and port
diff --git a/modules/setting/federation.go b/modules/setting/federation.go
index 2a8ecadaf9..583d9a6e2b 100644
--- a/modules/setting/federation.go
+++ b/modules/setting/federation.go
@@ -31,7 +31,7 @@ var (
}
)
-// Constant slice of httpsig algorithm objects
+// HttpsigAlgs is a constant slice of httpsig algorithm objects
var HttpsigAlgs []httpsig.Algorithm
func newFederationService() {
diff --git a/modules/setting/i18n.go b/modules/setting/i18n.go
index a9a57dc948..321e144ef3 100644
--- a/modules/setting/i18n.go
+++ b/modules/setting/i18n.go
@@ -40,12 +40,12 @@ func defaultI18nLangs() (res []string) {
for i := 0; i < len(defaultI18nLangNames); i += 2 {
res = append(res, defaultI18nLangNames[i])
}
- return
+ return res
}
func defaultI18nNames() (res []string) {
for i := 0; i < len(defaultI18nLangNames); i += 2 {
res = append(res, defaultI18nLangNames[i+1])
}
- return
+ return res
}
diff --git a/modules/setting/log.go b/modules/setting/log.go
index d69b5c6888..1d9535360a 100644
--- a/modules/setting/log.go
+++ b/modules/setting/log.go
@@ -211,7 +211,7 @@ func generateLogConfig(sec *ini.Section, name string, defaults defaultLogOptions
return
}
jsonConfig = string(byteConfig)
- return
+ return mode, jsonConfig, levelName
}
func generateNamedLogger(key string, options defaultLogOptions) *LogDescription {
diff --git a/modules/setting/service.go b/modules/setting/service.go
index a391926382..bd97e10b0f 100644
--- a/modules/setting/service.go
+++ b/modules/setting/service.go
@@ -96,7 +96,7 @@ func (a AllowedVisibility) ToVisibleTypeSlice() (result []structs.VisibleType) {
result = append(result, structs.VisibleType(i))
}
}
- return
+ return result
}
func newService() {