Showing 1,820 of 1,820 total issues
Similar blocks of code found in 10 locations. Consider refactoring. Open
func (m *SelectBy_NamePrefix) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
i -= len(m.NamePrefix)
copy(dAtA[i:], m.NamePrefix)
i = encodeVarintWatch(dAtA, i, uint64(len(m.NamePrefix)))
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 122.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
func (m *ReplicatedService) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 122.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function updateNode
has 8 return statements (exceeds 4 allowed). Open
func updateNode(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return errors.New("node ID missing")
}
Method controller.Prepare
has 8 return statements (exceeds 4 allowed). Open
func (r *controller) Prepare(ctx context.Context) error {
if err := r.checkClosed(); err != nil {
return err
}
Function reconcileTaskState
has 8 return statements (exceeds 4 allowed). Open
func reconcileTaskState(ctx context.Context, w *worker, assignments []*api.AssignmentChange, fullSnapshot bool) error {
var (
updatedTasks []*api.Task
removedTasks []*api.Task
)
Method worker.Subscribe
has 8 return statements (exceeds 4 allowed). Open
func (w *worker) Subscribe(ctx context.Context, subscription *api.SubscriptionMessage) error {
log.G(ctx).Debugf("Received subscription %s (selector: %v)", subscription.ID, subscription.Selector)
publisher, cancel, err := w.publisherProvider.Publisher(ctx, subscription.ID)
if err != nil {
Method Resolver.get
has 8 return statements (exceeds 4 allowed). Open
func (r *Resolver) get(t interface{}, id string) string {
switch t.(type) {
case api.Node:
res, err := r.c.GetNode(r.ctx, &api.GetNodeRequest{NodeID: id})
if err != nil {
Function processIPAMOptions
has 8 return statements (exceeds 4 allowed). Open
func processIPAMOptions(cmd *cobra.Command) (*api.IPAMOptions, error) {
flags := cmd.Flags()
var ipamOpts *api.IPAMOptions
if flags.Changed("ipam-driver") {
Function ConvertResourceWatch
has 8 return statements (exceeds 4 allowed). Open
func ConvertResourceWatch(action WatchActionKind, filters []*SelectBy, kind string) ([]Event, error) {
var (
m Resource
checkFuncs []ResourceCheckFunc
)
Function ConvertExtensionWatch
has 8 return statements (exceeds 4 allowed). Open
func ConvertExtensionWatch(action WatchActionKind, filters []*SelectBy) ([]Event, error) {
var (
m Extension
checkFuncs []ExtensionCheckFunc
)
Function ConvertSecretWatch
has 8 return statements (exceeds 4 allowed). Open
func ConvertSecretWatch(action WatchActionKind, filters []*SelectBy) ([]Event, error) {
var (
m Secret
checkFuncs []SecretCheckFunc
)
Function ConvertClusterWatch
has 8 return statements (exceeds 4 allowed). Open
func ConvertClusterWatch(action WatchActionKind, filters []*SelectBy) ([]Event, error) {
var (
m Cluster
checkFuncs []ClusterCheckFunc
)
Function ConvertServiceWatch
has 8 return statements (exceeds 4 allowed). Open
func ConvertServiceWatch(action WatchActionKind, filters []*SelectBy) ([]Event, error) {
var (
m Service
checkFuncs []ServiceCheckFunc
)
Function ConvertConfigWatch
has 8 return statements (exceeds 4 allowed). Open
func ConvertConfigWatch(action WatchActionKind, filters []*SelectBy) ([]Event, error) {
var (
m Config
checkFuncs []ConfigCheckFunc
)
Function ConvertVolumeWatch
has 8 return statements (exceeds 4 allowed). Open
func ConvertVolumeWatch(action WatchActionKind, filters []*SelectBy) ([]Event, error) {
var (
m Volume
checkFuncs []VolumeCheckFunc
)
Function ConvertNetworkWatch
has 8 return statements (exceeds 4 allowed). Open
func ConvertNetworkWatch(action WatchActionKind, filters []*SelectBy) ([]Event, error) {
var (
m Network
checkFuncs []NetworkCheckFunc
)
Method raftProxyDispatcherServer.Tasks
has 8 return statements (exceeds 4 allowed). Open
func (p *raftProxyDispatcherServer) Tasks(r *TasksRequest, stream Dispatcher_TasksServer) error {
ctx := stream.Context()
conn, err := p.connSelector.LeaderConn(ctx)
if err != nil {
if err == raftselector.ErrIsLeader {
Method raftProxyLogBrokerServer.ListenSubscriptions
has 8 return statements (exceeds 4 allowed). Open
func (p *raftProxyLogBrokerServer) ListenSubscriptions(r *ListenSubscriptionsRequest, stream LogBroker_ListenSubscriptionsServer) error {
ctx := stream.Context()
conn, err := p.connSelector.LeaderConn(ctx)
if err != nil {
if err == raftselector.ErrIsLeader {
Method raftProxyDispatcherServer.Session
has 8 return statements (exceeds 4 allowed). Open
func (p *raftProxyDispatcherServer) Session(r *SessionRequest, stream Dispatcher_SessionServer) error {
ctx := stream.Context()
conn, err := p.connSelector.LeaderConn(ctx)
if err != nil {
if err == raftselector.ErrIsLeader {
Function sanitizeResource
has 8 return statements (exceeds 4 allowed). Open
func sanitizeResource(nodeRes []*api.GenericResource, res *api.GenericResource) (ok bool, nrs []*api.GenericResource) {
switch na := res.Resource.(type) {
case *api.GenericResource_DiscreteResourceSpec:
nrs := GetResource(na.DiscreteResourceSpec.Kind, nodeRes)