yast/yast-network

View on GitHub

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
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 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"
Severity: Minor
Found in src/clients/remote.rb - About 1 hr to fix

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

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

      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."))
      Severity: Minor
      Found in src/lib/y2network/clients/routing.rb - About 1 hr to fix

        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}")
        Severity: Minor
        Found in src/modules/Host.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 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)
        Severity: Minor
        Found in src/lib/y2network/widgets/boot_protocol.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 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"   => {
        Severity: Minor
        Found in src/include/network/lan/complex.rb - About 1 hr to fix

          Method contents has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def contents
                  RadioButtonGroup(
                    VBox(
                      # Small spacing (bsc#988904)
                      VSpacing(0.3),
          Severity: Minor
          Found in src/lib/y2remote/widgets/remote.rb - About 1 hr to fix

            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)"),
            Severity: Minor
            Found in src/lib/y2network/clients/dns.rb - About 1 hr to fix

              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}"
              Severity: Minor
              Found in src/include/network/routines.rb - About 1 hr to fix

                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
                Severity: Major
                Found in src/lib/y2network/dialogs/s390_ctc_activation.rb and 1 other location - About 1 hr to fix
                src/lib/y2network/dialogs/s390_lcs_activation.rb on lines 22..65

                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

                Further Reading

                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
                Severity: Major
                Found in src/lib/y2network/dialogs/s390_lcs_activation.rb and 1 other location - About 1 hr to fix
                src/lib/y2network/dialogs/s390_ctc_activation.rb on lines 22..67

                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

                Further Reading

                Method LanSequence has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def LanSequence
                      aliases = {
                        "read"  => [-> { ReadDialog() }, true],
                        "main"  => -> { MainSequence("") },
                        "write" => [-> { WriteDialog() }, true]
                Severity: Minor
                Found in src/include/network/lan/wizards.rb - About 1 hr to fix

                  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
                  Severity: Minor
                  Found in src/lib/y2network/clients/dns.rb - About 1 hr to fix

                    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"]
                    Severity: Minor
                    Found in src/include/network/lan/cmdline.rb - About 1 hr to fix

                      Method dialog has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              def dialog(value = nil)
                                value ||= ""
                                Yast::UI.OpenDialog(
                                  Opt(:decorated),
                                  VBox(
                      Severity: Minor
                      Found in src/lib/y2network/dialogs/wireless_wep_keys.rb - About 1 hr to fix

                        Method contents has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              def contents
                                Frame(
                                  Id(:additional_addresses),
                                  # Frame label
                                  _("Additional Addresses"),
                        Severity: Minor
                        Found in src/lib/y2network/widgets/additional_addresses.rb - About 1 hr to fix

                          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"]
                          Severity: Minor
                          Found in src/lib/y2network/dialogs/wireless_wep_keys.rb - About 1 hr to fix

                            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 contents has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                    def contents
                                      HBox(
                                        HSpacing(4),
                                        VBox(
                                          VSpacing(0.5),
                              Severity: Minor
                              Found in src/lib/y2network/dialogs/wireless_expert_settings.rb - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language