yast/yast-yast2

View on GitHub

Showing 967 of 967 total issues

Method package_repository has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def package_repository(package_name)
      # Identify the installation repository with the package
      pkgs = Y2Packager::Resolvable.find(kind: :package, name: package_name)

      if pkgs.empty?
Severity: Minor
Found in library/control/src/modules/WorkflowManager.rb - About 25 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

Method ReplaceWorkflowModule has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def ReplaceWorkflowModule(workflow, old, new, domain, keep)
      workflow = deep_copy(workflow)
      new = deep_copy(new)
      found = false

Severity: Minor
Found in library/control/src/modules/WorkflowManager.rb - About 25 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

Method perform_reload has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def perform_reload
      return perform_restart unless support_reload?

      result = true

Severity: Minor
Found in library/systemd/src/lib/yast2/system_service.rb - About 25 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

Method AnyQuestion has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def AnyQuestion(headline, message, yes_button_message, no_button_message, focus)
      Builtins.y2milestone(1, "%1", message) if @log_yesno_messages

      focus = BACKWARD_MAPPING[focus] || focus
      ret = false
Severity: Minor
Found in library/general/src/modules/Report.rb - About 25 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

Method perform_action has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def perform_action
      return true unless action

      result = send("perform_#{action}")
      register_error(:active) if result == false
Severity: Minor
Found in library/systemd/src/lib/yast2/system_service.rb - About 25 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

Method Save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def Save
      InitFeatures(false)
      if Mode.update # in case of update old file has different format
        SCR.Execute(
          path(".target.bash"),
Severity: Minor
Found in library/control/src/modules/ProductFeatures.rb - About 25 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

Method output has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def output
        return "" unless result

        output = []
        output << "STDERR: #{result.stderr.strip}" unless result.stderr.empty?
Severity: Minor
Found in library/general/src/modules/Hooks.rb - About 25 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

Method to_html has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def to_html
        fatal, non_fatal = issues_list.partition(&:fatal?)

        parts = []
        parts << error_text(fatal) unless fatal.empty?
Severity: Minor
Found in library/general/src/lib/installation/autoinst_issues/issues_presenter.rb - About 25 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

Method start_modes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def start_modes
      @start_modes = [:on_boot, :manual, :on_demand] unless found?
      return @start_modes if @start_modes

      @start_modes = [:manual]
Severity: Minor
Found in library/systemd/src/lib/yast2/system_service.rb - About 25 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

Method MkTempInternal has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def MkTempInternal(template, usergroup, modes, directory)
      mktemp = Builtins.sformat(
        "/bin/mktemp %1 %2",
        directory ? "-d" : "",
        template.shellescape
Severity: Minor
Found in library/general/src/modules/FileUtils.rb - About 25 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

Method stage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def stage
      if @_stage.nil?
        @_stage = "normal"

        arg_count = Builtins.size(WFM.Args)
Severity: Minor
Found in library/general/src/modules/Stage.rb - About 25 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

Method sockets_map has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def sockets_map
        return @sockets_map if @sockets_map

        result = Yast2::Systemctl.execute(show_triggers_cmd)
        return {} unless result.exit.zero?
Severity: Minor
Found in library/systemd/src/lib/yast2/systemd/socket_finder.rb - About 25 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

Method event_loop has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def event_loop
      Yast.import "UI"
      @_finish_dialog_flag = false

      loop do
Severity: Minor
Found in library/general/src/lib/ui/event_dispatcher.rb - About 25 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

Method Transform has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def Transform(old)
      s = Builtins.symbolof(old)

      handler = Greasemonkey.method(s) if @handlers.include?(s)
      return Transform(handler.call(old)) if !handler.nil?
Severity: Minor
Found in library/general/src/lib/ui/greasemonkey.rb - About 25 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

Method load has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def load
      begin
        super
      rescue Errno::ENOENT # PATH does not exist yet
        self.data = @parser.empty
Severity: Minor
Found in library/general/src/lib/cfa/sysctl.rb - About 25 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

Method CheckNetwork6 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def CheckNetwork6(network)
      generic_check = CheckNetworkShared(network)
      return generic_check unless generic_check.nil?

      # 2001:db8:0::1/64
Severity: Minor
Found in library/types/src/modules/IP.rb - About 25 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 6 locations. Consider refactoring.
Open

    def Disable(service_name)
      log.info "Disabling service '#{service_name}'"
      service = Yast2::Systemd::Service.find(service_name)
      return failure(:not_found, service_name) unless service
      return failure(:disable, service_name, service.error) unless service.disable
Severity: Major
Found in library/systemd/src/modules/Service.rb and 5 other locations - About 25 mins to fix
library/systemd/src/modules/Service.rb on lines 112..118
library/systemd/src/modules/Service.rb on lines 142..148
library/systemd/src/modules/Service.rb on lines 157..163
library/systemd/src/modules/Service.rb on lines 172..178
library/systemd/src/modules/Service.rb on lines 187..193

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

Further Reading

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

    def Start(service_name)
      log.info "Starting service '#{service_name}'"
      service = Yast2::Systemd::Service.find(service_name)
      return failure(:not_found, service_name) unless service
      return failure(:start, service_name, service.error) unless service.start
Severity: Major
Found in library/systemd/src/modules/Service.rb and 5 other locations - About 25 mins to fix
library/systemd/src/modules/Service.rb on lines 112..118
library/systemd/src/modules/Service.rb on lines 127..133
library/systemd/src/modules/Service.rb on lines 157..163
library/systemd/src/modules/Service.rb on lines 172..178
library/systemd/src/modules/Service.rb on lines 187..193

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

Further Reading

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

    def Stop(service_name)
      log.info "Stopping service '#{service_name}'"
      service = Yast2::Systemd::Service.find(service_name)
      return failure(:not_found, service_name) unless service
      return failure(:stop, service_name, service.error) unless service.stop
Severity: Major
Found in library/systemd/src/modules/Service.rb and 5 other locations - About 25 mins to fix
library/systemd/src/modules/Service.rb on lines 112..118
library/systemd/src/modules/Service.rb on lines 127..133
library/systemd/src/modules/Service.rb on lines 142..148
library/systemd/src/modules/Service.rb on lines 157..163
library/systemd/src/modules/Service.rb on lines 172..178

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

Further Reading

Method MakeParamsFromMap has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def MakeParamsFromMap(params_map)
      params_map = deep_copy(params_map)
      # ["key1=value1", "key2=value2", ...] -> "key1=value1&key2=value2"
      Builtins.mergestring(
        # ["key" : "value", ...] -> ["key=value", ...]
Severity: Minor
Found in library/types/src/modules/URL.rb - About 25 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

Severity
Category
Status
Source
Language