Showing 51 of 51 total issues
Method job.Process
has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring. Open
func (p job) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstructured) (bool, helmify.Template, error) {
if obj.GroupVersionKind() != jobGVC {
return false, nil, nil
}
meta, err := processor.ProcessObjMeta(appMeta, obj)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method cron.Process
has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring. Open
func (p cron) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstructured) (bool, helmify.Template, error) {
if obj.GroupVersionKind() != cronGVC {
return false, nil, nil
}
meta, err := processor.ProcessObjMeta(appMeta, obj)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method crd.Process
has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring. Open
func (c crd) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstructured) (bool, helmify.Template, error) {
if obj.GroupVersionKind() != crdGVC {
return false, nil, nil
}
name, ok, err := unstructured.NestedString(obj.Object, "spec", "names", "singular")
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method deployment.Process
has 13 return statements (exceeds 4 allowed). Open
func (d deployment) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstructured) (bool, helmify.Template, error) {
if obj.GroupVersionKind() != deploymentGVC {
return false, nil, nil
}
depl := appsv1.Deployment{}
Function processPodContainer
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
func processPodContainer(name string, appMeta helmify.AppMetadata, c corev1.Container, values *helmify.Values) (corev1.Container, error) {
index := strings.LastIndex(c.Image, ":")
if strings.Contains(c.Image, "@") && strings.Count(c.Image, ":") >= 2 {
last := strings.LastIndex(c.Image, ":")
index = strings.LastIndex(c.Image[:last], ":")
Method pvc.Process
has 11 return statements (exceeds 4 allowed). Open
func (p pvc) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstructured) (bool, helmify.Template, error) {
if obj.GroupVersionKind() != pvcGVC {
return false, nil, nil
}
meta, err := processor.ProcessObjMeta(appMeta, obj)
Method daemonset.Process
has 11 return statements (exceeds 4 allowed). Open
func (d daemonset) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstructured) (bool, helmify.Template, error) {
if obj.GroupVersionKind() != daemonsetGVC {
return false, nil, nil
}
dae := appsv1.DaemonSet{}
Method svc.Process
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (r svc) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstructured) (bool, helmify.Template, error) {
if obj.GroupVersionKind() != svcGVC {
return false, nil, nil
}
service := corev1.Service{}
Function Start
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
func Start(stdin io.Reader, config config.Config) error {
err := config.Validate()
if err != nil {
return err
}
Method crd.Process
has 9 return statements (exceeds 4 allowed). Open
func (c crd) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstructured) (bool, helmify.Template, error) {
if obj.GroupVersionKind() != crdGVC {
return false, nil, nil
}
name, ok, err := unstructured.NestedString(obj.Object, "spec", "names", "singular")
Method secret.Process
has 9 return statements (exceeds 4 allowed). Open
func (d secret) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstructured) (bool, helmify.Template, error) {
if obj.GroupVersionKind() != configMapGVC {
return false, nil, nil
}
sec := corev1.Secret{}
Function ProcessSpec
has 8 return statements (exceeds 4 allowed). Open
func ProcessSpec(objName string, appMeta helmify.AppMetadata, spec corev1.PodSpec) (map[string]interface{}, helmify.Values, error) {
values, err := processPodSpec(objName, appMeta, &spec)
if err != nil {
return nil, nil, err
}
Function processPodContainer
has 8 return statements (exceeds 4 allowed). Open
func processPodContainer(name string, appMeta helmify.AppMetadata, c corev1.Container, values *helmify.Values) (corev1.Container, error) {
index := strings.LastIndex(c.Image, ":")
if strings.Contains(c.Image, "@") && strings.Count(c.Image, ":") >= 2 {
last := strings.LastIndex(c.Image, ":")
index = strings.LastIndex(c.Image[:last], ":")
Method output.Create
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
func (o output) Create(chartDir, chartName string, crd bool, certManagerAsSubchart bool, certManagerVersion string, templates []helmify.Template, filenames []string) error {
Similar blocks of code found in 2 locations. Consider refactoring. Open
for key := range sec.Data {
keyCamelCase := strcase.ToLowerCamel(key)
if key == strings.ToUpper(key) {
keyCamelCase = strcase.ToLowerCamel(strings.ToLower(key))
}
- 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 113.
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
for key := range sec.StringData {
keyCamelCase := strcase.ToLowerCamel(key)
if key == strings.ToUpper(key) {
keyCamelCase = strcase.ToLowerCamel(strings.ToLower(key))
}
- 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 113.
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
Method clusterRoleBinding.Process
has 6 return statements (exceeds 4 allowed). Open
func (r clusterRoleBinding) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstructured) (bool, helmify.Template, error) {
if obj.GroupVersionKind() != clusterRoleBindingGVC {
return false, nil, nil
}
Method role.Process
has 6 return statements (exceeds 4 allowed). Open
func (r role) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstructured) (bool, helmify.Template, error) {
var aggregationRule string
if obj.GroupVersionKind() != clusterRoleGVC && obj.GroupVersionKind() != roleGVC {
return false, nil, nil
Function processContainers
has 6 return statements (exceeds 4 allowed). Open
func processContainers(objName string, values helmify.Values, containerType string, containers []interface{}) ([]interface{}, helmify.Values, error) {
for i := range containers {
containerName := strcase.ToLowerCamel((containers[i].(map[string]interface{})["name"]).(string))
res, exists, err := unstructured.NestedMap(values, objName, containerName, "resources")
if err != nil {
Method pdb.Process
has 6 return statements (exceeds 4 allowed). Open
func (r pdb) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstructured) (bool, helmify.Template, error) {
if obj.GroupVersionKind() != pdbGVC {
return false, nil, nil
}
pdb := policyv1.PodDisruptionBudget{}