File susefirewall2.rb
has 1754 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "yast"
require "network/susefirewall"
module Yast
# ----------------------------------------------------------------------------
Class SuSEFirewall2Class
has 85 methods (exceeds 20 allowed). Consider refactoring. Open
class SuSEFirewall2Class < SuSEFirewallClass
CONFIG_FILE = "/etc/sysconfig/SuSEfirewall2".freeze
include Yast::Logger
Method ConvertToServicesDefinedByPackages
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
def ConvertToServicesDefinedByPackages
return if @already_converted
if FileUtils.Exists(@converted_to_services_dbp_file)
@already_converted = true
- Read upRead up
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 126 lines of code (exceeds 25 allowed). Consider refactoring. Open
def main
textdomain "base"
Yast.import "Mode"
Yast.import "Service"
Method ConvertToServicesDefinedByPackages
has 102 lines of code (exceeds 25 allowed). Consider refactoring. Open
def ConvertToServicesDefinedByPackages
return if @already_converted
if FileUtils.Exists(@converted_to_services_dbp_file)
@already_converted = true
Method WriteConfiguration
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def WriteConfiguration
# just disabled
return true if !SuSEFirewallIsInstalled()
# Progress only for normal configuration and command line
- Read upRead up
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 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
def WriteConfiguration
# just disabled
return true if !SuSEFirewallIsInstalled()
# Progress only for normal configuration and command line
Method IsServiceSupportedInZone
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
def IsServiceSupportedInZone(service, zone)
return nil if !IsKnownZone(zone)
Yast.import "SuSEFirewallServices" # lazy import due to circular dependencies
Method Read
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def Read
# Do not read it again and again
# to avoid rewriting changes already made
if @configuration_has_been_read
Builtins.y2milestone(
Method GetAdditionalServices
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def GetAdditionalServices(protocol, zone)
if !IsSupportedProtocol(protocol)
Builtins.y2error("Unknown protocol '%1'", protocol)
return nil
end
Method AddForwardIntoMasqueradeRule
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def AddForwardIntoMasqueradeRule(source_net, forward_to_ip, protocol, req_port, redirect_to_port, requested_ip)
SetModified()
masquerade_rules = Ops.get_string(@SETTINGS, "FW_FORWARD_MASQ", "")
Method RemoveOldAllowedServiceFromZone
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def RemoveOldAllowedServiceFromZone(old_service_def, zone)
old_service_def = deep_copy(old_service_def)
Builtins.y2milestone("Removing: %1 from zone %2", old_service_def, zone)
if Ops.get_list(old_service_def, "tcp_ports", []) != []
Method IsServiceSupportedInZone
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def IsServiceSupportedInZone(service, zone)
return nil if !IsKnownZone(zone)
Yast.import "SuSEFirewallServices" # lazy import due to circular dependencies
- Read upRead up
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 ActivateConfiguration
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def ActivateConfiguration
# just disabled
return true if !SuSEFirewallIsInstalled()
# starting firewall during second stage can cause deadlock in systemd - bnc#798620
- Read upRead up
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 SetFirewallKernelModules
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def SetFirewallKernelModules(k_modules)
k_modules = deep_copy(k_modules)
k_modules = Builtins.filter(k_modules) do |one_module|
if one_module.nil?
Builtins.y2error(
Method GetListOfForwardsIntoMasquerade
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def GetListOfForwardsIntoMasquerade
list_of_rules = []
Builtins.foreach(
Builtins.splitstring(
Method CheckKernelModules
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def CheckKernelModules
needs_additional_module = false
Builtins.foreach(GetKnownFirewallZones()) do |one_zone|
if Ops.greater_or_equal(
Method AddServiceSupportIntoZone
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def AddServiceSupportIntoZone(service, zone)
Yast.import "SuSEFirewallServices" # lazy import due to circular dependencies
needed = SuSEFirewallServices.GetNeededPortsAndProtocols(service)
# unknown service
Method RemoveServiceSupportFromZone
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def RemoveServiceSupportFromZone(service, zone)
Yast.import "SuSEFirewallServices" # lazy import due to circular dependencies
needed = SuSEFirewallServices.GetNeededPortsAndProtocols(service)
# unknown service
Method SetLoggingSettings
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def SetLoggingSettings(rule, state)
SetModified()
case rule
when "ACCEPT"
Method IsBroadcastAllowed
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def IsBroadcastAllowed(needed_ports, zone)
needed_ports = deep_copy(needed_ports)
if Builtins.size(needed_ports) == 0
Builtins.y2warning("Unknown service with no needed ports!")
return nil
Method SetServicesForZones
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def SetServicesForZones(services_ids, firewall_zones, new_status)
# setting for each service
Builtins.foreach(services_ids) do |service_id|
Builtins.foreach(firewall_zones) do |firewall_zone|
# zone must be known one
Method ReadSysconfigSuSEFirewall
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def ReadSysconfigSuSEFirewall(variables)
variables = deep_copy(variables)
Builtins.foreach(variables) do |variable|
value = Convert.to_string(
SCR.Read(Builtins.add(path(".sysconfig.SuSEfirewall2"), variable))
- Read upRead up
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 ActivateConfiguration
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def ActivateConfiguration
# just disabled
return true if !SuSEFirewallIsInstalled()
# starting firewall during second stage can cause deadlock in systemd - bnc#798620
Method AddInterfaceIntoZone
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def AddInterfaceIntoZone(interface, zone)
SetModified()
current_zone = GetZoneOfInterface(interface)
Method GetLoggingSettings
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def GetLoggingSettings(rule)
ret_val = nil
case rule
when "ACCEPT"
- Read upRead up
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 RemoveServiceSupportFromZone
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def RemoveServiceSupportFromZone(service, zone)
Yast.import "SuSEFirewallServices" # lazy import due to circular dependencies
needed = SuSEFirewallServices.GetNeededPortsAndProtocols(service)
# unknown service
- Read upRead up
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 a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def Read
# Do not read it again and again
# to avoid rewriting changes already made
if @configuration_has_been_read
Builtins.y2milestone(
- Read upRead up
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 AddForwardIntoMasqueradeRule
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def AddForwardIntoMasqueradeRule(source_net, forward_to_ip, protocol, req_port, redirect_to_port, requested_ip)
Method SetServicesForZones
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def SetServicesForZones(services_ids, firewall_zones, new_status)
# setting for each service
Builtins.foreach(services_ids) do |service_id|
Builtins.foreach(firewall_zones) do |firewall_zone|
# zone must be known one
- Read upRead up
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 GetAdditionalServices
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def GetAdditionalServices(protocol, zone)
if !IsSupportedProtocol(protocol)
Builtins.y2error("Unknown protocol '%1'", protocol)
return nil
end
- Read upRead up
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 AddServiceSupportIntoZone
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def AddServiceSupportIntoZone(service, zone)
Yast.import "SuSEFirewallServices" # lazy import due to circular dependencies
needed = SuSEFirewallServices.GetNeededPortsAndProtocols(service)
# unknown service
- Read upRead up
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 SetFirewallKernelModules
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def SetFirewallKernelModules(k_modules)
k_modules = deep_copy(k_modules)
k_modules = Builtins.filter(k_modules) do |one_module|
if one_module.nil?
Builtins.y2error(
- Read upRead up
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 AddForwardIntoMasqueradeRule
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def AddForwardIntoMasqueradeRule(source_net, forward_to_ip, protocol, req_port, redirect_to_port, requested_ip)
SetModified()
masquerade_rules = Ops.get_string(@SETTINGS, "FW_FORWARD_MASQ", "")
- Read upRead up
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 GetListOfForwardsIntoMasquerade
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def GetListOfForwardsIntoMasquerade
list_of_rules = []
Builtins.foreach(
Builtins.splitstring(
- Read upRead up
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 AnyRPCServiceInConfiguration
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def AnyRPCServiceInConfiguration
ret = false
Builtins.foreach(GetKnownFirewallZones()) do |fw_zone|
fw_rule = Builtins.sformat("FW_SERVICES_%1_RPC", fw_zone)
- Read upRead up
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
def RemoveInterfaceFromZone(interface, zone)
SetModified()
Builtins.y2milestone(
"Removing interface '%1' from '%2' zone.",
- Read upRead up
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 45.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def RemoveSpecialInterfaceFromZone(interface, zone)
SetModified()
Builtins.y2milestone(
"Removing special string '%1' from '%2' zone.",
- Read upRead up
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 45.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
when "ACCEPT"
case state
when "ALL"
Ops.set(@SETTINGS, "FW_LOG_ACCEPT_CRIT", "yes")
Ops.set(@SETTINGS, "FW_LOG_ACCEPT_ALL", "yes")
- Read upRead up
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 42.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
when "DROP"
case state
when "ALL"
Ops.set(@SETTINGS, "FW_LOG_DROP_CRIT", "yes")
Ops.set(@SETTINGS, "FW_LOG_DROP_ALL", "yes")
- Read upRead up
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 42.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
Builtins.foreach(needed_ports) do |needed_port|
# allowed ports don't contain the needed one and also portranges don't
if !Builtins.contains(
Ops.get(allowed_ports_divided, "ports", []),
needed_port
- Read upRead up
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 30.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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)
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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)
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def GetAllNonDialUpInterfaces
non_dial_up_interfaces = []
Builtins.foreach(GetAllKnownInterfaces()) do |interface|
if Ops.get(interface, "type") != "dial_up"
non_dial_up_interfaces = Builtins.add(
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def GetAllDialUpInterfaces
dial_up_interfaces = []
Builtins.foreach(GetAllKnownInterfaces()) do |interface|
if Ops.get(interface, "type") == "dial_up"
dial_up_interfaces = Builtins.add(
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76