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