fiunchinho/dmz-controller

View on GitHub

Showing 11 of 11 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

package repository

import (
    "k8s.io/client-go/informers"
    "k8s.io/client-go/kubernetes"
Severity: Major
Found in repository/configmap.go and 1 other location - About 3 hrs to fix
repository/ingress.go on lines 1..31

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 282.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

package repository

import (
    "k8s.io/client-go/informers"
    "k8s.io/client-go/kubernetes"
Severity: Major
Found in repository/ingress.go and 1 other location - About 3 hrs to fix
repository/configmap.go on lines 1..31

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 282.

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

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

func TestIpsAreAdded(t *testing.T) {
    ingressRepository := repository.NewFakeIngressRepository()
    configMapRepository := repository.NewFakeConfigMapRepository()
    ingressName := "namespace/my-ingress"
    ingress := BuildIngressObject().Named(ingressName).WithAnnotation(DMZProvidersAnnotation, "vpn").Build()
Severity: Major
Found in ingress_whitelister_test.go and 2 other locations - About 2 hrs to fix
ingress_whitelister_test.go on lines 62..84
ingress_whitelister_test.go on lines 143..165

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 217.

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

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

func TestThatItSkipsNonExistingProviders(t *testing.T) {
    ingressRepository := repository.NewFakeIngressRepository()
    configMapRepository := repository.NewFakeConfigMapRepository()
    ingressName := "namespace/my-ingress"
    ingress := BuildIngressObject().Named(ingressName).WithAnnotation(DMZProvidersAnnotation, "vpn,non-existing,offices").Build()
Severity: Major
Found in ingress_whitelister_test.go and 2 other locations - About 2 hrs to fix
ingress_whitelister_test.go on lines 15..37
ingress_whitelister_test.go on lines 62..84

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 217.

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

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

func TestThatAssignIpsWhenThereAreTwoIpSources(t *testing.T) {
    ingressRepository := repository.NewFakeIngressRepository()
    configMapRepository := repository.NewFakeConfigMapRepository()
    ingressName := "namespace/my-ingress"
    ingress := BuildIngressObject().Named(ingressName).WithAnnotation(DMZProvidersAnnotation, "vpn,offices").Build()
Severity: Major
Found in ingress_whitelister_test.go and 2 other locations - About 2 hrs to fix
ingress_whitelister_test.go on lines 15..37
ingress_whitelister_test.go on lines 143..165

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 217.

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

Further Reading

Function main has 79 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func main() {
    // When running as a pod in-cluster, a kubeconfig is not needed. Instead this will make use of the service account injected into the pod.
    // However, allow the use of a local kubeconfig as this can make local development & testing easier.
    kubeconfig := flag.String("kubeconfig", "", "Path to a kubeconfig file")

Severity: Major
Found in main.go - About 2 hrs to fix

    Function main has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
    Open

    func main() {
        // When running as a pod in-cluster, a kubeconfig is not needed. Instead this will make use of the service account injected into the pod.
        // However, allow the use of a local kubeconfig as this can make local development & testing easier.
        kubeconfig := flag.String("kubeconfig", "", "Path to a kubeconfig file")
    
    
    Severity: Minor
    Found in main.go - About 1 hr to fix

    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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    package repository
    
    import (
        "testing"
    
    
    Severity: Minor
    Found in repository/fake_ingress_test.go and 1 other location - About 55 mins to fix
    repository/fake_configmap_test.go on lines 1..22

    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 124.

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    package repository
    
    import (
        "testing"
    
    
    Severity: Minor
    Found in repository/fake_configmap_test.go and 1 other location - About 55 mins to fix
    repository/fake_ingress_test.go on lines 1..22

    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 124.

    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

    Further Reading

    Method IngressWhitelister.Whitelist has 5 return statements (exceeds 4 allowed).
    Open

    func (whitelister *IngressWhitelister) Whitelist(key string) error {
        namespace, name, err := cache.SplitMetaNamespaceKey(key)
        if err != nil {
            return fmt.Errorf("Error splitting meta namespace key into parts: %s", err.Error())
        }
    Severity: Major
    Found in ingress_whitelister.go - About 35 mins to fix

      2: cannot find package "github.com/fiunchinho/dmz-controller/repository" in any of:
      Open

          "github.com/fiunchinho/dmz-controller/repository"
      Severity: Minor
      Found in ingress_whitelister.go by govet
      Severity
      Category
      Status
      Source
      Language