docker/docker

View on GitHub
libnetwork/drivers/macvlan/macvlan_setup.go

Summary

Maintainability
D
1 day
Test Coverage

Function createVlanLink has 7 return statements (exceeds 4 allowed).
Open

func createVlanLink(parentName string) error {
    if strings.Contains(parentName, ".") {
        parent, vidInt, err := parseVlan(parentName)
        if err != nil {
            return err
Severity: Major
Found in libnetwork/drivers/macvlan/macvlan_setup.go - About 45 mins to fix

    Function createMacVlan has 5 return statements (exceeds 4 allowed).
    Open

    func createMacVlan(containerIfName, parent, macvlanMode string) (string, error) {
        // Set the macvlan mode. Default is bridge mode
        mode, err := setMacVlanMode(macvlanMode)
        if err != nil {
            return "", fmt.Errorf("Unsupported %s macvlan mode: %v", macvlanMode, err)
    Severity: Major
    Found in libnetwork/drivers/macvlan/macvlan_setup.go - About 35 mins to fix

      Function delVlanLink has 5 return statements (exceeds 4 allowed).
      Open

      func delVlanLink(linkName string) error {
          if strings.Contains(linkName, ".") {
              _, _, err := parseVlan(linkName)
              if err != nil {
                  return err
      Severity: Major
      Found in libnetwork/drivers/macvlan/macvlan_setup.go - About 35 mins to fix

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

        func createVlanLink(parentName string) error {
            if strings.Contains(parentName, ".") {
                parent, vidInt, err := parseVlan(parentName)
                if err != nil {
                    return err
        Severity: Major
        Found in libnetwork/drivers/macvlan/macvlan_setup.go and 1 other location - About 4 hrs to fix
        libnetwork/drivers/ipvlan/ipvlan_setup.go on lines 95..130

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

        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

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

        func delVlanLink(linkName string) error {
            if strings.Contains(linkName, ".") {
                _, _, err := parseVlan(linkName)
                if err != nil {
                    return err
        Severity: Major
        Found in libnetwork/drivers/macvlan/macvlan_setup.go and 1 other location - About 2 hrs to fix
        libnetwork/drivers/ipvlan/ipvlan_setup.go on lines 133..157

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

        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

        func createDummyLink(dummyName, truncNetID string) error {
            // create a parent interface since one was not specified
            parent := &netlink.Dummy{
                LinkAttrs: netlink.LinkAttrs{
                    Name: dummyName,
        Severity: Major
        Found in libnetwork/drivers/macvlan/macvlan_setup.go and 1 other location - About 1 hr to fix
        libnetwork/drivers/ipvlan/ipvlan_setup.go on lines 181..201

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

        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

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

        func delDummyLink(linkName string) error {
            // delete the vlan subinterface
            dummyLink, err := ns.NlHandle().LinkByName(linkName)
            if err != nil {
                return fmt.Errorf("failed to find link %s on the Docker host : %v", linkName, err)
        Severity: Major
        Found in libnetwork/drivers/macvlan/macvlan_setup.go and 1 other location - About 1 hr to fix
        libnetwork/drivers/ipvlan/ipvlan_setup.go on lines 204..221

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

        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

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

        func parseVlan(linkName string) (string, int, error) {
            // parse -o parent=eth0.10
            splitName := strings.Split(linkName, ".")
            if len(splitName) != 2 {
                return "", 0, fmt.Errorf("required interface name format is: name.vlan_id, ex. eth0.10 for vlan 10, instead received %s", linkName)
        Severity: Major
        Found in libnetwork/drivers/macvlan/macvlan_setup.go and 1 other location - About 1 hr to fix
        libnetwork/drivers/ipvlan/ipvlan_setup.go on lines 160..178

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

        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

        There are no issues that match your filters.

        Category
        Status