yast/yast-yast2

View on GitHub
library/network/src/modules/CWMFirewallInterfaces.rb

Summary

Maintainability
F
4 days
Test Coverage

File CWMFirewallInterfaces.rb has 704 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "yast"
require "y2firewall/firewalld"
require "y2firewall/helpers/interfaces"

module Yast
Severity: Major
Found in library/network/src/modules/CWMFirewallInterfaces.rb - About 1 day to fix

    Class CWMFirewallInterfacesClass has 42 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class CWMFirewallInterfacesClass < Module
        include Y2Firewall::Helpers::Interfaces
        include Yast::Logger
    
        # [Array<String>] List of all interfaces relevant for firewall settings
    Severity: Minor
    Found in library/network/src/modules/CWMFirewallInterfaces.rb - About 5 hrs to fix

      Method InterfacesValidate has 78 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def InterfacesValidate(_widget, _key, _event)
            trusted_zone = firewalld.find_zone("trusted")
      
            ifaces = Convert.convert(
              UI.QueryWidget(Id("_cwm_interface_list"), :SelectedItems),
      Severity: Major
      Found in library/network/src/modules/CWMFirewallInterfaces.rb - About 3 hrs to fix

        Method CreateOpenFirewallWidget has 68 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def CreateOpenFirewallWidget(settings)
              settings = deep_copy(settings)
        
              services = adapt_settings_services!(settings)
        
        
        Severity: Major
        Found in library/network/src/modules/CWMFirewallInterfaces.rb - About 2 hrs to fix

          Method CreateInterfacesWidget has 67 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def CreateInterfacesWidget(settings)
                settings = deep_copy(settings)
                widget = HBox(
                  HSpacing(1),
                  VBox(
          Severity: Major
          Found in library/network/src/modules/CWMFirewallInterfaces.rb - About 2 hrs to fix

            Method StoreAllowedInterfaces has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

                def StoreAllowedInterfaces(services)
                  services = deep_copy(services)
                  # do not save anything if configuration didn't change
                  return if !configuration_changed
            
            
            Severity: Minor
            Found in library/network/src/modules/CWMFirewallInterfaces.rb - About 2 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 Selected2Opened has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                def Selected2Opened(ifaces, _nm_ifaces_have_to_be_selected)
                  log.info("Selected ifaces: #{ifaces}")
                  zone_names = ifaces.map do |name|
                    zone = interface_zone(name)
                    zone ? zone.name : default_zone.name
            Severity: Minor
            Found in library/network/src/modules/CWMFirewallInterfaces.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 InterfacesValidate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                def InterfacesValidate(_widget, _key, _event)
                  trusted_zone = firewalld.find_zone("trusted")
            
                  ifaces = Convert.convert(
                    UI.QueryWidget(Id("_cwm_interface_list"), :SelectedItems),
            Severity: Minor
            Found in library/network/src/modules/CWMFirewallInterfaces.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 OpenFirewallHandle has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def OpenFirewallHandle(widget, _key, event)
                  widget = deep_copy(widget)
                  event = deep_copy(event)
                  event_id = Ops.get(event, "ID")
                  if event_id == "_cwm_firewall_details"
            Severity: Minor
            Found in library/network/src/modules/CWMFirewallInterfaces.rb - About 1 hr to fix

              Method interface_label has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  def interface_label(name)
                    return name if Mode.config
              
                    label = NetworkInterfaces.GetValue(name, "BOOTPROTO")
                    ipaddr = NetworkInterfaces.GetValue(name, "IPADDR")
              Severity: Minor
              Found in library/network/src/modules/CWMFirewallInterfaces.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 zone_services has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def zone_services(services)
                    services_status = {}
              
                    services.each do |service|
                      service_supported = firewalld.current_service_names.include?(service)
              Severity: Minor
              Found in library/network/src/modules/CWMFirewallInterfaces.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 OpenFirewallHandle has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def OpenFirewallHandle(widget, _key, event)
                    widget = deep_copy(widget)
                    event = deep_copy(event)
                    event_id = Ops.get(event, "ID")
                    if event_id == "_cwm_firewall_details"
              Severity: Minor
              Found in library/network/src/modules/CWMFirewallInterfaces.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 CreateOpenFirewallWidget has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def CreateOpenFirewallWidget(settings)
                    settings = deep_copy(settings)
              
                    services = adapt_settings_services!(settings)
              
              
              Severity: Minor
              Found in library/network/src/modules/CWMFirewallInterfaces.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 current_firewall_status has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def current_firewall_status
                    # bnc #429861
                    return :not_installed if Stage.initial || !firewalld.installed?
                    return :off unless firewalld.enabled?
                    return :no_ifaces if all_interfaces.empty?
              Severity: Minor
              Found in library/network/src/modules/CWMFirewallInterfaces.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 :closed if allowed_interfaces.empty?
              Severity: Major
              Found in library/network/src/modules/CWMFirewallInterfaces.rb - About 30 mins to fix

                There are no issues that match your filters.

                Category
                Status