yast/yast-yast2

View on GitHub
library/network/src/lib/network/susefirewalld.rb

Summary

Maintainability
F
5 days
Test Coverage

File susefirewalld.rb has 795 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "yast"
require "y2firewall/firewalld/api"
require "network/susefirewall"

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

    Class SuSEFirewalldClass has 62 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class SuSEFirewalldClass < SuSEFirewallClass
        require "set"
        attr_reader :special_all_interface_zone
    
        # Valid attributes for firewalld zones
    Severity: Major
    Found in library/network/src/lib/network/susefirewalld.rb - About 1 day to fix

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

          def SetServicesForZones(services_ids, firewall_zones, new_status)
            Yast.import "SuSEFirewallServices"
      
            services_ids = deep_copy(services_ids)
            zones = deep_copy(firewall_zones)
      Severity: Minor
      Found in library/network/src/lib/network/susefirewalld.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 WriteConfiguration has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def WriteConfiguration
            # just disabled
            return true if !SuSEFirewallIsInstalled()
      
            return false if !GetModified()
      Severity: Minor
      Found in library/network/src/lib/network/susefirewalld.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 Import has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def Import(import_settings)
            Read()
            import_settings = deep_copy(import_settings || {})
            # Sanitize it
            import_settings.each_key do |k|
      Severity: Minor
      Found in library/network/src/lib/network/susefirewalld.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 sanitize_services_and_ports has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def sanitize_services_and_ports(allowed_services, protocol)
            services = []
            ports = []
            allowed_services.each do |s|
              Builtins.y2debug("Examining %1", s)
      Severity: Minor
      Found in library/network/src/lib/network/susefirewalld.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 SetServicesForZones has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def SetServicesForZones(services_ids, firewall_zones, new_status)
            Yast.import "SuSEFirewallServices"
      
            services_ids = deep_copy(services_ids)
            zones = deep_copy(firewall_zones)
      Severity: Minor
      Found in library/network/src/lib/network/susefirewalld.rb - About 1 hr to fix

        Method initialize has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def initialize
              super
        
              textdomain "base"
        
        
        Severity: Minor
        Found in library/network/src/lib/network/susefirewalld.rb - About 1 hr to fix

          Method read_zones has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              def read_zones
                # Get all the information from zones and load them to @SETTINGS["zones"]
                # The following may seem somewhat complicated or fragile but it is more
                # efficient to only invoke a single firewall-cmd command instead of
                # iterating over the zones and then using all the different
          Severity: Minor
          Found in library/network/src/lib/network/susefirewalld.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 WriteConfiguration has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def WriteConfiguration
                # just disabled
                return true if !SuSEFirewallIsInstalled()
          
                return false if !GetModified()
          Severity: Minor
          Found in library/network/src/lib/network/susefirewalld.rb - About 1 hr to fix

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

                def GetAllowedServicesForZoneProto(zone, protocol)
                  Yast.import "SuSEFirewallServices"
            
                  result = []
                  protocol = protocol.downcase
            Severity: Minor
            Found in library/network/src/lib/network/susefirewalld.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 Import has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def Import(import_settings)
                  Read()
                  import_settings = deep_copy(import_settings || {})
                  # Sanitize it
                  import_settings.each_key do |k|
            Severity: Minor
            Found in library/network/src/lib/network/susefirewalld.rb - About 1 hr to fix

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

                  def ActivateConfiguration
                    # starting firewall during second stage can cause deadlock in systemd - bnc#798620
                    # Moreover, it is not needed. Firewall gets started via dependency on multi-user.target
                    # when second stage is over.
                    if Mode.installation
              Severity: Minor
              Found in library/network/src/lib/network/susefirewalld.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

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

                  def write_zone_services(zone)
                    return nil if !zone_attr_modified?(zone, :services)
              
                    # These are the services which should be enabled
                    good_services = get_zone_attr(zone, :services)
              Severity: Major
              Found in library/network/src/lib/network/susefirewalld.rb and 2 other locations - About 1 hr to fix
              library/network/src/lib/network/susefirewalld.rb on lines 1104..1117
              library/network/src/lib/network/susefirewalld.rb on lines 1136..1149

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

              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

                  def write_zone_ports(zone)
                    return nil if !zone_attr_modified?(zone, :ports)
              
                    # These are the ports which should be enabled
                    good_ports = get_zone_attr(zone, :ports)
              Severity: Major
              Found in library/network/src/lib/network/susefirewalld.rb and 2 other locations - About 1 hr to fix
              library/network/src/lib/network/susefirewalld.rb on lines 1104..1117
              library/network/src/lib/network/susefirewalld.rb on lines 1120..1133

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

              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

                  def write_zone_interfaces(zone)
                    return nil if !zone_attr_modified?(zone, :interfaces)
              
                    # These are the ones which should be enabled
                    good_interfaces = get_zone_attr(zone, :interfaces)
              Severity: Major
              Found in library/network/src/lib/network/susefirewalld.rb and 2 other locations - About 1 hr to fix
              library/network/src/lib/network/susefirewalld.rb on lines 1120..1133
              library/network/src/lib/network/susefirewalld.rb on lines 1136..1149

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

              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

                  def SetAcceptExpertRules(zone, expert_rules)
                    zone = Builtins.toupper(zone)
              
                    # Check for zone
                    if !Builtins.contains(GetKnownFirewallZones(), zone)
              Severity: Minor
              Found in library/network/src/lib/network/susefirewalld.rb and 1 other location - About 25 mins to fix
              library/network/src/lib/network/susefirewall2.rb on lines 2289..2301

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

              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

                    @zone_names = {
                      # TRANSLATORS: Firewall zone name - used in combo box or dialog title
                      "block"    => _(
                        "Block Zone"
                      ),
              Severity: Minor
              Found in library/network/src/lib/network/susefirewalld.rb and 1 other location - About 20 mins to fix
              library/network/src/lib/y2firewall/firewalld/zone.rb on lines 36..45

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

              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

                  def GetAcceptExpertRules(zone)
                    zone = Builtins.toupper(zone)
              
                    # Check for zone
                    if !Builtins.contains(GetKnownFirewallZones(), zone)
              Severity: Minor
              Found in library/network/src/lib/network/susefirewalld.rb and 1 other location - About 20 mins to fix
              library/network/src/lib/network/susefirewall2.rb on lines 2272..2281

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

              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