-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add static check and fix all errors #218
Conversation
I'm still hesitant about adding this check. IMO most suggestions from this tool are kind of nitpicking. For example here's a sample output: $ make staticcheck
staticcheck ./...
config/config.go:179:44: should use make(configmodels.Receivers) instead (S1019)
config/config.go:245:44: should use make(configmodels.Exporters) instead (S1019)
config/config.go:302:46: should use make(configmodels.Processors) instead (S1019)
config/config.go:359:44: should use make(configmodels.Pipelines) instead (S1019)
exporter/exporterhelper/metricshelper_test.go:97:68: should use make([]*metricspb.Metric, 1) instead (S1019)
exporter/exporterhelper/tracehelper_test.go:135:33: should use make([]*tracepb.Span, 2) instead (S1019)
exporter/exporterhelper/tracehelper_test.go:154:60: should use make([]*tracepb.Span, 1) instead (S1019)
exporter/exportertest/nop_exporter_test.go:34:5: don't use Yoda conditions (ST1017)
exporter/exportertest/nop_exporter_test.go:48:5: don't use Yoda conditions (ST1017)
exporter/exportertest/nop_exporter_test.go:61:5: don't use Yoda conditions (ST1017)
exporter/exportertest/nop_exporter_test.go:75:5: don't use Yoda conditions (ST1017)
exporter/exportertest/sink_exporter_test.go:42:5: don't use Yoda conditions (ST1017)
exporter/exportertest/sink_exporter_test.go:63:5: don't use Yoda conditions (ST1017)
exporter/jaegerexporter/jaeger_thrift_http_sender.go:114:20: error strings should not be capitalized (ST1005)
exporter/loggingexporter/logging_exporter_test.go:37:5: don't use Yoda conditions (ST1017)
exporter/loggingexporter/logging_exporter_test.go:53:5: don't use Yoda conditions (ST1017)
exporter/opencensusexporter/opencensus.go:60:2: field counter is unused (U1000)
exporter/prometheusexporter/factory_test.go:44:8: const defaultTestEndPoint is unused (U1000)
exporter/zipkinexporter/zipkin.go:110:35: error strings should not be capitalized (ST1005)
internal/collector/processor/idbatcher/id_batcher.go:70:2: field numBatches is unused (U1000)
internal/collector/processor/idbatcher/id_batcher.go:131:3: the surrounding loop is unconditionally terminated (SA4004)
internal/collector/processor/idbatcher/id_batcher_test.go:99:2: the goroutine calls T.Fatal, which must be called in the same goroutine as the test (SA2002)
internal/collector/processor/idbatcher/id_batcher_test.go:111:5: ineffective break statement. Did you mean to break out of the outer loop? (SA4011)
internal/collector/processor/idbatcher/id_batcher_test.go:157:24: should use make([][]byte, numIds) instead (S1019)
internal/collector/processor/metrics.go:58:3: redundant break statement (S1023)
observability/observabilitytest/observabilitytest.go:93:20: error strings should not be capitalized (ST1005)
observability/observabilitytest/observabilitytest.go:102:22: error strings should not be capitalized (ST1005)
observability/observabilitytest/observabilitytest.go:108:19: error strings should not be capitalized (ST1005)
processor/addattributesprocessor/addattributesprocessor.go:30:33: error strings should not be capitalized (ST1005)
processor/attributekeyprocessor/attributekeyprocessor_test.go:161:34: should use make([]*tracepb.Span, 1) instead (S1019)
processor/attributekeyprocessor/attributekeyprocessor_test.go:165:35: should use make([]*tracepb.Span, 1) instead (S1019)
processor/attributekeyprocessor/config_test.go:30:27: this value of err is never used (SA4006)
processor/attributekeyprocessor/config_test.go:78:27: this value of err is never used (SA4006)
processor/attributekeyprocessor/factory.go:47:43: should use make(map[string]NewKeyProperties) instead (S1019)
processor/nodebatcher/node_batcher.go:75:2: field bucketMu is unused (U1000)
processor/probabilisticsampler/config_test.go:56:27: this value of err is never used (SA4006)
processor/tailsampling/processor.go:72:2: const sourceFormat is unused (U1000)
processor/tailsampling/processor.go:204:49: should use make([]sampling.Decision, lenPolicies) instead (S1019)
processor/tailsampling/processor_test.go:216:29: should use make([][]byte, numIds) instead (S1019)
processor/tailsampling/processor_test.go:244:6: func newTestPolicy is unused (U1000)
receiver/jaegerreceiver/trace_receiver.go:74:2: field agentServer is unused (U1000)
receiver/jaegerreceiver/trace_receiver.go:96:2: const defaultZipkinThriftUDPPort is unused (U1000)
receiver/jaegerreceiver/trace_receiver_test.go:108:8: this value of err is never used (SA4006)
receiver/jaegerreceiver/trace_receiver_test.go:109:2: should check returned error before deferring conn.Close() (SA5001)
receiver/opencensusreceiver/octrace/opencensus.go:157:2: field tes is unused (U1000)
receiver/opencensusreceiver/opencensus.go:79:25: error strings should not be capitalized (ST1005)
receiver/opencensusreceiver/options.go:98:2: redundant return statement (S1023)
receiver/prometheusreceiver/internal/metricsbuilder.go:55:2: field ts is unused (U1000)
receiver/prometheusreceiver/internal/metricsbuilder_test.go:201:3: field processErr is unused (U1000)
receiver/prometheusreceiver/metrics_receiver.go:50:2: field ocaStore is unused (U1000)
receiver/prometheusreceiver/metrics_receiver.go:60:2: var errAlreadyStarted is unused (U1000)
receiver/prometheusreceiver/metrics_receiver.go:61:2: var errNilMetricsReceiverSink is unused (U1000)
receiver/vmmetricsreceiver/metrics_receiver.go:27:2: var errNilMetricsConsumer is unused (U1000)
receiver/zipkinreceiver/trace_receiver.go:341:9: this value of err is never used (SA4006)
receiver/zipkinreceiver/trace_receiver_test.go:128:3: field want is unused (U1000)
service/builder/pipelines_builder_test.go:71:16: this value of err is never used (SA4006)
service/builder/pipelines_builder_test.go:142:13: this value of err is never used (SA4006)
service/builder/receivers_builder_test.go:105:16: this value of err is never used (SA4006)
service/builder/receivers_builder_test.go:106:22: this value of err is never used (SA4006)
service/builder/receivers_builder_test.go:222:16: this value of err is never used (SA4006)
service/builder/receivers_builder_test.go:223:22: this value of err is never used (SA4006)
service/service.go:48:2: field processor is unused (U1000)
service/service.go:49:2: field receivers is unused (U1000)
service/service.go:195:25: func (*Application).shutdownReceivers is unused (U1000)
service/service_test.go:54:2: the goroutine calls T.Fatalf, which must be called in the same goroutine as the test (SA2002)
service/service_test.go:96:30: should use make([]string, numAddresses) instead (S1019)
translator/trace/jaeger/constants.go:38:2: var errNilTraceID is unused (U1000)
translator/trace/jaeger/constants.go:39:2: var errWrongLenTraceID is unused (U1000)
translator/trace/jaeger/constants.go:41:2: var errNilID is unused (U1000)
translator/trace/jaeger/constants.go:42:2: var errWrongLenID is unused (U1000)
translator/trace/jaeger/jaegerthrift_to_protospan_test.go:109:8: const numOfFiles is unused (U1000)
translator/trace/jaeger/protospan_to_jaegerproto.go:458:12: this value of err is never used (SA4006)
translator/trace/jaeger/protospan_to_jaegerproto.go:466:26: error strings should not be capitalized (ST1005)
translator/trace/jaeger/protospan_to_jaegerthrift.go:165:26: error strings should not be capitalized (ST1005)
make: *** [staticcheck] Error 1 The A few alternatives I can think of here:
WDYT? |
It may appear annoying at first, especially because you have lots of nitpicks when you run it for the first time. But subsequently there may be fewer errors to fix on incremental changes. Ideally it would have been nice if it also auto corrected. May be there will be such option in future. |
I like the idea, I'm just not sure if we should do it before milestone 0.1.0 or not. |
IMO this shouldn't be a blocker for v0.1.0 release because it's only affecting code styles rather than functionality. |
Agreed: it isn't a blocker, I'm just worried about the churn. That said if the fixes are all small/nit changes than it is fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes to add the tool itself LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes in this batch LGTM.
Should all be fixed - PTAL. Hopefully the bug fixing is an one-off effort. In the future new code will conform to the checks. |
Codecov Report
@@ Coverage Diff @@
## master #218 +/- ##
==========================================
+ Coverage 72.43% 72.48% +0.04%
==========================================
Files 109 109
Lines 6305 6301 -4
==========================================
Hits 4567 4567
+ Misses 1508 1504 -4
Partials 230 230
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Nice tool addition @songy23
@@ -120,7 +119,7 @@ func (b *batcher) AddToCurrentBatch(id ID) { | |||
} | |||
|
|||
func (b *batcher) CloseCurrentAndTakeFirstBatch() (Batch, bool) { | |||
for readBatch := range b.batches { | |||
if readBatch, ok := <-b.batches; ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was it intended to change the for
by if
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, otherwise either test or static check would fail. The updated code is equivalent to the previous one.
Should be ready to merge now. |
* Migrate updates to Prometheus receiver from opencensus-service * Remove unnecessary configuration for adjusting metrics * Update exporters README (#210) Remove stale content, put in place a simple skeleton, and put information for the Zipkin exporter. * Added Jaeger gRPC receiver (#197) * Added Jaeger gRPC receiver Signed-off-by: Juraci Paixão Kröhling <[email protected]> * Addressed first review round Signed-off-by: Juraci Paixão Kröhling <[email protected]> * Changes based on the feedback from the second review Signed-off-by: Juraci Paixão Kröhling <[email protected]> * Fixed import order, check for same ip:port on endpoints Signed-off-by: Juraci Paixão Kröhling <[email protected]> * Reverted the port-check Signed-off-by: Juraci Paixão Kröhling <[email protected]> * Fix README - remove broken links and commands (#211) Signed-off-by: Hui Kang <[email protected]> * Refactor opencensus exporter to make it easily extensible (#212) Refactored oc exporter code to make it easier to import in derived builds without copying all the code. Example derived exporter: https://github.com/owais/example-derived-oc-exporter - Moved internal/compression to root - Split opencensusexporter factory's `CreateTraceExporter` method into - `OCAgentOptions` and `CreateOCAgent` * Use sha256 instead of md5 in node batcher processor (#202) MD5 is insecure cryptographic hash functions, and are therefore unsuitable for security applications. * Add goimports check and fix import order for all files (#209) * Add goimports check and fix import order for all files Updates #155. * Try specifying a version for goimports * Show the diff instead of files and fix import * Fix default in Makefile * Add factory and update config for tail sampling processor (#200) * Add factory and update config for tail sampling processor Updates #146 * Move to package processor * Remove an unnecessary check * Move CreateDefaultConfig to factory and add unit tests * Fix test failure * Remove commented code * Add misspell check and fix all typos (#214) * Add misspell check and fix all typos Updates #155. * Format * Include yaml files * Move tail sampling config to its own package and remove stale configs (#217) Follow up of #200. Second step of #146. * Add Observability Vision document (#188) * Add Observability Vision document This is a guidance document that developers can consult with when working on improving own observability of OpenTelemetry Service. * PR fixes * Add Zipkin exporter factory (#207) * Add Zipkin exporter factory Add the Zipkin exporter configuration factory using the new configuration format. This does not bring many of the settings from the old configuration since they won't be used. In a sub-sequent PR the code of the exporter itself will be changed. * PR Feedback: add 1 test plus some comments * Rename endpoint to http-url and related field * Fix goimports issue * Remove TODO commented code Replaced the TODO commented code with an issue. * Rename the field used to specify destination * Update README to address reviewer comments. * Update module dependencies and import order for metricfamily * Improve OC Receiver Documentation (#203) * First round of receiver and opencensus receiver documentation. * Undo go mod/sum changes * Address initial set of comments. * Address next set of comments. * Address next set of comments. * Fix use of server instead of receiver in comment and explain settings can be mix and matched. * Merged master and fixed mispell error caugh with new tools * Add static check and fix all errors (#218) * Add static check Fixes #155. * Fix most staticcheck errors * More fixes * Fix id_batcher * Rename exporterhelp parameter (#220) The paramater was named exportFormat but it actually used as the exporter name. * Fix build: lower casing error message (#224) * Add jaeger grpc exporter (#219) * Add Jaeger gRPC exporter Adds a Jaeger gRPC exporter. * Update exporters/README.md * Fixes on the exporter/README.md * Add doc.go with package description. * Fix import order on config_test.go * Migrate updates to Prometheus receiver from opencensus-service * Remove unnecessary configuration for adjusting metrics * Update README to address reviewer comments. * Update module dependencies and import order for metricfamily * Fix goimports * Fix staticcheck issues
* Add SignalFx forwarder to default configs * Use layer caching on fpm builds * Document signalfx-forwarder as metric and trace receiver
* Added new values to allow custom ports * Bumped chart's patch version by 1 * Fixed tag position in values.yaml
Fixes #155.
This is inspired by googleapis/google-cloud-go.