Showing 59 of 59 total issues
Similar blocks of code found in 3 locations. Consider refactoring. Open
func (c *PodDisruptionBudget) Get(ctx context.Context, namespace, name string) (*policyv1beta1.PodDisruptionBudget, error) {
ctx, cancel := context.WithTimeout(ctx, k8sTimeout)
defer cancel()
return c.clientSet.PolicyV1beta1().PodDisruptionBudgets(namespace).Get(ctx, name, metav1.GetOptions{})
- 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 108.
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 (c *StatefulSet) Get(ctx context.Context, namespace, name string) (*appsv1.StatefulSet, error) {
ctx, cancel := context.WithTimeout(ctx, k8sTimeout)
defer cancel()
return c.clientSet.AppsV1().StatefulSets(namespace).Get(ctx, name, metav1.GetOptions{})
- 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 108.
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 do
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func do(ctx context.Context, client *http.Client, method string, uri string, body interface{}) error {
Function NewGetter
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
logger lager.Logger,
statefulSetGetter StatefulSetByLRPIdentifierGetter,
podGetter PodGetter,
eventGetter EventGetter,
statefulsetToLrpConverter StatefulSetToLRPConverter,
Method Executor.migrateObjects
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func (e *Executor) migrateObjects(ctx context.Context, logger lager.Logger, objects []runtime.Object, objectType ObjectType, setAnnotationFn func(context.Context, runtime.Object, int) error) error {
Function NewDesirer
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
logger lager.Logger,
secrets SecretsClient,
statefulSets StatefulSetCreator,
lrpToStatefulSetConverter LRPToStatefulSetConverter,
podDisruptionBudgetCreator PodDisruptionBudgetUpdater,
Method Executor.Migrate
has 5 return statements (exceeds 4 allowed). Open
func (e *Executor) Migrate(ctx context.Context, logger lager.Logger) error {
logger.Info("migration-start")
defer logger.Info("migration-end")
if err := e.verifySequenceIDs(); err != nil {
Method AdoptPDB.Apply
has 5 return statements (exceeds 4 allowed). Open
func (m AdoptPDB) Apply(ctx context.Context, obj runtime.Object) error {
stSet, ok := obj.(*appsv1.StatefulSet)
if !ok {
return fmt.Errorf("expected *v1.StatefulSet, got: %T", obj)
}
Function Fetch
has 5 return statements (exceeds 4 allowed). Open
func Fetch(dockerRef string, sysCtx types.SystemContext) (*v1.ImageConfig, error) {
ref, err := docker.ParseReference(dockerRef)
if err != nil {
return nil, errors.Wrap(err, "failed to parse docker reference")
}
Method InstanceIndexEnvInjector.Handle
has 5 return statements (exceeds 4 allowed). Open
func (i *InstanceIndexEnvInjector) Handle(ctx context.Context, req admission.Request) admission.Response {
logger := i.logger.Session("handle-webhook-request")
if req.Operation != admissionv1.Create {
return admission.Allowed("pod was already created")
Function do
has 5 return statements (exceeds 4 allowed). Open
func do(ctx context.Context, client *http.Client, method string, uri string, body interface{}) error {
bodyJSON, err := json.Marshal(body)
if err != nil {
return errors.Wrap(err, "cannot marshal body")
}
Method Stopper.StopInstance
has 5 return statements (exceeds 4 allowed). Open
func (s *Stopper) StopInstance(ctx context.Context, identifier api.LRPIdentifier, index uint) error {
logger := s.logger.Session("stopInstance", lager.Data{"guid": identifier.GUID, "version": identifier.Version, "index": index})
statefulset, err := s.getStatefulSet(ctx, identifier)
if errors.Is(err, eirini.ErrNotFound) {
Method Desirer.Desire
has 5 return statements (exceeds 4 allowed). Open
func (d *Desirer) Desire(ctx context.Context, namespace string, task *api.Task, opts ...shared.Option) error {
logger := d.logger.Session("desire-task", lager.Data{"guid": task.GUID, "name": task.Name, "namespace": namespace})
var (
err error
Method RetryableJSONClient.Post
has 5 return statements (exceeds 4 allowed). Open
func (c *RetryableJSONClient) Post(ctx context.Context, url string, data interface{}) error {
jsonBody, err := json.Marshal(data)
if err != nil {
return errors.Wrap(err, "failed to marshal json body")
}
Method Updater.update
has 5 return statements (exceeds 4 allowed). Open
func (u *Updater) update(ctx context.Context, lrp *api.LRP) error {
logger := u.logger.Session("update", lager.Data{"guid": lrp.GUID, "version": lrp.Version})
statefulSet, err := u.getStatefulSet(ctx, api.LRPIdentifier{GUID: lrp.GUID, Version: lrp.Version})
if err != nil {
Method Getter.GetInstances
has 5 return statements (exceeds 4 allowed). Open
func (g *Getter) GetInstances(ctx context.Context, identifier api.LRPIdentifier) ([]*api.Instance, error) {
logger := g.logger.Session("get-instance", lager.Data{"guid": identifier.GUID, "version": identifier.Version})
if _, err := g.getLRP(ctx, logger, identifier); errors.Is(err, eirini.ErrNotFound) {
return nil, err
}
Method Executor.migrateObjects
has 5 return statements (exceeds 4 allowed). Open
func (e *Executor) migrateObjects(ctx context.Context, logger lager.Logger, objects []runtime.Object, objectType ObjectType, setAnnotationFn func(context.Context, runtime.Object, int) error) error {
logger.Info("start")
defer logger.Info("end")
for i := range objects {
Similar blocks of code found in 2 locations. Consider refactoring. Open
func (c *PodDisruptionBudget) Delete(ctx context.Context, namespace string, name string) error {
ctx, cancel := context.WithTimeout(ctx, k8sTimeout)
defer cancel()
return c.clientSet.PolicyV1beta1().PodDisruptionBudgets(namespace).Delete(ctx, name, metav1.DeleteOptions{})
- 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 103.
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 2 locations. Consider refactoring. Open
func (c *Secret) Delete(ctx context.Context, namespace string, name string) error {
ctx, cancel := context.WithTimeout(ctx, k8sTimeout)
defer cancel()
return c.clientSet.CoreV1().Secrets(namespace).Delete(ctx, name, metav1.DeleteOptions{})
- 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 103.
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