yast/yast-network

View on GitHub
src/modules/Lan.rb

Summary

Maintainability
F
5 days
Test Coverage

File Lan.rb has 577 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "yast"
require "cfa/sysctl_config"
require "network/network_autoyast"
require "network/confirm_virt_proposal"
require "network/wicked"
Severity: Major
Found in src/modules/Lan.rb - About 1 day to fix

    Class LanClass has 46 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class LanClass < Module
        include ::UI::TextHelpers
        include Wicked
    
        def main
    Severity: Minor
    Found in src/modules/Lan.rb - About 6 hrs to fix

      Method Read has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

          def Read(cache)
            if cache == :cache && @initialized
              Builtins.y2milestone("Using cached data")
              return true
            end
      Severity: Minor
      Found in src/modules/Lan.rb - About 5 hrs 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

      Method Read has 92 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def Read(cache)
            if cache == :cache && @initialized
              Builtins.y2milestone("Using cached data")
              return true
            end
      Severity: Major
      Found in src/modules/Lan.rb - About 3 hrs to fix

        Method Write has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

            def Write(gui: true, apply_config: !write_only)
              log.info("Writing configuration")
        
              # Query modified flag in all components
              if !Modified()
        Severity: Minor
        Found in src/modules/Lan.rb - About 3 hrs 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

        Method Write has 75 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def Write(gui: true, apply_config: !write_only)
              log.info("Writing configuration")
        
              # Query modified flag in all components
              if !Modified()
        Severity: Major
        Found in src/modules/Lan.rb - About 3 hrs to fix

          Method Packages has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def Packages
                backend = if Mode.autoinst
                  Y2Network::Backend.all.find { |b| b.id == proposal_settings.current_backend }
                else
                  yast_config&.backend
          Severity: Minor
          Found in src/modules/Lan.rb - 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

          Method main has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def main
                Yast.import "UI"
                textdomain "network"
          
                Yast.import "Arch"
          Severity: Minor
          Found in src/modules/Lan.rb - About 1 hr to fix

            Method writeIPv6 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def writeIPv6
                  log.info("writeIPv6: IPv6 is #{@ipv6 ? "enabled" : "disabled"}")
                  sysctl_config_file = CFA::SysctlConfig.new
                  sysctl_config_file.load
                  sysctl_config_file.disable_ipv6 = !@ipv6
            Severity: Minor
            Found in src/modules/Lan.rb - About 45 mins 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

            Method activate_network_service has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def activate_network_service
                  # If the second installation stage has been called by yast.ssh via
                  # ssh, we should not restart network because systemctl
                  # hangs in that case. (bnc#885640)
                  action = :reload_restart   if Stage.normal || !Linuxrc.usessh
            Severity: Minor
            Found in src/modules/Lan.rb - About 45 mins 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

            Method isAnyInterfaceDown has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def isAnyInterfaceDown
                  down = false
                  link_status = devices_link_status
            
                  log.info("link_status #{link_status}")
            Severity: Minor
            Found in src/modules/Lan.rb - About 35 mins 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

            Method link_status has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def link_status(name)
                  addr_show = ["/usr/sbin/ip", "address", "show", name]
                  inet_link = ["grep", "inet\\|link"]
                  row = Yast::Execute.stdout.on_target!(addr_show, inet_link).split("\n").map(&:strip)
                  addr = false
            Severity: Minor
            Found in src/modules/Lan.rb - About 35 mins 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

            Avoid too many return statements within this method.
            Open

                    return false if Abort()
            Severity: Major
            Found in src/modules/Lan.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return false if Abort()
              Severity: Major
              Found in src/modules/Lan.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return false if Abort()
                Severity: Major
                Found in src/modules/Lan.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                        return true if Host.GetModified
                  Severity: Major
                  Found in src/modules/Lan.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                          return false if Abort()
                    Severity: Major
                    Found in src/modules/Lan.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                            return false if Abort()
                      Severity: Major
                      Found in src/modules/Lan.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                              return false if Abort()
                        Severity: Major
                        Found in src/modules/Lan.rb - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                  return false if Abort()
                          Severity: Major
                          Found in src/modules/Lan.rb - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                  return false if Abort()
                            Severity: Major
                            Found in src/modules/Lan.rb - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                    return false if Abort()
                              Severity: Major
                              Found in src/modules/Lan.rb - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                        return false unless read_config
                                Severity: Major
                                Found in src/modules/Lan.rb - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                          return false if Abort()
                                  Severity: Major
                                  Found in src/modules/Lan.rb - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                          return false if Abort()
                                    Severity: Major
                                    Found in src/modules/Lan.rb - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                              return false if !Popup.ContinueCancel(msg)
                                      Severity: Major
                                      Found in src/modules/Lan.rb - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                return false if Abort()
                                        Severity: Major
                                        Found in src/modules/Lan.rb - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                  return false if !@gui
                                          Severity: Major
                                          Found in src/modules/Lan.rb - About 30 mins to fix

                                            Method ensure_network_running has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                                def ensure_network_running
                                                  network = false
                                                  timeout = NM_DHCP_TIMEOUT
                                                  while timeout > 0
                                                    if NetworkService.isNetworkRunning
                                            Severity: Minor
                                            Found in src/modules/Lan.rb - About 25 mins 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

                                            Method Modified has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                                def Modified
                                                  return true if @modified
                                                  return true unless system_config == yast_config
                                                  return true if NetworkConfig.Modified
                                                  return true if NetworkService.Modified
                                            Severity: Minor
                                            Found in src/modules/Lan.rb - About 25 mins 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

                                            There are no issues that match your filters.

                                            Category
                                            Status