openSUSE/open-build-service

View on GitHub
src/api/app/models/patchinfo.rb

Summary

Maintainability
B
6 hrs
Test Coverage
B
89%

Method to_xml has a Cognitive Complexity of 21 (exceeds 8 allowed). Consider refactoring.
Open

  def to_xml(project, package)
    self.issues = []
    issueid.to_a.each_with_index do |new_issue, index|
      issues << [
        new_issue,
Severity: Minor
Found in src/api/app/models/patchinfo.rb - About 2 hrs 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_xml has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def to_xml(project, package)
    self.issues = []
    issueid.to_a.each_with_index do |new_issue, index|
      issues << [
        new_issue,
Severity: Minor
Found in src/api/app/models/patchinfo.rb - About 1 hr to fix

    Method load_from_xml has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def load_from_xml(patchinfo_xml)
        self.binaries = []
        patchinfo_xml.elements('binary').each do |binaries|
          self.binaries << binaries
        end
    Severity: Minor
    Found in src/api/app/models/patchinfo.rb - About 1 hr to fix

      Method update_patchinfo has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
      Open

        def update_patchinfo(project, patchinfo, opts = {})
          project.check_write_access!
          @patchinfo = patchinfo
      
          opts[:enfore_issue_update] ||= false
      Severity: Minor
      Found in src/api/app/models/patchinfo.rb - About 45 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_from_xml has a Cognitive Complexity of 9 (exceeds 8 allowed). Consider refactoring.
      Open

        def load_from_xml(patchinfo_xml)
          self.binaries = []
          patchinfo_xml.elements('binary').each do |binaries|
            self.binaries << binaries
          end
      Severity: Minor
      Found in src/api/app/models/patchinfo.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

      There are no issues that match your filters.

      Category
      Status