Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Golangci-lint failing with latest version #689

Closed
xnyo opened this issue May 22, 2023 · 1 comment · Fixed by #779
Closed

Golangci-lint failing with latest version #689

xnyo opened this issue May 22, 2023 · 1 comment · Fixed by #779
Assignees
Labels

Comments

@xnyo
Copy link
Member

xnyo commented May 22, 2023

When running mage lint with the latest version of golangci-lint, it fails:

╭─ ~/grafana/grafana-plugin-sdk-go on main *7                                                took 6s
╰─❯ mage lint    
data/sqlutil/macros.go:75:21: unused-parameter: parameter 'query' seems to be unused, consider removing or renaming it as _ (revive)
func macroTimeGroup(query *Query, args []string) (string, error) {
                    ^
data/sqlutil/macros.go:105:31: unused-parameter: parameter 'args' seems to be unused, consider removing or renaming it as _ (revive)
func macroTable(query *Query, args []string) (string, error) {
                              ^
data/sqlutil/macros.go:113:32: unused-parameter: parameter 'args' seems to be unused, consider removing or renaming it as _ (revive)
func macroColumn(query *Query, args []string) (string, error) {
                               ^
backend/datasource/query_type_mux_test.go:77:34: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (th *testHandler) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
                                 ^
backend/datasource/query_type_mux.go:109:22: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func fallbackHandler(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
                     ^
experimental/http_logger/http_logger_test.go:112:39: unused-parameter: parameter 'req' seems to be unused, consider removing or renaming it as _ (revive)
func (hl *fakeRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
                                      ^
experimental/macros/macros.go:11:61: unused-parameter: parameter 'pluginContext' seems to be unused, consider removing or renaming it as _ (revive)
func ApplyMacros(input string, timeRange backend.TimeRange, pluginContext backend.PluginContext) (string, error) {
                                                            ^
experimental/e2e/proxy.go:120:44: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive)
func (p *Proxy) append(res *http.Response, ctx *goproxy.ProxyCtx) *http.Response {
                                           ^
backend/data_adapter_test.go:44:67: unused-parameter: parameter 'req' seems to be unused, consider removing or renaming it as _ (revive)
func (f *fakeDataHandlerWithOAuth) QueryData(ctx context.Context, req *QueryDataRequest) (*QueryDataResponse, error) {
                                                                  ^
backend/resource_adapter_test.go:252:73: unused-parameter: parameter 'req' seems to be unused, consider removing or renaming it as _ (revive)
func (h *testCallResourceWithHeaders) CallResource(ctx context.Context, req *CallResourceRequest, sender CallResourceResponseSender) error {
                                                                        ^
data/frame.go:544:26: unused-parameter: parameter 'fieldName' seems to be unused, consider removing or renaming it as _ (revive)
func (f *Frame) TypeInfo(fieldName string) (FrameType, FrameTypeVersion) {
                         ^
backend/grpcplugin/grpc_data.go:29:37: unused-parameter: parameter 'broker' seems to be unused, consider removing or renaming it as _ (revive)
func (p *DataGRPCPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error {
                                    ^
backend/grpcplugin/grpc_stream.go:29:39: unused-parameter: parameter 'broker' seems to be unused, consider removing or renaming it as _ (revive)
func (p *StreamGRPCPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error {
                                      ^
backend/grpcplugin/grpc_resource.go:29:41: unused-parameter: parameter 'broker' seems to be unused, consider removing or renaming it as _ (revive)
func (p *ResourceGRPCPlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error {
                                        ^
Error: running "golangci-lint run ./..." failed with exit code 1

This isn't the version being used by ci, but if we update it will fail.

Moreover, if you run mage lint locally, it's a bit annoying to see those issues highlighted locally and not during the ci checks.

@xnyo
Copy link
Member Author

xnyo commented Oct 19, 2023

The issues above are fixed, however with the latest version there are a bunch of new ones:

golangci-lint version
golangci-lint has version 1.54.2 built with go1.21.0 from 411e0bbb on 2023-08-21T12:04:32Z
internal/buildinfo/buildinfo.go:9:2: import 'github.com/grafana/grafana-plugin-sdk-go/build' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/build"  
       ^  
backend/log/log.go:7:2: import 'github.com/hashicorp/go-hclog' is not allowed from list 'Main' (depguard)  
       hclog "github.com/hashicorp/go-hclog"  
       ^  
backend/log/context_test.go:7:2: import 'github.com/stretchr/testify/require' is not allowed from list 'Main' (depguard)  
       "github.com/stretchr/testify/require"  
       ^  
backend/log/log_test.go:7:2: import 'github.com/stretchr/testify/assert' is not allowed from list 'Main' (depguard)  
       "github.com/stretchr/testify/assert"  
       ^  
backend/log/log_test.go:8:2: import 'github.com/stretchr/testify/require' is not allowed from list 'Main' (depguard)  
       "github.com/stretchr/testify/require"  
       ^  
experimental/macros/macros_test.go:7:2: import 'github.com/grafana/grafana-plugin-sdk-go/backend' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/backend"  
       ^  
experimental/macros/macros_test.go:8:2: import 'github.com/grafana/grafana-plugin-sdk-go/experimental/macros' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/experimental/macros"  
       ^  
experimental/macros/macros_test.go:9:2: import 'github.com/stretchr/testify/assert' is not allowed from list 'Main' (depguard)  
       "github.com/stretchr/testify/assert"  
       ^  
experimental/macros/macros_test.go:10:2: import 'github.com/stretchr/testify/require' is not allowed from list 'Main' (depguard)  
       "github.com/stretchr/testify/require"  
       ^  
experimental/macros/time_macros_test.go:7:2: import 'github.com/grafana/grafana-plugin-sdk-go/backend' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/backend"  
       ^  
experimental/macros/time_macros_test.go:8:2: import 'github.com/grafana/grafana-plugin-sdk-go/experimental/macros' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/experimental/macros"  
       ^  
experimental/macros/time_macros_test.go:9:2: import 'github.com/stretchr/testify/assert' is not allowed from list 'Main' (depguard)  
       "github.com/stretchr/testify/assert"  
       ^  
experimental/e2e/proxy.go:10:2: import 'github.com/elazarl/goproxy' is not allowed from list 'Main' (depguard)  
       "github.com/elazarl/goproxy"  
       ^  
experimental/e2e/proxy.go:12:2: import 'github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/certificate_authority' is not allowed from list 'Main' (depguard)  
       ca "github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/certificate_authority"  
       ^  
experimental/e2e/proxy.go:13:2: import 'github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/config' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/config"  
       ^  
experimental/e2e/proxy.go:14:2: import 'github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/fixture' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/fixture"  
       ^  
experimental/e2e/proxy.go:15:2: import 'github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/utils' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/utils"  
       ^  
experimental/datasourcetest/client.go:13:2: import 'github.com/grafana/grafana-plugin-sdk-go/backend' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/backend"  
       ^  
experimental/datasourcetest/client.go:14:2: import 'github.com/grafana/grafana-plugin-sdk-go/genproto/pluginv2' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/genproto/pluginv2"  
       ^  
experimental/datasourcetest/manage.go:5:2: import 'github.com/grafana/grafana-plugin-sdk-go/backend/datasource' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/backend/datasource"  
       ^  
experimental/datasourcetest/manage.go:6:2: import 'github.com/grafana/grafana-plugin-sdk-go/internal/automanagement' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/internal/automanagement"  
       ^  
backend/httpclient/contextual_middleware_example_test.go:8:2: import 'github.com/grafana/grafana-plugin-sdk-go/backend/httpclient' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"  
       ^  
backend/httpclient/http_client_example_test.go:8:2: import 'github.com/grafana/grafana-plugin-sdk-go/backend/httpclient' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"  
       ^  
backend/httpclient/provider_example_test.go:8:2: import 'github.com/grafana/grafana-plugin-sdk-go/backend/httpclient' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/backend/httpclient"  
       ^  
backend/httpclient/tracing_middleware_test.go:16:2: import 'github.com/grafana/grafana-plugin-sdk-go/internal/tracerprovider' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/internal/tracerprovider"  
       ^  
data/converters/converters_test.go:9:2: import 'github.com/grafana/grafana-plugin-sdk-go/data/converters' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/data/converters"  
       ^  
experimental/authclient/authclient_test.go:16:2: import 'github.com/grafana/grafana-plugin-sdk-go/experimental/authclient' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/experimental/authclient"  
       ^  
experimental/e2e/proxy_test.go:13:2: import 'github.com/grafana/grafana-plugin-sdk-go/experimental/e2e' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/experimental/e2e"  
       ^  
experimental/e2e/proxy_test.go:14:2: import 'github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/config' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/config"  
       ^  
experimental/e2e/proxy_test.go:15:2: import 'github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/fixture' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/fixture"  
       ^  
experimental/e2e/proxy_test.go:16:2: import 'github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/storage' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/storage"  
       ^  
experimental/e2e/certificate_authority/ca_test.go:9:2: import 'github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/certificate_authority' is not allowed from list 'Main' (depguard)  
       ca "github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/certificate_authority"  
       ^  
experimental/http_logger/http_logger_test.go:14:2: import 'github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/storage' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/storage"  
       ^  
experimental/http_logger/http_logger_test.go:15:2: import 'github.com/grafana/grafana-plugin-sdk-go/experimental/http_logger' is not allowed from list 'Main' (depguard)  
       httplogger "github.com/grafana/grafana-plugin-sdk-go/experimental/http_logger"  
       ^  
backend/datasource/query_type_mux_example_test.go:7:2: import 'github.com/grafana/grafana-plugin-sdk-go/backend/datasource' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/backend/datasource"  
       ^  
backend/datasource/serve_example_test.go:9:2: import 'github.com/grafana/grafana-plugin-sdk-go/backend/datasource' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/backend/datasource"  
       ^  
backend/datasource/serve_example_test.go:11:2: import 'github.com/grafana/grafana-plugin-sdk-go/backend/instancemgmt' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/backend/instancemgmt"  
       ^  
backend/datasource/serve_example_test.go:12:2: import 'github.com/grafana/grafana-plugin-sdk-go/backend/resource/httpadapter' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/backend/resource/httpadapter"  
       ^  
backend/httpclient/http_client.go:10:2: import 'github.com/grafana/grafana-plugin-sdk-go/backend/proxy' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/backend/proxy"  
       ^  
backend/httpclient/options.go:8:2: import 'github.com/grafana/grafana-plugin-sdk-go/backend/proxy' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/backend/proxy"  
       ^  
backend/httpclient/tracing_middleware.go:16:2: import 'github.com/grafana/grafana-plugin-sdk-go/backend/tracing' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/backend/tracing"  
       ^  
build/common.go:13:2: import 'github.com/grafana/grafana-plugin-sdk-go/build/utils' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/build/utils"  
       ^  
build/common.go:14:2: import 'github.com/grafana/grafana-plugin-sdk-go/experimental/e2e' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/experimental/e2e"  
       ^  
build/common.go:15:2: import 'github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/certificate_authority' is not allowed from list 'Main' (depguard)  
       ca "github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/certificate_authority"  
       ^  
build/common.go:16:2: import 'github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/config' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/config"  
       ^  
build/common.go:17:2: import 'github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/fixture' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/fixture"  
       ^  
build/common.go:18:2: import 'github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/storage' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/experimental/e2e/storage"  
       ^  
build/common.go:19:2: import 'github.com/grafana/grafana-plugin-sdk-go/internal' is not allowed from list 'Main' (depguard)  
       "github.com/grafana/grafana-plugin-sdk-go/internal"  
       ^  
build/common.go:20:2: import 'github.com/magefile/mage/mg' is not allowed from list 'Main' (depguard)  
       "github.com/magefile/mage/mg"  
       ^  
build/common.go:21:2: import 'github.com/magefile/mage/sh' is not allowed from list 'Main' (depguard)  
       "github.com/magefile/mage/sh"  
       ^  
backend/setup.go:25:2: G101: Potential hardcoded credentials (gosec)  
       PluginProfilerPortEnvDeprecated = "GF_PLUGINS_PROFILER_PORT"  
       ^  
backend/setup.go:27:2: G101: Potential hardcoded credentials (gosec)  
       PluginProfilingPortEnv = "GF_PLUGIN_PROFILING_PORT"  
       ^  
backend/setup.go:31:2: G101: Potential hardcoded credentials (gosec)  
       PluginTracingOpenTelemetryOTLPAddressEnv = "GF_INSTANCE_OTLP_ADDRESS"  
       ^  
build/utils/copy.go:22:3: naked return in func `CopyFile` with 46 lines of code (nakedret)  
               return  
               ^  
build/utils/copy.go:35:3: naked return in func `CopyFile` with 46 lines of code (nakedret)  
               return  
               ^  
build/utils/copy.go:42:4: naked return in func `CopyFile` with 46 lines of code (nakedret)  
                       return  
                       ^  
data/time_series.go:69:3: naked return in func `TimeSeriesSchema` with 38 lines of code (nakedret)  
               return  
               ^  
data/time_series.go:75:3: naked return in func `TimeSeriesSchema` with 38 lines of code (nakedret)  
               return  
               ^  
data/time_series.go:95:3: naked return in func `TimeSeriesSchema` with 38 lines of code (nakedret)  
               return  
               ^  
Error: running "golangci-lint run ./..." failed with exit code 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
1 participant