Skip to content

Commit

Permalink
Redundant import aliases that can be omitted
Browse files Browse the repository at this point in the history
Redundant type declaration in composite literals
Type can be omitted
Unused global variables
Unused import
Name starts with package name
Rename public function
Imported package name as name identifier
  • Loading branch information
Vitalii Chepeliuk committed Mar 23, 2018
1 parent b8e65ee commit d960552
Show file tree
Hide file tree
Showing 63 changed files with 519 additions and 524 deletions.
4 changes: 2 additions & 2 deletions pkg/apis/mobile/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ var (
// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&MobileClient{},
&MobileClientList{},
&Client{},
&ClientList{},
)
return nil
}
12 changes: 6 additions & 6 deletions pkg/apis/mobile/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package mobile

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

// MobileClientList is a list of MobileClient objects.
type MobileClientList struct {
// ClientList is a list of Client objects.
type ClientList struct {
metav1.TypeMeta
metav1.ListMeta

Items []MobileClient
Items []Client
}

type MobileClientSpec struct {
type ClientSpec struct {
Name string
ApiKey string
ClientType string
Expand All @@ -19,9 +19,9 @@ type MobileClientSpec struct {

// +genclient

type MobileClient struct {
type Client struct {
metav1.TypeMeta
metav1.ObjectMeta

Spec MobileClientSpec
Spec ClientSpec
}
5 changes: 5 additions & 0 deletions pkg/apis/mobile/v1alpha1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ func addKnownTypes(scheme *runtime.Scheme) error {
return nil
}

// Kind takes an unqualified kind and returns back a Group qualified GroupKind
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}

// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/servicecatalog/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func Resource(resource string) schema.GroupResource {
var (
// SchemeBuilder needs to be exported as `SchemeBuilder` so
// the code-generation can find it.
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
localSchemeBuilder = &SchemeBuilder
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)

// AddToScheme is exposed for API installation
AddToScheme = SchemeBuilder.AddToScheme
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/servicecatalog/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ const (

// These are internal finalizer values to service catalog, must be qualified name.
const (
FinalizerServiceCatalog string = "kubernetes-incubator/service-catalog"
FinalizerServiceCatalog = "kubernetes-incubator/service-catalog"
)

// ServiceBindingPropertiesState is the state of a
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/servicecatalog/v1beta1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ func Resource(resource string) schema.GroupResource {
var (
// SchemeBuilder needs to be exported as `SchemeBuilder` so
// the code-generation can find it.
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
localSchemeBuilder = &SchemeBuilder
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)

// AddToScheme is exposed for API installation
AddToScheme = SchemeBuilder.AddToScheme
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/servicecatalog/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ const (

// These are external finalizer values to service catalog, must be qualified name.
const (
FinalizerServiceCatalog string = "kubernetes-incubator/service-catalog"
FinalizerServiceCatalog = "kubernetes-incubator/service-catalog"
)

// ServiceBindingPropertiesState is the state of a
Expand Down
8 changes: 4 additions & 4 deletions pkg/client/mobile/clientset/internalversion/clientset.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ package internalversion

import (
mobileinternalversion "github.com/aerogear/mobile-cli/pkg/client/mobile/clientset/internalversion/typed/mobile/internalversion"
glog "github.com/golang/glog"
discovery "k8s.io/client-go/discovery"
rest "k8s.io/client-go/rest"
flowcontrol "k8s.io/client-go/util/flowcontrol"
"github.com/golang/glog"
"k8s.io/client-go/discovery"
"k8s.io/client-go/rest"
"k8s.io/client-go/util/flowcontrol"
)

type Interface interface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import (
"k8s.io/client-go/testing"
)

// NewSimpleClientset returns a clientset that will respond with the provided objects.
// NewSimpleClientSet returns a clientset that will respond with the provided objects.
// It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
// without applying any validations and/or defaults. It shouldn't be considered a replacement
// for a real clientset and is mostly useful in simple unit tests.
func NewSimpleClientset(objects ...runtime.Object) *Clientset {
func NewSimpleClientSet(objects ...runtime.Object) *Clientset {
o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder())
for _, obj := range objects {
if err := o.Add(obj); err != nil {
Expand Down Expand Up @@ -60,7 +60,7 @@ func (c *Clientset) Discovery() discovery.DiscoveryInterface {

var _ clientset.Interface = &Clientset{}

// Mobile retrieves the MobileClient
// Mobile retrieves the Client
func (c *Clientset) Mobile() mobileinternalversion.MobileInterface {
return &fakemobileinternalversion.FakeMobile{Fake: &c.Fake}
return &fakemobileinternalversion.Mobile{Fake: &c.Fake}
}
9 changes: 4 additions & 5 deletions pkg/client/mobile/clientset/internalversion/fake/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ package fake

import (
mobileinternalversion "github.com/aerogear/mobile-cli/pkg/apis/mobile"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer"
)

var scheme = runtime.NewScheme()
var codecs = serializer.NewCodecFactory(scheme)
var parameterCodec = runtime.NewParameterCodec(scheme)

func init() {
v1.AddToGroupVersion(scheme, schema.GroupVersion{Version: "v1"})
Expand Down
14 changes: 7 additions & 7 deletions pkg/client/mobile/clientset/internalversion/scheme/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ package scheme

import (
mobile "github.com/aerogear/mobile-cli/pkg/apis/mobile/install"
announced "k8s.io/apimachinery/pkg/apimachinery/announced"
registered "k8s.io/apimachinery/pkg/apimachinery/registered"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
schema "k8s.io/apimachinery/pkg/runtime/schema"
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
os "os"
"k8s.io/apimachinery/pkg/apimachinery/announced"
"k8s.io/apimachinery/pkg/apimachinery/registered"
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/serializer"
"os"
)

var Scheme = runtime.NewScheme()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ limitations under the License.
package fake

import (
internalversion "github.com/aerogear/mobile-cli/pkg/client/mobile/clientset/internalversion/typed/mobile/internalversion"
rest "k8s.io/client-go/rest"
testing "k8s.io/client-go/testing"
"github.com/aerogear/mobile-cli/pkg/client/mobile/clientset/internalversion/typed/mobile/internalversion"
"k8s.io/client-go/rest"
"k8s.io/client-go/testing"
)

type FakeMobile struct {
type Mobile struct {
*testing.Fake
}

func (c *FakeMobile) MobileClients(namespace string) internalversion.MobileClientInterface {
return &FakeMobileClients{c, namespace}
func (c *Mobile) MobileClients(namespace string) internalversion.MobileClientInterface {
return &MobileClients{c, namespace}
}

// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeMobile) RESTClient() rest.Interface {
func (c *Mobile) RESTClient() rest.Interface {
var ret *rest.RESTClient
return ret
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,40 @@ limitations under the License.
package fake

import (
mobile "github.com/aerogear/mobile-cli/pkg/apis/mobile"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
schema "k8s.io/apimachinery/pkg/runtime/schema"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
testing "k8s.io/client-go/testing"
"github.com/aerogear/mobile-cli/pkg/apis/mobile"
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/testing"
)

// FakeMobileClients implements MobileClientInterface
type FakeMobileClients struct {
Fake *FakeMobile
// MobileClients implements MobileClientInterface
type MobileClients struct {
Fake *Mobile
ns string
}

var mobileclientsResource = schema.GroupVersionResource{Group: "mobile.k8s.io", Version: "", Resource: "mobileclients"}

var mobileclientsKind = schema.GroupVersionKind{Group: "mobile.k8s.io", Version: "", Kind: "MobileClient"}
var mobileclientsKind = schema.GroupVersionKind{Group: "mobile.k8s.io", Version: "", Kind: "Client"}

// Get takes name of the mobileClient, and returns the corresponding mobileClient object, and an error if there is any.
func (c *FakeMobileClients) Get(name string, options v1.GetOptions) (result *mobile.MobileClient, err error) {
func (c *MobileClients) Get(name string, options v1.GetOptions) (result *mobile.Client, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(mobileclientsResource, c.ns, name), &mobile.MobileClient{})
Invokes(testing.NewGetAction(mobileclientsResource, c.ns, name), &mobile.Client{})

if obj == nil {
return nil, err
}
return obj.(*mobile.MobileClient), err
return obj.(*mobile.Client), err
}

// List takes label and field selectors, and returns the list of MobileClients that match those selectors.
func (c *FakeMobileClients) List(opts v1.ListOptions) (result *mobile.MobileClientList, err error) {
func (c *MobileClients) List(opts v1.ListOptions) (result *mobile.ClientList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(mobileclientsResource, mobileclientsKind, c.ns, opts), &mobile.MobileClientList{})
Invokes(testing.NewListAction(mobileclientsResource, mobileclientsKind, c.ns, opts), &mobile.ClientList{})

if obj == nil {
return nil, err
Expand All @@ -60,8 +60,8 @@ func (c *FakeMobileClients) List(opts v1.ListOptions) (result *mobile.MobileClie
if label == nil {
label = labels.Everything()
}
list := &mobile.MobileClientList{}
for _, item := range obj.(*mobile.MobileClientList).Items {
list := &mobile.ClientList{}
for _, item := range obj.(*mobile.ClientList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
Expand All @@ -70,57 +70,57 @@ func (c *FakeMobileClients) List(opts v1.ListOptions) (result *mobile.MobileClie
}

// Watch returns a watch.Interface that watches the requested mobileClients.
func (c *FakeMobileClients) Watch(opts v1.ListOptions) (watch.Interface, error) {
func (c *MobileClients) Watch(opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(mobileclientsResource, c.ns, opts))

}

// Create takes the representation of a mobileClient and creates it. Returns the server's representation of the mobileClient, and an error, if there is any.
func (c *FakeMobileClients) Create(mobileClient *mobile.MobileClient) (result *mobile.MobileClient, err error) {
func (c *MobileClients) Create(mobileClient *mobile.Client) (result *mobile.Client, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(mobileclientsResource, c.ns, mobileClient), &mobile.MobileClient{})
Invokes(testing.NewCreateAction(mobileclientsResource, c.ns, mobileClient), &mobile.Client{})

if obj == nil {
return nil, err
}
return obj.(*mobile.MobileClient), err
return obj.(*mobile.Client), err
}

// Update takes the representation of a mobileClient and updates it. Returns the server's representation of the mobileClient, and an error, if there is any.
func (c *FakeMobileClients) Update(mobileClient *mobile.MobileClient) (result *mobile.MobileClient, err error) {
func (c *MobileClients) Update(mobileClient *mobile.Client) (result *mobile.Client, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(mobileclientsResource, c.ns, mobileClient), &mobile.MobileClient{})
Invokes(testing.NewUpdateAction(mobileclientsResource, c.ns, mobileClient), &mobile.Client{})

if obj == nil {
return nil, err
}
return obj.(*mobile.MobileClient), err
return obj.(*mobile.Client), err
}

// Delete takes name of the mobileClient and deletes it. Returns an error if one occurs.
func (c *FakeMobileClients) Delete(name string, options *v1.DeleteOptions) error {
func (c *MobileClients) Delete(name string, options *v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(mobileclientsResource, c.ns, name), &mobile.MobileClient{})
Invokes(testing.NewDeleteAction(mobileclientsResource, c.ns, name), &mobile.Client{})

return err
}

// DeleteCollection deletes a collection of objects.
func (c *FakeMobileClients) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
func (c *MobileClients) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(mobileclientsResource, c.ns, listOptions)

_, err := c.Fake.Invokes(action, &mobile.MobileClientList{})
_, err := c.Fake.Invokes(action, &mobile.ClientList{})
return err
}

// Patch applies the patch and returns the patched mobileClient.
func (c *FakeMobileClients) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *mobile.MobileClient, err error) {
func (c *MobileClients) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *mobile.Client, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(mobileclientsResource, c.ns, name, data, subresources...), &mobile.MobileClient{})
Invokes(testing.NewPatchSubresourceAction(mobileclientsResource, c.ns, name, data, subresources...), &mobile.Client{})

if obj == nil {
return nil, err
}
return obj.(*mobile.MobileClient), err
return obj.(*mobile.Client), err
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ package internalversion

import (
"github.com/aerogear/mobile-cli/pkg/client/mobile/clientset/internalversion/scheme"
rest "k8s.io/client-go/rest"
"k8s.io/client-go/rest"
)

type MobileInterface interface {
RESTClient() rest.Interface
MobileClientsGetter
}

// MobileClient is used to interact with features provided by the mobile.k8s.io group.
// Client is used to interact with features provided by the mobile.k8s.io group.
type MobileClient struct {
restClient rest.Interface
}
Expand All @@ -35,7 +35,7 @@ func (c *MobileClient) MobileClients(namespace string) MobileClientInterface {
return newMobileClients(c, namespace)
}

// NewForConfig creates a new MobileClient for the given config.
// NewForConfig creates a new Client for the given config.
func NewForConfig(c *rest.Config) (*MobileClient, error) {
config := *c
if err := setConfigDefaults(&config); err != nil {
Expand All @@ -48,7 +48,7 @@ func NewForConfig(c *rest.Config) (*MobileClient, error) {
return &MobileClient{client}, nil
}

// NewForConfigOrDie creates a new MobileClient for the given config and
// NewForConfigOrDie creates a new Client for the given config and
// panics if there is an error in the config.
func NewForConfigOrDie(c *rest.Config) *MobileClient {
client, err := NewForConfig(c)
Expand All @@ -58,7 +58,7 @@ func NewForConfigOrDie(c *rest.Config) *MobileClient {
return client
}

// New creates a new MobileClient for the given RESTClient.
// New creates a new Client for the given RESTClient.
func New(c rest.Interface) *MobileClient {
return &MobileClient{c}
}
Expand Down
Loading

0 comments on commit d960552

Please sign in to comment.