Chore: Fix staticcheck issues (#28860)

* Chore: Fix issues reported by staticcheck

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Undo changes

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Chore: Fix issues reported by staticcheck

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Fix test

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Fix test

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
Arve Knudsen
2020-11-05 13:07:06 +01:00
committed by GitHub
parent 7897c6b7d5
commit 3d3a7cbba8
41 changed files with 125 additions and 124 deletions
+6 -6
View File
@@ -34,7 +34,7 @@ const (
)
var (
ErrCannotChangeStateOnPausedAlert = fmt.Errorf("Cannot change state on pause alert")
ErrCannotChangeStateOnPausedAlert = fmt.Errorf("cannot change state on pause alert")
ErrRequiresNewState = fmt.Errorf("update alert state requires a new state")
)
@@ -97,13 +97,13 @@ func (alert *Alert) ShouldUpdateState(newState AlertStateType) bool {
return alert.State != newState
}
func (this *Alert) ContainsUpdates(other *Alert) bool {
func (a *Alert) ContainsUpdates(other *Alert) bool {
result := false
result = result || this.Name != other.Name
result = result || this.Message != other.Message
result = result || a.Name != other.Name
result = result || a.Message != other.Message
if this.Settings != nil && other.Settings != nil {
json1, err1 := this.Settings.Encode()
if a.Settings != nil && other.Settings != nil {
json1, err1 := a.Settings.Encode()
json2, err2 := other.Settings.Encode()
if err1 != nil || err2 != nil {
+4 -4
View File
@@ -9,13 +9,13 @@ import (
)
var (
ErrAlertNotificationNotFound = errors.New("Alert notification not found")
ErrNotificationFrequencyNotFound = errors.New("Notification frequency not specified")
ErrAlertNotificationNotFound = errors.New("alert notification not found")
ErrNotificationFrequencyNotFound = errors.New("notification frequency not specified")
ErrAlertNotificationStateNotFound = errors.New("alert notification state not found")
ErrAlertNotificationStateVersionConflict = errors.New("alert notification state update version conflict")
ErrAlertNotificationStateAlreadyExist = errors.New("alert notification state already exists")
ErrAlertNotificationFailedGenerateUniqueUid = errors.New("Failed to generate unique alert notification uid")
ErrAlertNotificationFailedTranslateUniqueID = errors.New("Failed to translate Notification Id to Uid")
ErrAlertNotificationFailedGenerateUniqueUid = errors.New("failed to generate unique alert notification uid")
ErrAlertNotificationFailedTranslateUniqueID = errors.New("failed to translate Notification Id to Uid")
ErrAlertNotificationWithSameNameExists = errors.New("alert notification with same name already exists")
ErrAlertNotificationWithSameUIDExists = errors.New("alert notification with same uid already exists")
)
+3 -3
View File
@@ -5,9 +5,9 @@ import (
"time"
)
var ErrInvalidApiKey = errors.New("Invalid API Key")
var ErrInvalidApiKeyExpiration = errors.New("Negative value for SecondsToLive")
var ErrDuplicateApiKey = errors.New("API Key Organization ID And Name Must Be Unique")
var ErrInvalidApiKey = errors.New("invalid API key")
var ErrInvalidApiKeyExpiration = errors.New("negative value for SecondsToLive")
var ErrDuplicateApiKey = errors.New("API key, organization ID and name must be unique")
type ApiKey struct {
Id int64
+2 -2
View File
@@ -8,8 +8,8 @@ import (
)
var (
ErrDashboardVersionNotFound = errors.New("Dashboard version not found")
ErrNoVersionsForDashboardId = errors.New("No dashboard versions found for the given DashboardId")
ErrDashboardVersionNotFound = errors.New("dashboard version not found")
ErrNoVersionsForDashboardId = errors.New("no dashboard versions found for the given DashboardId")
)
// A DashboardVersion represents the comparable data in a dashboard, allowing
+7 -7
View File
@@ -30,13 +30,13 @@ const (
)
var (
ErrDataSourceNotFound = errors.New("Data source not found")
ErrDataSourceNameExists = errors.New("Data source with the same name already exists")
ErrDataSourceUidExists = errors.New("Data source with the same uid already exists")
ErrDataSourceUpdatingOldVersion = errors.New("Trying to update old version of datasource")
ErrDatasourceIsReadOnly = errors.New("Data source is readonly. Can only be updated from configuration")
ErrDataSourceAccessDenied = errors.New("Data source access denied")
ErrDataSourceFailedGenerateUniqueUid = errors.New("Failed to generate unique datasource id")
ErrDataSourceNotFound = errors.New("data source not found")
ErrDataSourceNameExists = errors.New("data source with the same name already exists")
ErrDataSourceUidExists = errors.New("data source with the same uid already exists")
ErrDataSourceUpdatingOldVersion = errors.New("trying to update old version of datasource")
ErrDatasourceIsReadOnly = errors.New("data source is readonly, can only be updated from configuration")
ErrDataSourceAccessDenied = errors.New("data source access denied")
ErrDataSourceFailedGenerateUniqueUid = errors.New("failed to generate unique datasource ID")
)
type DsAccess string
+1 -1
View File
@@ -224,7 +224,7 @@ func (ds *DataSource) GetTLSConfig() (*tls.Config, error) {
caPool := x509.NewCertPool()
ok := caPool.AppendCertsFromPEM([]byte(decrypted["tlsCACert"]))
if !ok {
return nil, errors.New("Failed to parse TLS CA PEM certificate")
return nil, errors.New("failed to parse TLS CA PEM certificate")
}
tlsConfig.RootCAs = caPool
}
+7 -7
View File
@@ -8,13 +8,13 @@ import (
// Typed errors
var (
ErrFolderNotFound = errors.New("Folder not found")
ErrFolderVersionMismatch = errors.New("The folder has been changed by someone else")
ErrFolderTitleEmpty = errors.New("Folder title cannot be empty")
ErrFolderWithSameUIDExists = errors.New("A folder/dashboard with the same uid already exists")
ErrFolderSameNameExists = errors.New("A folder or dashboard in the general folder with the same name already exists")
ErrFolderFailedGenerateUniqueUid = errors.New("Failed to generate unique folder id")
ErrFolderAccessDenied = errors.New("Access denied to folder")
ErrFolderNotFound = errors.New("folder not found")
ErrFolderVersionMismatch = errors.New("the folder has been changed by someone else")
ErrFolderTitleEmpty = errors.New("folder title cannot be empty")
ErrFolderWithSameUIDExists = errors.New("a folder/dashboard with the same uid already exists")
ErrFolderSameNameExists = errors.New("a folder or dashboard in the general folder with the same name already exists")
ErrFolderFailedGenerateUniqueUid = errors.New("failed to generate unique folder ID")
ErrFolderAccessDenied = errors.New("access denied to folder")
)
type Folder struct {
+1 -1
View File
@@ -2,7 +2,7 @@ package models
import "errors"
var ErrInvalidEmailCode = errors.New("Invalid or expired email code")
var ErrInvalidEmailCode = errors.New("invalid or expired email code")
var ErrSmtpNotEnabled = errors.New("SMTP not configured, check your grafana.ini config file's [smtp] section")
// SendEmailAttachFile is a definition of the attached files without path
+2 -2
View File
@@ -7,8 +7,8 @@ import (
// Typed errors
var (
ErrOrgNotFound = errors.New("Organization not found")
ErrOrgNameTaken = errors.New("Organization name is taken")
ErrOrgNotFound = errors.New("organization not found")
ErrOrgNameTaken = errors.New("organization name is taken")
)
type Org struct {
+4 -4
View File
@@ -9,10 +9,10 @@ import (
// Typed errors
var (
ErrInvalidRoleType = errors.New("Invalid role type")
ErrLastOrgAdmin = errors.New("Cannot remove last organization admin")
ErrOrgUserNotFound = errors.New("Cannot find the organization user")
ErrOrgUserAlreadyAdded = errors.New("User is already added to organization")
ErrInvalidRoleType = errors.New("invalid role type")
ErrLastOrgAdmin = errors.New("cannot remove last organization admin")
ErrOrgUserNotFound = errors.New("cannot find the organization user")
ErrOrgUserAlreadyAdded = errors.New("user is already added to organization")
)
type RoleType string
+3 -3
View File
@@ -6,8 +6,8 @@ import (
// Typed errors
var (
ErrPlaylistNotFound = errors.New("Playlist not found")
ErrPlaylistWithSameNameExists = errors.New("A playlist with the same name already exists")
ErrPlaylistNotFound = errors.New("playlist not found")
ErrPlaylistWithSameNameExists = errors.New("a playlist with the same name already exists")
)
// Playlist model
@@ -50,7 +50,7 @@ type PlaylistItem struct {
Title string
}
func (this PlaylistDashboard) TableName() string {
func (p PlaylistDashboard) TableName() string {
return "dashboard"
}
+1 -1
View File
@@ -8,7 +8,7 @@ import (
)
var (
ErrPluginSettingNotFound = errors.New("Plugin setting not found")
ErrPluginSettingNotFound = errors.New("plugin setting not found")
)
type PluginSetting struct {
+1 -1
View File
@@ -7,7 +7,7 @@ import (
"github.com/grafana/grafana/pkg/setting"
)
var ErrInvalidQuotaTarget = errors.New("Invalid quota target")
var ErrInvalidQuotaTarget = errors.New("invalid quota target")
type Quota struct {
Id int64
+1 -1
View File
@@ -2,7 +2,7 @@ package models
import "errors"
var ErrCommandValidationFailed = errors.New("Command missing required fields")
var ErrCommandValidationFailed = errors.New("command missing required fields")
type Star struct {
Id int64
+6 -6
View File
@@ -7,12 +7,12 @@ import (
// Typed errors
var (
ErrTeamNotFound = errors.New("Team not found")
ErrTeamNameTaken = errors.New("Team name is taken")
ErrTeamMemberNotFound = errors.New("Team member not found")
ErrLastTeamAdmin = errors.New("Not allowed to remove last admin")
ErrNotAllowedToUpdateTeam = errors.New("User not allowed to update team")
ErrNotAllowedToUpdateTeamInDifferentOrg = errors.New("User not allowed to update team in another org")
ErrTeamNotFound = errors.New("team not found")
ErrTeamNameTaken = errors.New("team name is taken")
ErrTeamMemberNotFound = errors.New("team member not found")
ErrLastTeamAdmin = errors.New("not allowed to remove last admin")
ErrNotAllowedToUpdateTeam = errors.New("user not allowed to update team")
ErrNotAllowedToUpdateTeamInDifferentOrg = errors.New("user not allowed to update team in another org")
)
// Team model
+3 -3
View File
@@ -7,9 +7,9 @@ import (
// Typed errors
var (
ErrUserNotFound = errors.New("User not found")
ErrUserAlreadyExists = errors.New("User already exists")
ErrLastGrafanaAdmin = errors.New("Cannot remove last grafana admin")
ErrUserNotFound = errors.New("user not found")
ErrUserAlreadyExists = errors.New("user already exists")
ErrLastGrafanaAdmin = errors.New("cannot remove last grafana admin")
)
type Password string