Showing 255 of 255 total issues
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
- 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 command_line_definition
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def command_line_definition
{
# Commandline help title
"help" => _(
"Remote Access Configuration"
Method main
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def main
Yast.import "UI"
textdomain "network"
Method EditHandler
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def EditHandler(options)
destination = options["dest"]
if destination == ""
CommandLine.Error(_("Destination IP address must be specified."))
Method Update
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def Update(oldhn, newhn, ip)
raise ArgumentError, "IP cannot be nil" if ip.nil?
raise ArgumentError, "Nonempty IP expected" if ip.empty?
log.info("Updating /etc/hosts: #{oldhn} -> #{newhn}: #{ip}")
- 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 validate
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def validate
return true if value != :bootproto_static
ipa = Yast::UI.QueryWidget(:bootproto_ipaddr, :Value)
if !Yast::IP.Check(ipa)
- 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 tabs_descr
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def tabs_descr
return @tabs_descr if @tabs_descr
@tabs_descr = {
"global" => {
Method contents
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def contents
RadioButtonGroup(
VBox(
# Small spacing (bsc#988904)
VSpacing(0.3),
Method option_handlers
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def option_handlers
{
hostname => {
"validator" => fun_ref(method(:valid_hostname?), "boolean (string)"),
"setter" => fun_ref(method(:SetHostname), "void (any)"),
Method PackagesInstall
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def PackagesInstall(packages)
packages = deep_copy(packages)
return :next if packages == []
log.info "Checking packages: #{packages}"
Similar blocks of code found in 2 locations. Consider refactoring. Open
module Y2Network
module Dialogs
# Dialog for activating a CTC device
class S390CtcActivation < S390DeviceActivation
def contents
- 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 54.
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
module Y2Network
module Dialogs
# Dialog for activating a LCS s390 device
class S390LcsActivation < S390DeviceActivation
def contents
- 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 54.
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
Method LanSequence
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def LanSequence
aliases = {
"read" => [-> { ReadDialog() }, true],
"main" => -> { MainSequence("") },
"write" => [-> { WriteDialog() }, true]
Method EditHandler
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def EditHandler(options)
log.info("Edit handler, options: #{options.inspect}")
# validator: a reference to boolean( string) is expected
# setter: a reference to void( any) is expected
Method update_builder_from_options!
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_builder_from_options!(builder, options)
case builder.type.short_name
when "bond"
# change only if user specify it
builder.ports = options["bond_ports"].split if options["bond_ports"]
Method dialog
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def dialog(value = nil)
value ||= ""
Yast::UI.OpenDialog(
Opt(:decorated),
VBox(
Method contents
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def contents
Frame(
Id(:additional_addresses),
# Frame label
_("Additional Addresses"),
Method handle
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handle(event)
return nil if event["EventReason"] != "Activated"
cur = Yast::UI.QueryWidget(Id(:wep_keys_table), :CurrentItem).to_i
case event["ID"]
Method main
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def main
Yast.import "UI"
textdomain "network"
Yast.import "Arch"
Method contents
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def contents
HBox(
HSpacing(4),
VBox(
VSpacing(0.5),