Skip to content

Commit

Permalink
Add script that auto orders imports (#676)
Browse files Browse the repository at this point in the history
* Add script to auto order imports

Signed-off-by: Won Jun Jang <wjang@uber.com>
  • Loading branch information
black-adder authored and yurishkuro committed Feb 4, 2018
1 parent 2fb6fa5 commit fcbd210
Show file tree
Hide file tree
Showing 32 changed files with 143 additions and 46 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*.xml
*.swp
fmt.log
import.log
lint.log
cover.html
.envrc
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ GOVET=go vet
GOFMT=gofmt
FMT_LOG=fmt.log
LINT_LOG=lint.log
IMPORT_LOG=import.log

GIT_SHA=$(shell git rev-parse HEAD)
GIT_CLOSEST_TAG=$(shell git describe --abbrev=0 --tags)
Expand Down Expand Up @@ -98,6 +99,7 @@ nocover:

.PHONY: fmt
fmt:
./scripts/import-order-cleanup.sh inplace
$(GOFMT) -e -s -l -w $(ALL_SRC)
./scripts/updateLicenses.sh

Expand All @@ -109,7 +111,8 @@ lint:
@[ ! -s "$(LINT_LOG)" ] || (echo "Lint Failures" | cat - $(LINT_LOG) && false)
@$(GOFMT) -e -s -l $(ALL_SRC) > $(FMT_LOG)
@./scripts/updateLicenses.sh >> $(FMT_LOG)
@[ ! -s "$(FMT_LOG)" ] || (echo "Go fmt or license check failures, run 'make fmt'" | cat - $(FMT_LOG) && false)
@./scripts/import-order-cleanup.sh stdout > $(IMPORT_LOG)
@[ ! -s "$(FMT_LOG)" -a ! -s "$(IMPORT_LOG)" ] || (echo "Go fmt, license check, or import ordering failures, run 'make fmt'" | cat - $(FMT_LOG) && false)

.PHONY: install-glide
install-glide:
Expand Down
4 changes: 2 additions & 2 deletions cmd/agent/app/reporter/reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import (
"fmt"
"testing"

"github.com/jaegertracing/jaeger/thrift-gen/jaeger"
"github.com/jaegertracing/jaeger/thrift-gen/zipkincore"
"github.com/stretchr/testify/assert"

"github.com/jaegertracing/jaeger/cmd/agent/app/testutils"
"github.com/jaegertracing/jaeger/thrift-gen/jaeger"
"github.com/jaegertracing/jaeger/thrift-gen/zipkincore"
)

func TestMultiReporter(t *testing.T) {
Expand Down
5 changes: 2 additions & 3 deletions cmd/agent/app/servers/tbuffered_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ import (
"github.com/uber/jaeger-lib/metrics"
mTestutils "github.com/uber/jaeger-lib/metrics/testutils"

"github.com/jaegertracing/jaeger/thrift-gen/agent"
"github.com/jaegertracing/jaeger/thrift-gen/zipkincore"

"github.com/jaegertracing/jaeger/cmd/agent/app/customtransports"
"github.com/jaegertracing/jaeger/cmd/agent/app/servers/thriftudp"
"github.com/jaegertracing/jaeger/cmd/agent/app/testutils"
"github.com/jaegertracing/jaeger/thrift-gen/agent"
"github.com/jaegertracing/jaeger/thrift-gen/zipkincore"
)

func TestTBufferedServer(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions cmd/builder/builder_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"go.uber.org/zap"

"github.com/uber/jaeger-lib/metrics"
"go.uber.org/zap"
)

func TestApplyOptions(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion cmd/collector/app/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ package app
import (
"sync"

"github.com/jaegertracing/jaeger/model"
"github.com/uber/jaeger-lib/metrics"

"github.com/jaegertracing/jaeger/model"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion cmd/collector/app/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
"time"

"github.com/stretchr/testify/assert"
jaegerM "github.com/uber/jaeger-lib/metrics"

"github.com/jaegertracing/jaeger/model"
jaegerM "github.com/uber/jaeger-lib/metrics"
)

func TestProcessorMetrics(t *testing.T) {
Expand Down
5 changes: 2 additions & 3 deletions cmd/collector/app/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
package app

import (
"go.uber.org/zap"

"github.com/jaegertracing/jaeger/model"
"github.com/uber/jaeger-lib/metrics"
"go.uber.org/zap"

"github.com/jaegertracing/jaeger/cmd/collector/app/sanitizer"
"github.com/jaegertracing/jaeger/model"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion cmd/collector/app/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/uber/jaeger-lib/metrics"
"go.uber.org/zap"

"github.com/jaegertracing/jaeger/model"
"github.com/uber/jaeger-lib/metrics"
)

func TestAllOptionSet(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion cmd/collector/app/sanitizer/service_name_sanitizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ package sanitizer
import (
"testing"

"github.com/jaegertracing/jaeger/model"
"github.com/stretchr/testify/assert"

"github.com/jaegertracing/jaeger/model"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion cmd/collector/app/sanitizer/utf8_sanitizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import (
"fmt"
"unicode/utf8"

"github.com/jaegertracing/jaeger/model"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"

"github.com/jaegertracing/jaeger/model"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion cmd/collector/app/sanitizer/utf8_sanitizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import (
"encoding/hex"
"testing"

"github.com/jaegertracing/jaeger/model"
"github.com/stretchr/testify/assert"
"go.uber.org/zap"

"github.com/jaegertracing/jaeger/model"
)

func invalidUTF8() string {
Expand Down
5 changes: 2 additions & 3 deletions cmd/collector/app/span_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ import (
"github.com/uber/tchannel-go"
"go.uber.org/zap"

"github.com/jaegertracing/jaeger/model"
"github.com/jaegertracing/jaeger/storage/spanstore"

"github.com/jaegertracing/jaeger/cmd/collector/app/sanitizer"
"github.com/jaegertracing/jaeger/model"
"github.com/jaegertracing/jaeger/pkg/queue"
"github.com/jaegertracing/jaeger/storage/spanstore"
)

type spanProcessor struct {
Expand Down
3 changes: 2 additions & 1 deletion cmd/collector/app/zipkin/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import (
"fmt"
"testing"

"github.com/jaegertracing/jaeger/thrift-gen/zipkincore"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/jaegertracing/jaeger/thrift-gen/zipkincore"
)

var endpointFmt = `{"serviceName": "%s", "ipv4": "%s", "ipv6": "%s", "port": %d}`
Expand Down
2 changes: 1 addition & 1 deletion cmd/query/app/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
jaeger "github.com/uber/jaeger-client-go"
"go.uber.org/zap"

"github.com/jaegertracing/jaeger/model"
Expand All @@ -38,7 +39,6 @@ import (
depsmocks "github.com/jaegertracing/jaeger/storage/dependencystore/mocks"
"github.com/jaegertracing/jaeger/storage/spanstore"
spanstoremocks "github.com/jaegertracing/jaeger/storage/spanstore/mocks"
jaeger "github.com/uber/jaeger-client-go"
)

const millisToNanosMultiplier = int64(time.Millisecond / time.Nanosecond)
Expand Down
1 change: 0 additions & 1 deletion examples/hotrod/services/customer/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"errors"

"go.uber.org/zap"

"github.com/opentracing/opentracing-go"
tags "github.com/opentracing/opentracing-go/ext"

Expand Down
3 changes: 2 additions & 1 deletion model/converter/json/process_hashtable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ package json
import (
"testing"

"github.com/jaegertracing/jaeger/model"
"github.com/stretchr/testify/assert"

"github.com/jaegertracing/jaeger/model"
)

func TestProcessHashtable(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion model/converter/json/to_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import (
"fmt"
"strconv"

"github.com/pkg/errors"

"github.com/jaegertracing/jaeger/model"
"github.com/jaegertracing/jaeger/model/json"
"github.com/pkg/errors"
)

// SpanToDomain converts json.Span with embedded Process into model.Span format.
Expand Down
4 changes: 2 additions & 2 deletions model/converter/thrift/zipkin/to_domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import (
"time"

"github.com/kr/pretty"
"github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go/ext"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/jaegertracing/jaeger/model"
z "github.com/jaegertracing/jaeger/thrift-gen/zipkincore"
"github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go/ext"
)

const NumberOfFixtures = 3
Expand Down
3 changes: 2 additions & 1 deletion model/hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ import (
"io"
"testing"

"github.com/jaegertracing/jaeger/model"
"github.com/stretchr/testify/assert"

"github.com/jaegertracing/jaeger/model"
)

type mockHashWwiterAnswer struct {
Expand Down
3 changes: 1 addition & 2 deletions model/keyvalue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
package model_test

import (
"encoding/json"
"testing"

"github.com/stretchr/testify/assert"

"encoding/json"

"github.com/jaegertracing/jaeger/model"
)

Expand Down
5 changes: 2 additions & 3 deletions model/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@
package model_test

import (
"errors"
"hash/fnv"
"io"
"testing"

"github.com/stretchr/testify/assert"

"errors"
"github.com/stretchr/testify/require"

"github.com/jaegertracing/jaeger/model"
"github.com/stretchr/testify/require"
)

func TestProcessEqual(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions model/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@
package model

import (
"encoding/gob"
"fmt"
"io"
"strconv"
"time"

"encoding/gob"

"github.com/opentracing/opentracing-go/ext"
)

Expand Down
5 changes: 2 additions & 3 deletions model/span_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@
package model_test

import (
"bytes"
"encoding/json"
"testing"
"time"

"github.com/opentracing/opentracing-go/ext"
"github.com/stretchr/testify/assert"

"bytes"
"github.com/stretchr/testify/require"

"github.com/jaegertracing/jaeger/model"
"github.com/stretchr/testify/require"
)

type TraceIDContainer struct {
Expand Down
3 changes: 2 additions & 1 deletion pkg/cassandra/metrics/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import (
"testing"
"time"

"github.com/jaegertracing/jaeger/pkg/testutils"
"github.com/stretchr/testify/assert"
"github.com/uber/jaeger-lib/metrics"

"github.com/jaegertracing/jaeger/pkg/testutils"
)

func TestTableEmit(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/discovery/notifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
package discovery

import (
"testing"

"sync"
"testing"

"github.com/stretchr/testify/assert"
)
Expand Down
3 changes: 2 additions & 1 deletion pkg/healthcheck/internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ import (
"testing"
"time"

"github.com/jaegertracing/jaeger/pkg/testutils"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/jaegertracing/jaeger/pkg/testutils"
)

func TestHttpCall(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/queue/bounded_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@
package queue

import (
"reflect"
"sync"
"sync/atomic"
"testing"
"time"

"reflect"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/uber/jaeger-lib/metrics"
Expand Down
1 change: 0 additions & 1 deletion plugin/storage/cassandra/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/jaegertracing/jaeger/pkg/cassandra"
"github.com/jaegertracing/jaeger/pkg/cassandra/mocks"
"github.com/jaegertracing/jaeger/pkg/config"

"github.com/jaegertracing/jaeger/storage"
)

Expand Down
2 changes: 1 addition & 1 deletion plugin/storage/es/spanstore/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"github.com/uber/jaeger-lib/metrics"
"go.uber.org/zap"
"gopkg.in/olivere/elastic.v5"

Expand All @@ -31,7 +32,6 @@ import (
"github.com/jaegertracing/jaeger/pkg/es/mocks"
"github.com/jaegertracing/jaeger/pkg/testutils"
"github.com/jaegertracing/jaeger/storage/spanstore"
"github.com/uber/jaeger-lib/metrics"
)

var exampleESSpan = []byte(
Expand Down
Loading

0 comments on commit fcbd210

Please sign in to comment.