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

Add godot linter to golangci #2845

Merged
merged 3 commits into from Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .golangci.yml
Expand Up @@ -15,6 +15,7 @@ linters:
- goimports
- gosimple
- govet
- godot
- ineffassign
- misspell
- revive
Expand Down Expand Up @@ -45,3 +46,9 @@ linters-settings:
- cancelled
goimports:
local-prefixes: go.opentelemetry.io
godot:
exclude:
# Exclude sentence fragments for lists.
- '^[ ]*[-•]'
# Exclude sentences prefixing a list.
- ':$'
6 changes: 3 additions & 3 deletions bridge/opencensus/exporter.go
Expand Up @@ -40,7 +40,7 @@ import (
var errConversion = errors.New("Unable to convert from OpenCensus to OpenTelemetry")

// NewMetricExporter returns an OpenCensus exporter that exports to an
// OpenTelemetry exporter
// OpenTelemetry exporter.
func NewMetricExporter(base export.Exporter) metricexport.Exporter {
return &exporter{base: base}
}
Expand All @@ -51,7 +51,7 @@ type exporter struct {
base export.Exporter
}

// ExportMetrics implements the OpenCensus metric Exporter interface
// ExportMetrics implements the OpenCensus metric Exporter interface.
func (e *exporter) ExportMetrics(ctx context.Context, metrics []*metricdata.Metric) error {
res := resource.Empty()
if len(metrics) != 0 {
Expand Down Expand Up @@ -147,7 +147,7 @@ func convertResource(res *ocresource.Resource) *resource.Resource {
return resource.NewSchemaless(attrs...)
}

// convertDescriptor converts an OpenCensus Descriptor to an OpenTelemetry Descriptor
// convertDescriptor converts an OpenCensus Descriptor to an OpenTelemetry Descriptor.
func convertDescriptor(ocDescriptor metricdata.Descriptor) (sdkapi.Descriptor, error) {
var (
nkind number.Kind
Expand Down
2 changes: 1 addition & 1 deletion example/opencensus/main.go
Expand Up @@ -40,7 +40,7 @@ import (
var (
// instrumenttype differentiates between our gauge and view metrics.
keyType = tag.MustNewKey("instrumenttype")
// Counts the number of lines read in from standard input
// Counts the number of lines read in from standard input.
countMeasure = stats.Int64("test_count", "A count of something", stats.UnitDimensionless)
countView = &view.View{
Name: "test_count",
Expand Down
4 changes: 2 additions & 2 deletions example/passthrough/handler/handler.go
Expand Up @@ -44,7 +44,7 @@ func New(next func(r *http.Request)) *Handler {
}
}

// HandleHTTPReq mimics what an instrumented http server does
// HandleHTTPReq mimics what an instrumented http server does.
func (h *Handler) HandleHTTPReq(r *http.Request) {
ctx := h.propagators.Extract(r.Context(), propagation.HeaderCarrier(r.Header))
var span trace.Span
Expand All @@ -58,7 +58,7 @@ func (h *Handler) HandleHTTPReq(r *http.Request) {
h.makeOutgoingRequest(ctx)
}

// makeOutgoingRequest mimics what an instrumented http client does
// makeOutgoingRequest mimics what an instrumented http client does.
func (h *Handler) makeOutgoingRequest(ctx context.Context) {
// make a new http request
r, err := http.NewRequest("", "", nil)
Expand Down
2 changes: 1 addition & 1 deletion example/passthrough/main.go
Expand Up @@ -73,7 +73,7 @@ func initPassthroughGlobals() {
}

// nonGlobalTracer creates a trace provider instance for testing, but doesn't
// set it as the global tracer provider
// set it as the global tracer provider.
func nonGlobalTracer() *sdktrace.TracerProvider {
var err error
exp, err := stdouttrace.New(stdouttrace.WithPrettyPrint())
Expand Down
2 changes: 1 addition & 1 deletion exporters/jaeger/agent.go
Expand Up @@ -29,7 +29,7 @@ import (
)

const (
// udpPacketMaxLength is the max size of UDP packet we want to send, synced with jaeger-agent
// udpPacketMaxLength is the max size of UDP packet we want to send, synced with jaeger-agent.
udpPacketMaxLength = 65000
// emitBatchOverhead is the additional overhead bytes used for enveloping the datagram,
// synced with jaeger-agent https://github.com/jaegertracing/jaeger-client-go/blob/master/transport_udp.go#L37
Expand Down
8 changes: 4 additions & 4 deletions exporters/jaeger/env.go
Expand Up @@ -18,13 +18,13 @@ import (
"os"
)

// Environment variable names
// Environment variable names.
const (
// Hostname for the Jaeger agent, part of address where exporter sends spans
// i.e. "localhost"
// i.e. "localhost".
envAgentHost = "OTEL_EXPORTER_JAEGER_AGENT_HOST"
// Port for the Jaeger agent, part of address where exporter sends spans
// i.e. 6831
// i.e. 6831.
envAgentPort = "OTEL_EXPORTER_JAEGER_AGENT_PORT"
// The HTTP endpoint for sending spans directly to a collector,
// i.e. http://jaeger-collector:14268/api/traces.
Expand All @@ -35,7 +35,7 @@ const (
envPassword = "OTEL_EXPORTER_JAEGER_PASSWORD"
)

// envOr returns an env variable's value if it is exists or the default if not
// envOr returns an env variable's value if it is exists or the default if not.
func envOr(key, defaultValue string) string {
if v, ok := os.LookupEnv(key); ok && v != "" {
return v
Expand Down
6 changes: 3 additions & 3 deletions exporters/jaeger/reconnecting_udp_client.go
Expand Up @@ -134,7 +134,7 @@ func (c *reconnectingUDPConn) attemptDialNewAddr(newAddr *net.UDPAddr) error {
return nil
}

// Write calls net.udpConn.Write, if it fails an attempt is made to connect to a new addr, if that succeeds the write is retried before returning
// Write calls net.udpConn.Write, if it fails an attempt is made to connect to a new addr, if that succeeds the write is retried before returning.
func (c *reconnectingUDPConn) Write(b []byte) (int, error) {
var bytesWritten int
var err error
Expand Down Expand Up @@ -167,7 +167,7 @@ func (c *reconnectingUDPConn) Write(b []byte) (int, error) {
return bytesWritten, err
}

// Close stops the reconnectLoop, then closes the connection via net.udpConn 's implementation
// Close stops the reconnectLoop, then closes the connection via net.udpConn 's implementation.
func (c *reconnectingUDPConn) Close() error {
close(c.closeChan)

Expand All @@ -183,7 +183,7 @@ func (c *reconnectingUDPConn) Close() error {
}

// SetWriteBuffer defers to the net.udpConn SetWriteBuffer implementation wrapped with a RLock. if no conn is currently held
// and SetWriteBuffer is called store bufferBytes to be set for new conns
// and SetWriteBuffer is called store bufferBytes to be set for new conns.
func (c *reconnectingUDPConn) SetWriteBuffer(bytes int) error {
var err error

Expand Down
2 changes: 1 addition & 1 deletion exporters/jaeger/uploader.go
Expand Up @@ -28,7 +28,7 @@ import (
"go.opentelemetry.io/otel/exporters/jaeger/internal/third_party/thrift/lib/go/thrift"
)

// batchUploader send a batch of spans to Jaeger
// batchUploader send a batch of spans to Jaeger.
type batchUploader interface {
upload(context.Context, *gen.Batch) error
shutdown(context.Context) error
Expand Down
16 changes: 8 additions & 8 deletions exporters/otlp/internal/envconfig/envconfig.go
Expand Up @@ -25,17 +25,17 @@ import (
"time"
)

// ConfigFn is the generic function used to set a config
// ConfigFn is the generic function used to set a config.
type ConfigFn func(*EnvOptionsReader)

// EnvOptionsReader reads the required environment variables
// EnvOptionsReader reads the required environment variables.
type EnvOptionsReader struct {
GetEnv func(string) string
ReadFile func(string) ([]byte, error)
Namespace string
}

// Apply runs every ConfigFn
// Apply runs every ConfigFn.
func (e *EnvOptionsReader) Apply(opts ...ConfigFn) {
for _, o := range opts {
o(e)
Expand All @@ -50,7 +50,7 @@ func (e *EnvOptionsReader) GetEnvValue(key string) (string, bool) {
return v, v != ""
}

// WithString retrieves the specified config and passes it to ConfigFn as a string
// WithString retrieves the specified config and passes it to ConfigFn as a string.
func WithString(n string, fn func(string)) func(e *EnvOptionsReader) {
return func(e *EnvOptionsReader) {
if v, ok := e.GetEnvValue(n); ok {
Expand All @@ -59,7 +59,7 @@ func WithString(n string, fn func(string)) func(e *EnvOptionsReader) {
}
}

// WithDuration retrieves the specified config and passes it to ConfigFn as a duration
// WithDuration retrieves the specified config and passes it to ConfigFn as a duration.
func WithDuration(n string, fn func(time.Duration)) func(e *EnvOptionsReader) {
return func(e *EnvOptionsReader) {
if v, ok := e.GetEnvValue(n); ok {
Expand All @@ -70,7 +70,7 @@ func WithDuration(n string, fn func(time.Duration)) func(e *EnvOptionsReader) {
}
}

// WithHeaders retrieves the specified config and passes it to ConfigFn as a map of HTTP headers
// WithHeaders retrieves the specified config and passes it to ConfigFn as a map of HTTP headers.
func WithHeaders(n string, fn func(map[string]string)) func(e *EnvOptionsReader) {
return func(e *EnvOptionsReader) {
if v, ok := e.GetEnvValue(n); ok {
Expand All @@ -79,7 +79,7 @@ func WithHeaders(n string, fn func(map[string]string)) func(e *EnvOptionsReader)
}
}

// WithURL retrieves the specified config and passes it to ConfigFn as a net/url.URL
// WithURL retrieves the specified config and passes it to ConfigFn as a net/url.URL.
func WithURL(n string, fn func(*url.URL)) func(e *EnvOptionsReader) {
return func(e *EnvOptionsReader) {
if v, ok := e.GetEnvValue(n); ok {
Expand All @@ -90,7 +90,7 @@ func WithURL(n string, fn func(*url.URL)) func(e *EnvOptionsReader) {
}
}

// WithTLSConfig retrieves the specified config and passes it to ConfigFn as a crypto/tls.Config
// WithTLSConfig retrieves the specified config and passes it to ConfigFn as a crypto/tls.Config.
func WithTLSConfig(n string, fn func(*tls.Config)) func(e *EnvOptionsReader) {
return func(e *EnvOptionsReader) {
if v, ok := e.GetEnvValue(n); ok {
Expand Down
Expand Up @@ -40,7 +40,7 @@ var (

// ErrIncompatibleAgg is returned when
// aggregation.Kind implies an interface conversion that has
// failed
// failed.
ErrIncompatibleAgg = errors.New("incompatible aggregation type")

// ErrUnknownValueType is returned when a transformation of an unknown value
Expand Down
8 changes: 4 additions & 4 deletions exporters/otlp/otlpmetric/internal/otlpconfig/envconfig.go
Expand Up @@ -26,14 +26,14 @@ import (
"go.opentelemetry.io/otel/exporters/otlp/internal/envconfig"
)

// DefaultEnvOptionsReader is the default environments reader
// DefaultEnvOptionsReader is the default environments reader.
var DefaultEnvOptionsReader = envconfig.EnvOptionsReader{
GetEnv: os.Getenv,
ReadFile: ioutil.ReadFile,
Namespace: "OTEL_EXPORTER_OTLP",
}

// ApplyGRPCEnvConfigs applies the env configurations for gRPC
// ApplyGRPCEnvConfigs applies the env configurations for gRPC.
func ApplyGRPCEnvConfigs(cfg Config) Config {
opts := getOptionsFromEnv()
for _, opt := range opts {
Expand All @@ -42,7 +42,7 @@ func ApplyGRPCEnvConfigs(cfg Config) Config {
return cfg
}

// ApplyHTTPEnvConfigs applies the env configurations for HTTP
// ApplyHTTPEnvConfigs applies the env configurations for HTTP.
func ApplyHTTPEnvConfigs(cfg Config) Config {
opts := getOptionsFromEnv()
for _, opt := range opts {
Expand Down Expand Up @@ -104,7 +104,7 @@ func withEndpointForGRPC(u *url.URL) func(cfg Config) Config {
}
}

// WithEnvCompression retrieves the specified config and passes it to ConfigFn as a Compression
// WithEnvCompression retrieves the specified config and passes it to ConfigFn as a Compression.
func WithEnvCompression(n string, fn func(Compression)) func(e *envconfig.EnvOptionsReader) {
return func(e *envconfig.EnvOptionsReader) {
if v, ok := e.GetEnvValue(n); ok {
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/otlpmetric/otlpmetricgrpc/client_test.go
Expand Up @@ -163,7 +163,7 @@ func TestNewExporterInvokeStartThenStopManyTimes(t *testing.T) {
}
}

// This test takes a long time to run: to skip it, run tests using: -short
// This test takes a long time to run: to skip it, run tests using: -short.
func TestNewExporterCollectorOnBadConnection(t *testing.T) {
if testing.Short() {
t.Skipf("Skipping this long running test")
Expand Down
Expand Up @@ -139,7 +139,7 @@ func (mc *mockCollector) GetMetrics() []*metricpb.Metric {
return mc.getMetrics()
}

// runMockCollector is a helper function to create a mock Collector
// runMockCollector is a helper function to create a mock Collector.
func runMockCollector(t *testing.T) *mockCollector {
return runMockCollectorAtEndpoint(t, "localhost:0")
}
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/otlpmetric/otlpmetrichttp/client.go
Expand Up @@ -98,7 +98,7 @@ func NewClient(opts ...Option) otlpmetric.Client {
}
}

// Start does nothing in a HTTP client
// Start does nothing in a HTTP client.
func (d *client) Start(ctx context.Context) error {
// nothing to do
select {
Expand Down
8 changes: 4 additions & 4 deletions exporters/otlp/otlptrace/internal/otlpconfig/envconfig.go
Expand Up @@ -26,14 +26,14 @@ import (
"go.opentelemetry.io/otel/exporters/otlp/internal/envconfig"
)

// DefaultEnvOptionsReader is the default environments reader
// DefaultEnvOptionsReader is the default environments reader.
var DefaultEnvOptionsReader = envconfig.EnvOptionsReader{
GetEnv: os.Getenv,
ReadFile: ioutil.ReadFile,
Namespace: "OTEL_EXPORTER_OTLP",
}

// ApplyGRPCEnvConfigs applies the env configurations for gRPC
// ApplyGRPCEnvConfigs applies the env configurations for gRPC.
func ApplyGRPCEnvConfigs(cfg Config) Config {
opts := getOptionsFromEnv()
for _, opt := range opts {
Expand All @@ -42,7 +42,7 @@ func ApplyGRPCEnvConfigs(cfg Config) Config {
return cfg
}

// ApplyHTTPEnvConfigs applies the env configurations for HTTP
// ApplyHTTPEnvConfigs applies the env configurations for HTTP.
func ApplyHTTPEnvConfigs(cfg Config) Config {
opts := getOptionsFromEnv()
for _, opt := range opts {
Expand Down Expand Up @@ -113,7 +113,7 @@ func withEndpointForGRPC(u *url.URL) func(cfg Config) Config {
}
}

// WithEnvCompression retrieves the specified config and passes it to ConfigFn as a Compression
// WithEnvCompression retrieves the specified config and passes it to ConfigFn as a Compression.
func WithEnvCompression(n string, fn func(Compression)) func(e *envconfig.EnvOptionsReader) {
return func(e *envconfig.EnvOptionsReader) {
if v, ok := e.GetEnvValue(n); ok {
Expand Down
Expand Up @@ -37,7 +37,7 @@ const (
GzipCompression
)

// Marshaler describes the kind of message format sent to the collector
// Marshaler describes the kind of message format sent to the collector.
type Marshaler int

const (
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/otlptrace/otlptracegrpc/client_test.go
Expand Up @@ -167,7 +167,7 @@ func TestNewInvokeStartThenStopManyTimes(t *testing.T) {
}
}

// This test takes a long time to run: to skip it, run tests using: -short
// This test takes a long time to run: to skip it, run tests using: -short.
func TestNewCollectorOnBadConnection(t *testing.T) {
if testing.Short() {
t.Skipf("Skipping this long running test")
Expand Down
Expand Up @@ -150,7 +150,7 @@ func (mc *mockCollector) getHeaders() metadata.MD {
return mc.traceSvc.getHeaders()
}

// runMockCollector is a helper function to create a mock Collector
// runMockCollector is a helper function to create a mock Collector.
func runMockCollector(t *testing.T) *mockCollector {
return runMockCollectorAtEndpoint(t, "localhost:0")
}
Expand Down
2 changes: 1 addition & 1 deletion exporters/otlp/otlptrace/otlptracehttp/client.go
Expand Up @@ -100,7 +100,7 @@ func NewClient(opts ...Option) otlptrace.Client {
}
}

// Start does nothing in a HTTP client
// Start does nothing in a HTTP client.
func (d *client) Start(ctx context.Context) error {
// nothing to do
select {
Expand Down
2 changes: 1 addition & 1 deletion exporters/prometheus/sanitize.go
Expand Up @@ -40,7 +40,7 @@ func sanitize(s string) string {
return s
}

// converts anything that is not a letter or digit to an underscore
// converts anything that is not a letter or digit to an underscore.
func sanitizeRune(r rune) rune {
if unicode.IsLetter(r) || unicode.IsDigit(r) {
return r
Expand Down
6 changes: 3 additions & 3 deletions exporters/zipkin/env.go
Expand Up @@ -16,13 +16,13 @@ package zipkin // import "go.opentelemetry.io/otel/exporters/zipkin"

import "os"

// Environment variable names
// Environment variable names.
const (
// Endpoint for Zipkin collector
// Endpoint for Zipkin collector.
envEndpoint = "OTEL_EXPORTER_ZIPKIN_ENDPOINT"
)

// envOr returns an env variable's value if it is exists or the default if not
// envOr returns an env variable's value if it is exists or the default if not.
func envOr(key, defaultValue string) string {
if v, ok := os.LookupEnv(key); ok && v != "" {
return v
Expand Down