Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
d1e6214a
Unverified
Commit
d1e6214a
authored
Jun 29, 2020
by
Arve Knudsen
Committed by
GitHub
Jun 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Chore: Enable scopelint Go linter (#25896)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
parent
a5fb6bdd
Hide whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
45 additions
and
4 deletions
+45
-4
.circleci/config.yml
+1
-1
pkg/api/dashboard_test.go
+2
-0
pkg/api/folder_test.go
+2
-0
pkg/api/login_test.go
+2
-0
pkg/api/pluginproxy/access_token_provider_test.go
+1
-0
pkg/api/pluginproxy/ds_proxy_test.go
+1
-0
pkg/cmd/grafana-cli/commands/upgrade_all_command_test.go
+4
-2
pkg/cmd/grafana-server/diagnostics_test.go
+2
-0
pkg/components/gtime/gtime_test.go
+1
-0
pkg/login/social/azuread_oauth_test.go
+1
-0
pkg/login/social/generic_oauth_test.go
+3
-0
pkg/plugins/backendplugin/grpcplugin/log_wrapper_test.go
+1
-0
pkg/plugins/plugins_test.go
+1
-0
pkg/services/alerting/alerting_usage_test.go
+1
-0
pkg/services/guardian/guardian_test.go
+6
-0
pkg/services/notifications/mailer.go
+1
-0
pkg/services/sqlstore/migrations/migrations_test.go
+1
-0
pkg/services/sqlstore/migrator/migrator.go
+1
-0
pkg/services/sqlstore/sqlstore_test.go
+1
-0
pkg/tsdb/azuremonitor/applicationinsights-datasource_test.go
+1
-0
pkg/tsdb/azuremonitor/azure-log-analytics-datasource_test.go
+2
-0
pkg/tsdb/azuremonitor/azure-log-analytics-table-frame_test.go
+1
-0
pkg/tsdb/azuremonitor/azuremonitor-datasource_test.go
+3
-0
pkg/tsdb/azuremonitor/macros_test.go
+1
-0
pkg/tsdb/elasticsearch/time_series_query.go
+1
-0
pkg/tsdb/frame_util_test.go
+1
-0
pkg/tsdb/influxdb/flux/macros_test.go
+1
-0
scripts/go/configs/.golangci.toml
+1
-1
No files found.
.circleci/config.yml
View file @
d1e6214a
...
...
@@ -826,7 +826,7 @@ jobs:
command
:
|
# To save memory, run in two batches
golangci-lint run -v -j 4 --config scripts/go/configs/ci/.golangci.toml -E deadcode -E depguard -E dogsled \
-E errcheck -E goconst -E golint -E gosec -E gosimple -E govet ./pkg/...
-E errcheck -E goconst -E golint -E gosec -E gosimple -E govet
-E scopelint
./pkg/...
golangci-lint run -v -j 4 --config scripts/go/configs/ci/.golangci.toml -E ineffassign \
-E rowserrcheck -E staticcheck -E structcheck -E typecheck -E unconvert -E unused -E varcheck ./pkg/...
./scripts/go/bin/revive -formatter stylish -config ./scripts/go/configs/revive.toml ./pkg/...
...
...
pkg/api/dashboard_test.go
View file @
d1e6214a
...
...
@@ -42,6 +42,7 @@ func TestGetHomeDashboard(t *testing.T) {
}
for
_
,
tc
:=
range
tests
{
tc
:=
tc
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
dash
:=
dtos
.
DashboardFullWithMeta
{}
dash
.
Meta
.
IsHome
=
true
...
...
@@ -801,6 +802,7 @@ func TestDashboardApiEndpoint(t *testing.T) {
}
for
_
,
tc
:=
range
testCases
{
tc
:=
tc
mock
:=
&
dashboards
.
FakeDashboardService
{
SaveDashboardError
:
tc
.
SaveError
,
}
...
...
pkg/api/folder_test.go
View file @
d1e6214a
...
...
@@ -62,6 +62,7 @@ func TestFoldersApiEndpoint(t *testing.T) {
}
for
_
,
tc
:=
range
testCases
{
tc
:=
tc
mock
:=
&
fakeFolderService
{
CreateFolderError
:
tc
.
Error
,
}
...
...
@@ -119,6 +120,7 @@ func TestFoldersApiEndpoint(t *testing.T) {
}
for
_
,
tc
:=
range
testCases
{
tc
:=
tc
mock
:=
&
fakeFolderService
{
UpdateFolderError
:
tc
.
Error
,
}
...
...
pkg/api/login_test.go
View file @
d1e6214a
...
...
@@ -252,6 +252,7 @@ func TestLoginViewRedirect(t *testing.T) {
}
for
_
,
c
:=
range
redirectCases
{
c
:=
c
hs
.
Cfg
.
AppUrl
=
c
.
appURL
hs
.
Cfg
.
AppSubUrl
=
c
.
appSubURL
t
.
Run
(
c
.
desc
,
func
(
t
*
testing
.
T
)
{
...
...
@@ -420,6 +421,7 @@ func TestLoginPostRedirect(t *testing.T) {
}
for
_
,
c
:=
range
redirectCases
{
c
:=
c
hs
.
Cfg
.
AppUrl
=
c
.
appURL
hs
.
Cfg
.
AppSubUrl
=
c
.
appSubURL
t
.
Run
(
c
.
desc
,
func
(
t
*
testing
.
T
)
{
...
...
pkg/api/pluginproxy/access_token_provider_test.go
View file @
d1e6214a
...
...
@@ -189,6 +189,7 @@ func TestAccessToken(t *testing.T) {
},
}
for
_
,
testCase
:=
range
testCases
{
testCase
:=
testCase
Convey
(
testCase
.
desc
,
func
()
{
clearTokenCache
()
// reset the httphandler counter
...
...
pkg/api/pluginproxy/ds_proxy_test.go
View file @
d1e6214a
...
...
@@ -617,6 +617,7 @@ func TestNewDataSourceProxy_MSSQL(t *testing.T) {
},
}
for
_
,
tc
:=
range
tcs
{
tc
:=
tc
t
.
Run
(
tc
.
description
,
func
(
t
*
testing
.
T
)
{
cfg
:=
setting
.
Cfg
{}
plugin
:=
plugins
.
DataSourcePlugin
{}
...
...
pkg/cmd/grafana-cli/commands/upgrade_all_command_test.go
View file @
d1e6214a
...
...
@@ -21,9 +21,10 @@ func TestVersionComparison(t *testing.T) {
}
for
k
,
v
:=
range
upgradeablePlugins
{
key
:=
k
val
:=
v
t
.
Run
(
fmt
.
Sprintf
(
"for %s should be true"
,
k
),
func
(
t
*
testing
.
T
)
{
assert
.
True
(
t
,
shouldUpgrade
(
k
,
&
val
))
assert
.
True
(
t
,
shouldUpgrade
(
k
ey
,
&
val
))
})
}
})
...
...
@@ -40,9 +41,10 @@ func TestVersionComparison(t *testing.T) {
}
for
k
,
v
:=
range
shouldNotUpgrade
{
key
:=
k
val
:=
v
t
.
Run
(
fmt
.
Sprintf
(
"for %s should be false"
,
k
),
func
(
t
*
testing
.
T
)
{
assert
.
False
(
t
,
shouldUpgrade
(
k
,
&
val
))
assert
.
False
(
t
,
shouldUpgrade
(
k
ey
,
&
val
))
})
}
})
...
...
pkg/cmd/grafana-server/diagnostics_test.go
View file @
d1e6214a
...
...
@@ -23,6 +23,7 @@ func TestProfilingDiagnostics(t *testing.T) {
}
for
i
,
tc
:=
range
tcs
{
tc
:=
tc
t
.
Run
(
fmt
.
Sprintf
(
"testcase %d"
,
i
),
func
(
t
*
testing
.
T
)
{
os
.
Clearenv
()
if
tc
.
enabledEnv
!=
""
{
...
...
@@ -55,6 +56,7 @@ func TestTracingDiagnostics(t *testing.T) {
}
for
i
,
tc
:=
range
tcs
{
tc
:=
tc
t
.
Run
(
fmt
.
Sprintf
(
"testcase %d"
,
i
),
func
(
t
*
testing
.
T
)
{
os
.
Clearenv
()
if
tc
.
enabledEnv
!=
""
{
...
...
pkg/components/gtime/gtime_test.go
View file @
d1e6214a
...
...
@@ -26,6 +26,7 @@ func TestParseInterval(t *testing.T) {
}
for
i
,
tc
:=
range
tcs
{
tc
:=
tc
t
.
Run
(
fmt
.
Sprintf
(
"testcase %d"
,
i
),
func
(
t
*
testing
.
T
)
{
res
,
err
:=
ParseInterval
(
tc
.
interval
)
if
tc
.
err
==
""
{
...
...
pkg/login/social/azuread_oauth_test.go
View file @
d1e6214a
...
...
@@ -221,6 +221,7 @@ func TestSocialAzureAD_UserInfo(t *testing.T) {
},
}
for
_
,
tt
:=
range
tests
{
tt
:=
tt
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
s
:=
&
SocialAzureAD
{
SocialBase
:
tt
.
fields
.
SocialBase
,
...
...
pkg/login/social/generic_oauth_test.go
View file @
d1e6214a
...
...
@@ -89,6 +89,7 @@ func TestSearchJSONForEmail(t *testing.T) {
}
for
_
,
test
:=
range
tests
{
test
:=
test
provider
.
emailAttributePath
=
test
.
EmailAttributePath
t
.
Run
(
test
.
Name
,
func
(
t
*
testing
.
T
)
{
actualResult
,
err
:=
provider
.
searchJSONForAttr
(
test
.
EmailAttributePath
,
test
.
UserInfoJSONResponse
)
...
...
@@ -152,6 +153,7 @@ func TestSearchJSONForRole(t *testing.T) {
}
for
_
,
test
:=
range
tests
{
test
:=
test
provider
.
roleAttributePath
=
test
.
RoleAttributePath
t
.
Run
(
test
.
Name
,
func
(
t
*
testing
.
T
)
{
actualResult
,
err
:=
provider
.
searchJSONForAttr
(
test
.
RoleAttributePath
,
test
.
UserInfoJSONResponse
)
...
...
@@ -304,6 +306,7 @@ func TestUserInfoSearchesForEmailAndRole(t *testing.T) {
}
for
_
,
test
:=
range
tests
{
test
:=
test
provider
.
roleAttributePath
=
test
.
RoleAttributePath
t
.
Run
(
test
.
Name
,
func
(
t
*
testing
.
T
)
{
response
,
err
:=
json
.
Marshal
(
test
.
APIURLResponse
)
...
...
pkg/plugins/backendplugin/grpcplugin/log_wrapper_test.go
View file @
d1e6214a
...
...
@@ -21,6 +21,7 @@ func TestLogWrapper(t *testing.T) {
}
for
i
,
tc
:=
range
tcs
{
tc
:=
tc
t
.
Run
(
fmt
.
Sprintf
(
"formatArgs testcase %d"
,
i
),
func
(
t
*
testing
.
T
)
{
res
:=
formatArgs
(
tc
.
args
...
)
assert
.
Exactly
(
t
,
tc
.
expectedResult
,
res
)
...
...
pkg/plugins/plugins_test.go
View file @
d1e6214a
...
...
@@ -177,6 +177,7 @@ func TestPluginManager_IsBackendOnlyPlugin(t *testing.T) {
{
name
:
"renderer"
,
isBackendOnly
:
true
},
{
name
:
"app"
,
isBackendOnly
:
false
},
}
{
c
:=
c
t
.
Run
(
fmt
.
Sprintf
(
"Plugin %s"
,
c
.
name
),
func
(
t
*
testing
.
T
)
{
result
:=
pluginScanner
.
IsBackendOnlyPlugin
(
c
.
name
)
...
...
pkg/services/alerting/alerting_usage_test.go
View file @
d1e6214a
...
...
@@ -107,6 +107,7 @@ func TestParsingAlertRuleSettings(t *testing.T) {
require
.
NoError
(
t
,
err
,
"Init should not return an error"
)
for
_
,
tc
:=
range
tcs
{
tc
:=
tc
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
content
,
err
:=
ioutil
.
ReadFile
(
tc
.
file
)
require
.
NoError
(
t
,
err
,
"expected to be able to read file"
)
...
...
pkg/services/guardian/guardian_test.go
View file @
d1e6214a
...
...
@@ -372,6 +372,7 @@ func (sc *scenarioContext) verifyUpdateDashboardPermissionsShouldBeAllowed(pt pe
}
for
_
,
p
:=
range
[]
models
.
PermissionType
{
models
.
PERMISSION_ADMIN
,
models
.
PERMISSION_EDIT
,
models
.
PERMISSION_VIEW
}
{
p
:=
p
tc
:=
fmt
.
Sprintf
(
"When updating dashboard permissions with %s permissions should be allowed"
,
p
.
String
())
Convey
(
tc
,
func
()
{
...
...
@@ -420,6 +421,7 @@ func (sc *scenarioContext) verifyUpdateDashboardPermissionsShouldNotBeAllowed(pt
}
for
_
,
p
:=
range
[]
models
.
PermissionType
{
models
.
PERMISSION_ADMIN
,
models
.
PERMISSION_EDIT
,
models
.
PERMISSION_VIEW
}
{
p
:=
p
tc
:=
fmt
.
Sprintf
(
"When updating dashboard permissions with %s permissions should NOT be allowed"
,
p
.
String
())
Convey
(
tc
,
func
()
{
...
...
@@ -460,6 +462,7 @@ func (sc *scenarioContext) verifyUpdateChildDashboardPermissionsShouldBeAllowed(
}
for
_
,
p
:=
range
[]
models
.
PermissionType
{
models
.
PERMISSION_ADMIN
,
models
.
PERMISSION_EDIT
,
models
.
PERMISSION_VIEW
}
{
p
:=
p
tc
:=
fmt
.
Sprintf
(
"When updating child dashboard permissions with %s permissions should be allowed"
,
p
.
String
())
Convey
(
tc
,
func
()
{
...
...
@@ -523,6 +526,7 @@ func (sc *scenarioContext) verifyUpdateChildDashboardPermissionsShouldNotBeAllow
}
for
_
,
p
:=
range
[]
models
.
PermissionType
{
models
.
PERMISSION_ADMIN
,
models
.
PERMISSION_EDIT
,
models
.
PERMISSION_VIEW
}
{
p
:=
p
tc
:=
fmt
.
Sprintf
(
"When updating child dashboard permissions with %s permissions should NOT be allowed"
,
p
.
String
())
Convey
(
tc
,
func
()
{
...
...
@@ -586,6 +590,7 @@ func (sc *scenarioContext) verifyUpdateChildDashboardPermissionsWithOverrideShou
}
for
_
,
p
:=
range
[]
models
.
PermissionType
{
models
.
PERMISSION_ADMIN
,
models
.
PERMISSION_EDIT
,
models
.
PERMISSION_VIEW
}
{
p
:=
p
// permission to update is higher than parent folder permission
if
p
>
parentFolderPermission
{
continue
...
...
@@ -631,6 +636,7 @@ func (sc *scenarioContext) verifyUpdateChildDashboardPermissionsWithOverrideShou
}
for
_
,
p
:=
range
[]
models
.
PermissionType
{
models
.
PERMISSION_ADMIN
,
models
.
PERMISSION_EDIT
,
models
.
PERMISSION_VIEW
}
{
p
:=
p
// permission to update is lower than or equal to parent folder permission
if
p
<=
parentFolderPermission
{
continue
...
...
pkg/services/notifications/mailer.go
View file @
d1e6214a
...
...
@@ -78,6 +78,7 @@ func (ns *NotificationService) setFiles(
}
for
_
,
file
:=
range
msg
.
AttachedFiles
{
file
:=
file
m
.
Attach
(
file
.
Name
,
gomail
.
SetCopyFunc
(
func
(
writer
io
.
Writer
)
error
{
_
,
err
:=
writer
.
Write
(
file
.
Content
)
return
err
...
...
pkg/services/sqlstore/migrations/migrations_test.go
View file @
d1e6214a
...
...
@@ -16,6 +16,7 @@ func TestMigrations(t *testing.T) {
}
for
_
,
testDB
:=
range
testDBs
{
testDB
:=
testDB
sql
:=
`select count(*) as count from migration_log`
r
:=
struct
{
Count
int64
...
...
pkg/services/sqlstore/migrator/migrator.go
View file @
d1e6214a
...
...
@@ -81,6 +81,7 @@ func (mg *Migrator) Start() error {
}
for
_
,
m
:=
range
mg
.
migrations
{
m
:=
m
_
,
exists
:=
logMap
[
m
.
Id
()]
if
exists
{
mg
.
Logger
.
Debug
(
"Skipping migration: Already executed"
,
"id"
,
m
.
Id
())
...
...
pkg/services/sqlstore/sqlstore_test.go
View file @
d1e6214a
...
...
@@ -71,6 +71,7 @@ func TestSqlConnectionString(t *testing.T) {
t
.
Helper
()
for
_
,
testCase
:=
range
sqlStoreTestCases
{
testCase
:=
testCase
Convey
(
testCase
.
name
,
func
()
{
sqlstore
:=
&
SqlStore
{}
sqlstore
.
Cfg
=
makeSqlStoreTestConfig
(
testCase
.
dbType
,
testCase
.
dbHost
)
...
...
pkg/tsdb/azuremonitor/applicationinsights-datasource_test.go
View file @
d1e6214a
...
...
@@ -275,6 +275,7 @@ func TestAppInsightsPluginRoutes(t *testing.T) {
}
for
_
,
tt
:=
range
tests
{
tt
:=
tt
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
route
,
routeName
,
err
:=
datasource
.
getPluginRoute
(
plugin
,
tt
.
cloudName
)
tt
.
Err
(
t
,
err
)
...
...
pkg/tsdb/azuremonitor/azure-log-analytics-datasource_test.go
View file @
d1e6214a
...
...
@@ -69,6 +69,7 @@ func TestBuildingAzureLogAnalyticsQueries(t *testing.T) {
}
for
_
,
tt
:=
range
tests
{
tt
:=
tt
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
queries
,
err
:=
datasource
.
buildQueries
(
tt
.
queryModel
,
tt
.
timeRange
)
tt
.
Err
(
t
,
err
)
...
...
@@ -141,6 +142,7 @@ func TestPluginRoutes(t *testing.T) {
}
for
_
,
tt
:=
range
tests
{
tt
:=
tt
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
route
,
proxypass
,
err
:=
datasource
.
getPluginRoute
(
plugin
,
tt
.
cloudName
)
tt
.
Err
(
t
,
err
)
...
...
pkg/tsdb/azuremonitor/azure-log-analytics-table-frame_test.go
View file @
d1e6214a
...
...
@@ -122,6 +122,7 @@ func TestLogTableToFrame(t *testing.T) {
}
for
_
,
tt
:=
range
tests
{
tt
:=
tt
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
res
,
err
:=
loadLogAnalyticsTestFileWithNumber
(
tt
.
testFile
)
require
.
NoError
(
t
,
err
)
...
...
pkg/tsdb/azuremonitor/azuremonitor-datasource_test.go
View file @
d1e6214a
...
...
@@ -98,6 +98,7 @@ func TestAzureMonitorBuildQueries(t *testing.T) {
}
for
_
,
tt
:=
range
tests
{
tt
:=
tt
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
for
k
,
v
:=
range
commonAzureModelProps
{
tt
.
azureMonitorVariedProperties
[
k
]
=
v
...
...
@@ -363,6 +364,7 @@ func TestAzureMonitorParseResponse(t *testing.T) {
datasource
:=
&
AzureMonitorDatasource
{}
for
_
,
tt
:=
range
tests
{
tt
:=
tt
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
azData
,
err
:=
loadTestFile
(
"azuremonitor/"
+
tt
.
responseFile
)
require
.
NoError
(
t
,
err
)
...
...
@@ -420,6 +422,7 @@ func TestFindClosestAllowIntervalMS(t *testing.T) {
},
}
for
_
,
tt
:=
range
tests
{
tt
:=
tt
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
interval
:=
findClosestAllowedIntervalMS
(
tt
.
inputInterval
,
tt
.
allowedTimeGrains
)
require
.
Equal
(
t
,
tt
.
expectedInterval
,
interval
)
...
...
pkg/tsdb/azuremonitor/macros_test.go
View file @
d1e6214a
...
...
@@ -139,6 +139,7 @@ func TestAzureLogAnalyticsMacros(t *testing.T) {
}
for
_
,
tt
:=
range
tests
{
tt
:=
tt
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
defaultTimeField
:=
"TimeGenerated"
rawQuery
,
err
:=
KqlInterpolate
(
tt
.
query
,
timeRange
,
tt
.
kql
,
defaultTimeField
)
...
...
pkg/tsdb/elasticsearch/time_series_query.go
View file @
d1e6214a
...
...
@@ -89,6 +89,7 @@ func (e *timeSeriesQuery) execute() (*tsdb.Response, error) {
}
for
_
,
m
:=
range
q
.
Metrics
{
m
:=
m
if
m
.
Type
==
countType
{
continue
}
...
...
pkg/tsdb/frame_util_test.go
View file @
d1e6214a
...
...
@@ -128,6 +128,7 @@ func TestFrameToSeriesSlice(t *testing.T) {
},
}
for
_
,
tt
:=
range
tests
{
tt
:=
tt
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
seriesSlice
,
err
:=
FrameToSeriesSlice
(
tt
.
frame
)
tt
.
Err
(
t
,
err
)
...
...
pkg/tsdb/influxdb/flux/macros_test.go
View file @
d1e6214a
...
...
@@ -35,6 +35,7 @@ func TestInterpolate(t *testing.T) {
},
}
for
_
,
tt
:=
range
tests
{
tt
:=
tt
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
query
:=
QueryModel
{
...
...
scripts/go/configs/.golangci.toml
View file @
d1e6214a
...
...
@@ -29,7 +29,7 @@ enable = [
# "interfacer",
# "misspell",
"rowserrcheck"
,
#
"scopelint",
"scopelint"
,
"staticcheck"
,
"structcheck"
,
# "stylecheck",
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment