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

Enable unused linter #2357

Merged
merged 1 commit into from
Feb 23, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ linters:
- gosimple
- staticcheck
- structcheck
- unused
- varcheck
4 changes: 0 additions & 4 deletions cli/cmd/install-sp.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import (
"github.com/spf13/cobra"
)

type installSPConfig struct {
Namespace string
}

func newCmdInstallSP() *cobra.Command {
cmd := &cobra.Command{
Use: "install-sp [flags]",
Expand Down
7 changes: 0 additions & 7 deletions cli/cmd/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ import (
"k8s.io/apimachinery/pkg/util/validation"
)

type templateConfig struct {
ControlPlaneNamespace string
ServiceNamespace string
ServiceName string
ClusterZone string
}

type profileOptions struct {
name string
namespace string
Expand Down
1 change: 0 additions & 1 deletion cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (

const (
defaultNamespace = "linkerd"
lineWidth = 80
)

var (
Expand Down
2 changes: 0 additions & 2 deletions cli/cmd/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ type routeRowStats struct {
actualSuccessRate float64
}

const defaultRoute = "[UNKNOWN]"

func newRoutesOptions() *routesOptions {
return &routesOptions{
statOptionsBase: *newStatOptionsBase(),
Expand Down
7 changes: 0 additions & 7 deletions cli/cmd/top.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,13 +571,6 @@ func (t *topTable) renderHeaders() {
}
}

func max(i, j int) int {
if i > j {
return i
}
return j
}

func (t *topTable) adjustColumnWidths() {
for i, col := range t.columns {
if !col.flexible {
Expand Down
7 changes: 3 additions & 4 deletions cli/cmd/uninject_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ import (
func TestUninjectYAML(t *testing.T) {

testCases := []struct {
inputFileName string
goldenFileName string
reportFileName string
testInjectOptions *injectOptions
inputFileName string
goldenFileName string
reportFileName string
}{
{
inputFileName: "inject_emojivoto_deployment.golden.yml",
Expand Down
4 changes: 0 additions & 4 deletions cni-plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,3 @@ func cmdDel(args *skel.CmdArgs) error {
logrus.Info("linkerd-cni: cmdDel not implemented")
return nil
}

func cmdGet(args *skel.CmdArgs) error {
return fmt.Errorf("linkerd-cni: cmdGet not implemented")
}
7 changes: 0 additions & 7 deletions controller/api/destination/endpoint_listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type podExpected struct {
pod string
namespace string
replicationController string
phase v1.PodPhase
}

var (
addedAddress1 = &net.TcpAddress{
Ip: &net.IPAddress{Ip: &net.IPAddress_Ipv4{Ipv4: 1}},
Expand Down
3 changes: 1 addition & 2 deletions controller/api/destination/endpoints_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import (
)

const (
kubeSystem = "kube-system"
endpointResource = "endpoints"
kubeSystem = "kube-system"
)

// TODO: prom metrics for all the queues/caches
Expand Down
22 changes: 0 additions & 22 deletions controller/api/public/test_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,28 +72,6 @@ func (c *MockAPIClient) SelfCheck(ctx context.Context, in *healthcheckPb.SelfChe
return c.SelfCheckResponseToReturn, c.ErrorToReturn
}

type mockAPITapClient struct {
TapEventsToReturn []pb.TapEvent
ErrorsToReturn []error
grpc.ClientStream
}

func (a *mockAPITapClient) Recv() (*pb.TapEvent, error) {
var eventPopped pb.TapEvent
var errorPopped error
if len(a.TapEventsToReturn) == 0 && len(a.ErrorsToReturn) == 0 {
return nil, io.EOF
}
if len(a.TapEventsToReturn) != 0 {
eventPopped, a.TapEventsToReturn = a.TapEventsToReturn[0], a.TapEventsToReturn[1:]
}
if len(a.ErrorsToReturn) != 0 {
errorPopped, a.ErrorsToReturn = a.ErrorsToReturn[0], a.ErrorsToReturn[1:]
}

return &eventPopped, errorPopped
}

// MockAPITapByResourceClient satisfies the TapByResourceClient gRPC interface.
type MockAPITapByResourceClient struct {
TapEventsToReturn []pb.TapEvent
Expand Down
10 changes: 0 additions & 10 deletions controller/api/public/top_routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,6 @@ type topRoutesExpected struct {
expectedResponse pb.TopRoutesResponse // the routes response we expect
}

func genEmptyTopRoutesResponse() pb.TopRoutesResponse {
return pb.TopRoutesResponse{
Response: &pb.TopRoutesResponse_Ok_{
Ok: &pb.TopRoutesResponse_Ok{
Routes: []*pb.RouteTable{},
},
},
}
}

func routesMetric(routes []string) model.Vector {
samples := make(model.Vector, 0)
for _, route := range routes {
Expand Down
18 changes: 0 additions & 18 deletions controller/proxy-injector/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/linkerd/linkerd2/controller/proxy-injector/fake"
"github.com/linkerd/linkerd2/pkg/k8s"
admissionv1beta1 "k8s.io/api/admission/v1beta1"
corev1 "k8s.io/api/core/v1"
)

Expand Down Expand Up @@ -180,20 +179,3 @@ func TestVolumesSpec(t *testing.T) {
t.Errorf("Content mismatch\nExpected: %+v\nActual: %+v", expectedLinkerdSecrets, actualLinkerdSecrets)
}
}

func assertEqualAdmissionReview(t *testing.T, expected, actual *admissionv1beta1.AdmissionReview) {
if !reflect.DeepEqual(expected.Request, actual.Request) {
if !reflect.DeepEqual(expected.Request.Object, actual.Request.Object) {
t.Errorf("Request object mismatch\nExpected: %s\nActual: %s", expected.Request.Object, actual.Request.Object)
} else {
t.Errorf("Request mismatch\nExpected: %+v\nActual: %+v", expected.Request, actual.Request)
}
}

if !reflect.DeepEqual(expected.Response, actual.Response) {
if actual.Response.Result != nil {
t.Errorf("Actual response message: %s", actual.Response.Result.Message)
}
t.Errorf("Response patch mismatch\nExpected: %s\nActual: %s", expected.Response.Patch, actual.Response.Patch)
}
}
8 changes: 0 additions & 8 deletions pkg/healthcheck/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@ import (
pb "github.com/linkerd/linkerd2/controller/gen/public"
)

func createMockPublicAPI(version string) *public.MockAPIClient {
return &public.MockAPIClient{
VersionInfoToReturn: &pb.VersionInfo{
ReleaseVersion: version,
},
}
}

func TestGetServerVersion(t *testing.T) {
t.Run("Returns existing version from server", func(t *testing.T) {
expectedServerVersion := "1.2.3"
Expand Down