yast/yast-installation

View on GitHub
src/lib/transfer/file_from_url.rb

Summary

Maintainability
F
4 days
Test Coverage

Method get_file_from_url has a Cognitive Complexity of 148 (exceeds 5 allowed). Consider refactoring.
Open

    def get_file_from_url(scheme:, host:, urlpath:, localfile:,
      urltok:, destdir:)
      # adapt sane API to legacy implementation
      _Scheme    = scheme
      _Host      = host
Severity: Minor
Found in src/lib/transfer/file_from_url.rb - About 3 days 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

File file_from_url.rb has 500 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "yast"
require "yast2/execute"
require "yast2/rel_url"

# rubocop:disable all
Severity: Minor
Found in src/lib/transfer/file_from_url.rb - About 1 day to fix

    Avoid deeply nested control flow statements.
    Open

            if WFM.Execute(path(".local.bash"), copyCmd) == 0
              @GET_error = ""
              ok = true
            else
              # autoyast tried to copy a file via NFS which failed
    Severity: Major
    Found in src/lib/transfer/file_from_url.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  if m
                    Builtins.y2milestone(
                      "%1 is already mounted, trying to bind mount...",
                      cdrom_device
                    )
      Severity: Major
      Found in src/lib/transfer/file_from_url.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                if !Convert.to_boolean(
                  SCR.Execute(
                    path(".target.mount"),
                    [Ops.add(Ops.add("//", _Host), dirname(_Path)), mount_point],
                    "-t cifs -o guest,ro,noatime"
        Severity: Major
        Found in src/lib/transfer/file_from_url.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                elsif _Scheme == "floppy"
                  @GET_error = _("URLs starting with 'floppy:/' are not longer supported")
                  ok = false
                elsif _Scheme == "device" || _Scheme == "usb" # Device or USB
                  if _Path != ""
          Severity: Major
          Found in src/lib/transfer/file_from_url.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                        if ok
                          copy_local_file(File.join(mount_point, _Path), _Localfile)
                          WFM.Execute(path(".local.umount"), mount_point)
                          if File.exist?(_Localfile)
                            @GET_error = ""
            Severity: Major
            Found in src/lib/transfer/file_from_url.rb - About 45 mins to fix

              Avoid too many return statements within this method.
              Open

                        return false
              Severity: Major
              Found in src/lib/transfer/file_from_url.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                          return false
                Severity: Major
                Found in src/lib/transfer/file_from_url.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return true
                  Severity: Major
                  Found in src/lib/transfer/file_from_url.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                              return false
                    Severity: Major
                    Found in src/lib/transfer/file_from_url.rb - About 30 mins to fix

                      Identical blocks of code found in 2 locations. Consider refactoring.
                      Open

                              if WFM.Execute(path(".local.bash"), copyCmd) == 0
                                @GET_error = ""
                                ok = true
                              else
                                # autoyast tried to copy a file via NFS which failed
                      Severity: Minor
                      Found in src/lib/transfer/file_from_url.rb and 1 other location - About 40 mins to fix
                      src/lib/transfer/file_from_url.rb on lines 376..387

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

                      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

                              if WFM.Execute(path(".local.bash"), copyCmd) == 0
                                @GET_error = ""
                                ok = true
                              else
                                # autoyast tried to copy a file via NFS which failed
                      Severity: Minor
                      Found in src/lib/transfer/file_from_url.rb and 1 other location - About 40 mins to fix
                      src/lib/transfer/file_from_url.rb on lines 420..431

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

                      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