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

KubernetesClientUtil : Replace switch with if statement to improve readibility #2677

Closed
1 of 2 tasks
rohanKanojia opened this issue Feb 14, 2024 · 1 comment · Fixed by #2683
Closed
1 of 2 tasks
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Milestone

Comments

@rohanKanojia
Copy link
Member

rohanKanojia commented Feb 14, 2024

Component

JKube Kit

Task description

Description

KubernetesClientUtil seems to have this simple switch clause :

https://github.com/eclipse/jkube/blob/cc2c8a20c541c78c26f752058dc5bf334f74ff2b/jkube-kit/config/service/src/main/java/org/eclipse/jkube/kit/config/service/kubernetes/KubernetesClientUtil.java#L122-L128

As per Sonar rule S1301

Switch statements are useful when there are many different cases depending on the value of the same expression.
For just one or two cases, however, the code will be more readable with if statements.

There are no unit tests for this method, it would be nice to have two unit tests verifying both conditions.

Expected Behavior

The above code should be refactored to use if else statements.

Acceptance Criteria

  • Switch statements are replaced by if else statements
  • Unit tests added to verify method is working as expected

How to manually test my changes

Kubernetes

If you don't have a real Kubernetes cluster available (most probably), you can use Minikube or Kind to test with a local cluster.

OpenShift

If you don't have a real OpenShift cluster available (most probably), you can use Red Hat's developer Sandbox for Red Hat OpenShift. The only requirement is to have a Red Hat account.

Once you have your Sandbox environment, you'll need to download the oc tool from the cluster console.
(Press the ? icon and from the context menu select Command line tools, you'll be redirected to https://$subdomain.openshiftapps.com/command-lines-tools where you'll be able to download the CLI for your platform)

@rohanKanojia rohanKanojia added good first issue Good for newcomers help wanted Extra attention is needed labels Feb 14, 2024
@Yogeshknaik
Copy link
Contributor

im interested to work on it , can you assign this to me.!?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants