openSUSE/open-build-service

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

Summary

Maintainability
F
3 days
Test Coverage
A
96%

Class Package has 113 methods (exceeds 20 allowed). Consider refactoring.
Open

class Package < ApplicationRecord
  include FlagHelper
  include FlagValidations
  include CanRenderModel
  include HasRelationships
Severity: Major
Found in src/api/app/models/package.rb - About 2 days to fix

    Method find_changed_issues has a Cognitive Complexity of 27 (exceeds 8 allowed). Consider refactoring.
    Open

      def find_changed_issues
        # no expand=1, so only branches are tracked
        query = { cmd: :diff, orev: 0, onlyissues: 1, linkrev: :base, view: :xml }
        issue_change = parse_issues_xml(query, 'kept')
        # issues introduced by local changes
    Severity: Minor
    Found in src/api/app/models/package.rb - About 3 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 get_by_project_and_name has a Cognitive Complexity of 22 (exceeds 8 allowed). Consider refactoring.
    Open

      def self.get_by_project_and_name(project_name_or_object, package_name, opts = {})
        get_by_project_and_name_defaults = { use_source: true, follow_project_links: true, follow_multibuild: false, check_update_project: false }
        opts = get_by_project_and_name_defaults.merge(opts)
    
        package_name = striping_multibuild_suffix(package_name) if opts[:follow_multibuild]
    Severity: Minor
    Found in src/api/app/models/package.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 delete_on_backend has a Cognitive Complexity of 17 (exceeds 8 allowed). Consider refactoring.
    Open

      def delete_on_backend
        # lock this package object to avoid that dependend objects get created in parallel
        # for example a backend_package
        reload(lock: true)
    
    
    Severity: Minor
    Found in src/api/app/models/package.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 find_changed_issues has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def find_changed_issues
        # no expand=1, so only branches are tracked
        query = { cmd: :diff, orev: 0, onlyissues: 1, linkrev: :base, view: :xml }
        issue_change = parse_issues_xml(query, 'kept')
        # issues introduced by local changes
    Severity: Minor
    Found in src/api/app/models/package.rb - About 1 hr to fix

      Method resolve_devel_package has a Cognitive Complexity of 13 (exceeds 8 allowed). Consider refactoring.
      Open

        def resolve_devel_package
          pkg = self
          prj_name = pkg.project.name
          processed = {}
      
      
      Severity: Minor
      Found in src/api/app/models/package.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 update_product_list has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
      Open

        def update_product_list
          # short cut to ensure that no products are left over
          unless is_product?
            products.destroy_all
            return
      Severity: Minor
      Found in src/api/app/models/package.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 update_from_xml has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
      Open

        def update_from_xml(xmlhash, ignore_lock = nil)
          check_write_access!(ignore_lock)
      
          Package.transaction do
            self.title = xmlhash.value('title')
      Severity: Minor
      Found in src/api/app/models/package.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 write_to_backend has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
      Open

        def write_to_backend
          reset_cache
          raise ArgumentError, 'no commit_user set' unless commit_user
          raise InvalidParameterError, 'Project meta file can not be written via package model' if name == '_project'
      
      
      Severity: Minor
      Found in src/api/app/models/package.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 add_channels has a Cognitive Complexity of 11 (exceeds 8 allowed). Consider refactoring.
      Open

        def add_channels(mode = :add_disabled)
          raise InvalidParameterError unless %i[add_disabled skip_disabled enable_all].include?(mode)
          return if is_channel?
      
          opkg = origin_container(local: false)
      Severity: Minor
      Found in src/api/app/models/package.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 sources_changed has a Cognitive Complexity of 10 (exceeds 8 allowed). Consider refactoring.
      Open

        def sources_changed(opts = {})
          dir_xml = opts[:dir_xml]
      
          # to call update_activity before filter
          # NOTE: We need `Time.now`, otherwise the old tests suite doesn't work,
      Severity: Minor
      Found in src/api/app/models/package.rb - About 35 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