mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Enable exhaustive linter (#29458)
* Chore: Enable exhaustive linter Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
parent
cbb2c0a5d8
commit
f55818ca70
@ -109,6 +109,7 @@ func (hs *HTTPServer) Run(ctx context.Context) error {
|
|||||||
if err := hs.configureHttps(); err != nil {
|
if err := hs.configureHttps(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
listener, err := hs.getListener()
|
listener, err := hs.getListener()
|
||||||
|
@ -107,6 +107,9 @@ func perFloat(val Value, floatF func(x float64) float64) (Value, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
newVal = newSeries
|
newVal = newSeries
|
||||||
|
default:
|
||||||
|
// TODO: Should we deal with TypeString, TypeVariantSet?
|
||||||
}
|
}
|
||||||
|
|
||||||
return newVal, nil
|
return newVal, nil
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,8 @@ func SeriesFromFrame(frame *data.Frame) (s Series, err error) {
|
|||||||
s.ValueIsNullabe = true
|
s.ValueIsNullabe = true
|
||||||
foundValue = true
|
foundValue = true
|
||||||
s.ValueIdx = i
|
s.ValueIdx = i
|
||||||
|
default:
|
||||||
|
// Handle default case
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !foundTime {
|
if !foundTime {
|
||||||
|
@ -97,10 +97,8 @@ func (m *SigV4Middleware) signer() (*v4.Signer, error) {
|
|||||||
c = credentials.NewStaticCredentials(m.Config.AccessKey, m.Config.SecretKey, "")
|
c = credentials.NewStaticCredentials(m.Config.AccessKey, m.Config.SecretKey, "")
|
||||||
case Credentials:
|
case Credentials:
|
||||||
c = credentials.NewSharedCredentials("", m.Config.Profile)
|
c = credentials.NewSharedCredentials("", m.Config.Profile)
|
||||||
}
|
case Default:
|
||||||
|
// passing nil credentials will force AWS to allow a more complete credential chain vs the explicit default
|
||||||
// passing nil credentials will force AWS to allow a more complete credential chain vs the explicit default
|
|
||||||
if c == nil {
|
|
||||||
s, err := session.NewSession(&aws.Config{
|
s, err := session.NewSession(&aws.Config{
|
||||||
Region: aws.String(m.Config.Region),
|
Region: aws.String(m.Config.Region),
|
||||||
})
|
})
|
||||||
|
@ -51,6 +51,8 @@ func (lw logWrapper) Log(level hclog.Level, msg string, args ...interface{}) {
|
|||||||
lw.Warn(msg, args...)
|
lw.Warn(msg, args...)
|
||||||
case hclog.Error:
|
case hclog.Error:
|
||||||
lw.Error(msg, args...)
|
lw.Error(msg, args...)
|
||||||
|
default:
|
||||||
|
// TODO: Handle hclog.NoLevel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,6 +138,8 @@ func (hc *HipChatNotifier) Notify(evalContext *alerting.EvalContext) error {
|
|||||||
color = "gray"
|
color = "gray"
|
||||||
case models.AlertStateAlerting:
|
case models.AlertStateAlerting:
|
||||||
color = "red"
|
color = "red"
|
||||||
|
default:
|
||||||
|
// Handle other cases?
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a card with link to the dashboard
|
// Add a card with link to the dashboard
|
||||||
|
@ -99,6 +99,8 @@ func (on *OpsGenieNotifier) Notify(evalContext *alerting.EvalContext) error {
|
|||||||
}
|
}
|
||||||
case models.AlertStateAlerting:
|
case models.AlertStateAlerting:
|
||||||
err = on.createAlert(evalContext)
|
err = on.createAlert(evalContext)
|
||||||
|
default:
|
||||||
|
// Handle other cases?
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -127,6 +127,8 @@ func (notifier *ThreemaNotifier) Notify(evalContext *alerting.EvalContext) error
|
|||||||
stateEmoji = "\u2753\uFE0F " // Question Mark
|
stateEmoji = "\u2753\uFE0F " // Question Mark
|
||||||
case models.AlertStateAlerting:
|
case models.AlertStateAlerting:
|
||||||
stateEmoji = "\u26A0\uFE0F " // Warning sign
|
stateEmoji = "\u26A0\uFE0F " // Warning sign
|
||||||
|
default:
|
||||||
|
// Handle other cases?
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build message
|
// Build message
|
||||||
|
@ -444,6 +444,8 @@ func (sc *scenarioContext) verifyUpdateDashboardPermissionsShouldNotBeAllowed(pt
|
|||||||
newDefaultUserPermission(dashboardID, p),
|
newDefaultUserPermission(dashboardID, p),
|
||||||
newCustomTeamPermission(dashboardID, otherTeamID, p),
|
newCustomTeamPermission(dashboardID, otherTeamID, p),
|
||||||
}...)
|
}...)
|
||||||
|
default:
|
||||||
|
// TODO: Handle other cases?
|
||||||
}
|
}
|
||||||
|
|
||||||
sc.updatePermissions = permissionList
|
sc.updatePermissions = permissionList
|
||||||
|
@ -286,5 +286,7 @@ func handleLog(msg centrifuge.LogEntry) {
|
|||||||
loggerCF.Error(msg.Message, arr...)
|
loggerCF.Error(msg.Message, arr...)
|
||||||
case centrifuge.LogLevelInfo:
|
case centrifuge.LogLevelInfo:
|
||||||
loggerCF.Info(msg.Message, arr...)
|
loggerCF.Info(msg.Message, arr...)
|
||||||
|
case centrifuge.LogLevelNone:
|
||||||
|
loggerCF.Debug(msg.Message, arr...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,6 @@ func (ls *LoginService) UpsertUser(cmd *models.UpsertUserCommand) error {
|
|||||||
Email: extUser.Email,
|
Email: extUser.Email,
|
||||||
Login: extUser.Login,
|
Login: extUser.Login,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := bus.Dispatch(userQuery); err != nil {
|
if err := bus.Dispatch(userQuery); err != nil {
|
||||||
if !errors.Is(err, models.ErrUserNotFound) {
|
if !errors.Is(err, models.ErrUserNotFound) {
|
||||||
return err
|
return err
|
||||||
|
@ -232,6 +232,8 @@ func (rs *RenderingService) getURL(path string) string {
|
|||||||
protocol = "http"
|
protocol = "http"
|
||||||
case setting.HTTP2Scheme, setting.HTTPSScheme:
|
case setting.HTTP2Scheme, setting.HTTPSScheme:
|
||||||
protocol = "https"
|
protocol = "https"
|
||||||
|
default:
|
||||||
|
// TODO: Handle other schemes?
|
||||||
}
|
}
|
||||||
|
|
||||||
subPath := ""
|
subPath := ""
|
||||||
|
@ -232,7 +232,6 @@ func verifyExistingOrg(sess *DBSession, orgId int64) error {
|
|||||||
|
|
||||||
func getOrCreateOrg(sess *DBSession, orgName string) (int64, error) {
|
func getOrCreateOrg(sess *DBSession, orgName string) (int64, error) {
|
||||||
var org models.Org
|
var org models.Org
|
||||||
|
|
||||||
if setting.AutoAssignOrg {
|
if setting.AutoAssignOrg {
|
||||||
has, err := sess.Where("id=?", setting.AutoAssignOrgId).Get(&org)
|
has, err := sess.Where("id=?", setting.AutoAssignOrgId).Get(&org)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -241,15 +240,16 @@ func getOrCreateOrg(sess *DBSession, orgName string) (int64, error) {
|
|||||||
if has {
|
if has {
|
||||||
return org.Id, nil
|
return org.Id, nil
|
||||||
}
|
}
|
||||||
if setting.AutoAssignOrgId == 1 {
|
|
||||||
org.Name = mainOrgName
|
if setting.AutoAssignOrgId != 1 {
|
||||||
org.Id = int64(setting.AutoAssignOrgId)
|
|
||||||
} else {
|
|
||||||
sqlog.Error("Could not create user: organization ID does not exist", "orgID",
|
sqlog.Error("Could not create user: organization ID does not exist", "orgID",
|
||||||
setting.AutoAssignOrgId)
|
setting.AutoAssignOrgId)
|
||||||
return 0, fmt.Errorf("could not create user: organization ID %d does not exist",
|
return 0, fmt.Errorf("could not create user: organization ID %d does not exist",
|
||||||
setting.AutoAssignOrgId)
|
setting.AutoAssignOrgId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
org.Name = mainOrgName
|
||||||
|
org.Id = int64(setting.AutoAssignOrgId)
|
||||||
} else {
|
} else {
|
||||||
org.Name = orgName
|
org.Name = orgName
|
||||||
}
|
}
|
||||||
|
@ -291,7 +291,7 @@ func formatDate(t time.Time, pattern string) string {
|
|||||||
if day == time.Sunday {
|
if day == time.Sunday {
|
||||||
dayOfWeekIso = 7
|
dayOfWeekIso = 7
|
||||||
}
|
}
|
||||||
quarter := 4
|
var quarter int
|
||||||
switch t.Month() {
|
switch t.Month() {
|
||||||
case time.January, time.February, time.March:
|
case time.January, time.February, time.March:
|
||||||
quarter = 1
|
quarter = 1
|
||||||
@ -299,6 +299,8 @@ func formatDate(t time.Time, pattern string) string {
|
|||||||
quarter = 2
|
quarter = 2
|
||||||
case time.July, time.August, time.September:
|
case time.July, time.August, time.September:
|
||||||
quarter = 3
|
quarter = 3
|
||||||
|
default:
|
||||||
|
quarter = 4
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, formatted := range formattedDatePatterns {
|
for i, formatted := range formattedDatePatterns {
|
||||||
|
@ -42,11 +42,9 @@ func (m *postgresMacroEngine) Interpolate(query *tsdb.Query, timeRange *tsdb.Tim
|
|||||||
if groups[1] == "__timeGroup" {
|
if groups[1] == "__timeGroup" {
|
||||||
if index := strings.Index(sql, groups[0]); index >= 0 {
|
if index := strings.Index(sql, groups[0]); index >= 0 {
|
||||||
index += len(groups[0])
|
index += len(groups[0])
|
||||||
if len(sql) > index {
|
// check for character after macro expression
|
||||||
// check for character after macro expression
|
if len(sql) > index && sql[index] == ',' {
|
||||||
if sql[index] == ',' {
|
groups[1] = "__timeGroupAlias"
|
||||||
groups[1] = "__timeGroupAlias"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,9 @@ min-confidence = 3
|
|||||||
min-len = 5
|
min-len = 5
|
||||||
min-occurrences = 5
|
min-occurrences = 5
|
||||||
|
|
||||||
|
[linters-settings.exhaustive]
|
||||||
|
default-signifies-exhaustive = true
|
||||||
|
|
||||||
[linters]
|
[linters]
|
||||||
disable-all = true
|
disable-all = true
|
||||||
enable = [
|
enable = [
|
||||||
@ -39,6 +42,7 @@ enable = [
|
|||||||
"varcheck",
|
"varcheck",
|
||||||
"whitespace",
|
"whitespace",
|
||||||
"gocyclo",
|
"gocyclo",
|
||||||
|
"exhaustive",
|
||||||
"typecheck",
|
"typecheck",
|
||||||
"asciicheck",
|
"asciicheck",
|
||||||
"errorlint",
|
"errorlint",
|
||||||
|
Loading…
Reference in New Issue
Block a user