openSUSE/open-build-service

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

Summary

Maintainability
F
1 wk
Test Coverage

File bs_request.rb has 945 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'xmlhash'

include MaintenanceHelper

class BsRequest < ApplicationRecord
Severity: Major
Found in src/api/app/models/bs_request.rb - About 2 days to fix

    Method webui_actions has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring.
    Open

      def webui_actions(opts = {})
        # TODO: Fix!
        actions = []
        with_diff = opts.delete(:diffs)
        bs_request_actions.each do |xml|
    Severity: Minor
    Found in src/api/app/models/bs_request.rb - About 1 day 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

    Class BsRequest has 67 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class BsRequest < ApplicationRecord
      class InvalidStateError < APIError
        setup 'request_not_modifiable', 404
      end
      class InvalidReview < APIError
    Severity: Major
    Found in src/api/app/models/bs_request.rb - About 1 day to fix

      Method new_from_hash has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
      Wontfix

        def self.new_from_hash(hashed)
          if hashed['id']
            theid = hashed.delete('id') { raise 'not found' }
            theid = Integer(theid)
          else
      Severity: Minor
      Found in src/api/app/models/bs_request.rb - About 6 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 changestate_accepted has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
      Open

        def changestate_accepted(opts)
          # all maintenance_incident actions go into the same incident project
          incident_project = nil # .where(type: 'maintenance_incident')
          bs_request_actions.each do |action|
            source_project = Project.find_by_name(action.source_project)
      Severity: Minor
      Found in src/api/app/models/bs_request.rb - About 6 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 _assignreview_update_reviews has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

        def _assignreview_update_reviews(reviewer, opts, new_review = nil)
          review_comment = nil
          reviews.reverse_each do |review|
            next if review.by_user
            next if review.by_group && review.by_group != opts[:by_group]
      Severity: Minor
      Found in src/api/app/models/bs_request.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 change_review_state has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

        def change_review_state(new_review_state, opts = {})
          with_lock do
            new_review_state = new_review_state.to_sym
      
            unless state == :review || (state == :new && new_review_state == :new)
      Severity: Minor
      Found in src/api/app/models/bs_request.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 render_xml has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

        def render_xml(opts = {})
          builder = Nokogiri::XML::Builder.new
          builder.request(id: number, creator: creator) do |r|
            bs_request_actions.includes([:bs_request_action_accept_info]).find_each do |action|
              action.render_xml(r)
      Severity: Minor
      Found in src/api/app/models/bs_request.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 is_reviewer? has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

        def is_reviewer?(user)
          return false if reviews.blank?
      
          reviews.each do |r|
            if r.by_user
      Severity: Minor
      Found in src/api/app/models/bs_request.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 apply_default_reviewers has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

        def apply_default_reviewers
          reviewers = collect_default_reviewers!
          # apply reviewers
          reviewers.each do |r|
            if r.class == User
      Severity: Minor
      Found in src/api/app/models/bs_request.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 webui_actions has 81 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def webui_actions(opts = {})
          # TODO: Fix!
          actions = []
          with_diff = opts.delete(:diffs)
          bs_request_actions.each do |xml|
      Severity: Major
      Found in src/api/app/models/bs_request.rb - About 3 hrs to fix

        Method assignreview has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

          def assignreview(opts = {})
            unless state == :review || (state == :new && state == :new)
              raise InvalidStateError, 'request is not in review state'
            end
            reviewer = User.find_by_login!(opts[:reviewer])
        Severity: Minor
        Found in src/api/app/models/bs_request.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 new_from_hash has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Wontfix

          def self.new_from_hash(hashed)
            if hashed['id']
              theid = hashed.delete('id') { raise 'not found' }
              theid = Integer(theid)
            else
        Severity: Major
        Found in src/api/app/models/bs_request.rb - About 2 hrs to fix

          Method change_state has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

            def change_state(opts)
              with_lock do
                permission_check_change_state!(opts)
                changestate_revoked if opts[:newstate] == 'revoked'
                changestate_accepted(opts) if opts[:newstate] == 'accepted'
          Severity: Minor
          Found in src/api/app/models/bs_request.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 change_state has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def change_state(opts)
              with_lock do
                permission_check_change_state!(opts)
                changestate_revoked if opts[:newstate] == 'revoked'
                changestate_accepted(opts) if opts[:newstate] == 'accepted'
          Severity: Minor
          Found in src/api/app/models/bs_request.rb - About 1 hr to fix

            Method changestate_accepted has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def changestate_accepted(opts)
                # all maintenance_incident actions go into the same incident project
                incident_project = nil # .where(type: 'maintenance_incident')
                bs_request_actions.each do |action|
                  source_project = Project.find_by_name(action.source_project)
            Severity: Minor
            Found in src/api/app/models/bs_request.rb - About 1 hr to fix

              Method auto_accept has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

                def auto_accept
                  # do not run for processed requests. Ignoring review on purpose since this
                  # must also work when people do not react anymore
                  return unless state == :new || state == :review
              
              
              Severity: Minor
              Found in src/api/app/models/bs_request.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 render_xml has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def render_xml(opts = {})
                  builder = Nokogiri::XML::Builder.new
                  builder.request(id: number, creator: creator) do |r|
                    bs_request_actions.includes([:bs_request_action_accept_info]).find_each do |action|
                      action.render_xml(r)
              Severity: Minor
              Found in src/api/app/models/bs_request.rb - About 1 hr to fix

                Method obsolete_reviews has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  def obsolete_reviews(opts)
                    return false unless opts[:by_user] || opts[:by_group] || opts[:by_project] || opts[:by_package]
                    reviews.each do |review|
                      next unless review.reviewable_by?(opts)
                
                
                Severity: Minor
                Found in src/api/app/models/bs_request.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 change_review_state has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def change_review_state(new_review_state, opts = {})
                    with_lock do
                      new_review_state = new_review_state.to_sym
                
                      unless state == :review || (state == :new && new_review_state == :new)
                Severity: Minor
                Found in src/api/app/models/bs_request.rb - About 1 hr to fix

                  Avoid deeply nested control flow statements.
                  Open

                            return true if pkg && user.can_modify?(pkg)
                  Severity: Major
                  Found in src/api/app/models/bs_request.rb - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                              return true if prj && user.can_modify?(prj)
                    Severity: Major
                    Found in src/api/app/models/bs_request.rb - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                      if forward[:project] == lprj && forward[:package] == lpkg
                                        link_is_already_devel = true
                                        break
                                      end
                      Severity: Major
                      Found in src/api/app/models/bs_request.rb - About 45 mins to fix

                        Method list has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def self.list(opts)
                            # All types means don't pass 'type'
                            opts.delete(:types) if [opts[:types]].flatten.include?('all')
                            # Do not allow a full collection to avoid server load
                            if [:project, :user, :package].all? { |filter| opts[filter].blank? }
                        Severity: Minor
                        Found in src/api/app/models/bs_request.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 sanitize! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def sanitize!
                            # apply default values, expand and do permission checks
                            self.creator ||= User.session!.login
                            self.commenter ||= User.session!.login
                            # FIXME: Move permission checks to controller level
                        Severity: Minor
                        Found in src/api/app/models/bs_request.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

                        Avoid deeply nested control flow statements.
                        Open

                                next if reviews.any? { |a| a.by_project == r.project.name && a.by_package == r.name }
                        Severity: Major
                        Found in src/api/app/models/bs_request.rb - About 45 mins to fix

                          Method check_creator has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def check_creator
                              errors.add(:creator, 'No creator defined') unless creator
                              # Allow admins to create requests for deleted or inactive users
                              return if User.admin_session?
                              user = User.not_deleted.find_by(login: creator)
                          Severity: Minor
                          Found in src/api/app/models/bs_request.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

                          Avoid too many return statements within this method.
                          Open

                                    return true if prj && user.can_modify?(prj)
                          Severity: Major
                          Found in src/api/app/models/bs_request.rb - About 30 mins to fix

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

                              def changestate_revoked
                                bs_request_actions.where(type: 'maintenance_release').find_each do |action|
                                  # unlock incident project in the soft way
                                  prj = Project.get_by_name(action.source_project)
                                  if prj.is_locked?
                            Severity: Minor
                            Found in src/api/app/models/bs_request.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 check_supersede_state has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def check_supersede_state
                                if state == :superseded && (!superseded_by.is_a?(Numeric) || !(superseded_by > 0))
                                  errors.add(:superseded_by, 'Superseded_by should be set')
                                end
                            
                            
                            Severity: Minor
                            Found in src/api/app/models/bs_request.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 expand_targets has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def expand_targets
                                newactions = []
                                oldactions = []
                            
                                bs_request_actions.each do |action|
                            Severity: Minor
                            Found in src/api/app/models/bs_request.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 2 locations. Consider refactoring.
                            Open

                                  when :maintenance_release then
                                    action[:name] = "Release #{action[:spkg]}"
                                    action[:sourcediff] = xml.webui_infos(superseded_bs_request_action: xml.find_action_with_same_target(opts[:diff_to_superseded])) if with_diff
                            Severity: Minor
                            Found in src/api/app/models/bs_request.rb and 1 other location - About 15 mins to fix
                            src/api/app/models/bs_request.rb on lines 1040..1042

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

                            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

                                  if xml.target_project
                                    action[:tprj] = xml.target_project
                                    action[:tpkg] = xml.target_package if xml.target_package
                                    action[:trepo] = xml.target_repository if xml.target_repository
                            Severity: Minor
                            Found in src/api/app/models/bs_request.rb and 1 other location - About 15 mins to fix
                            src/api/app/models/bs_request.rb on lines 969..972

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

                            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

                                  when :maintenance_incident then
                                    action[:name] = "Incident #{action[:spkg]}"
                                    action[:sourcediff] = xml.webui_infos(superseded_bs_request_action: xml.find_action_with_same_target(opts[:diff_to_superseded])) if with_diff
                            Severity: Minor
                            Found in src/api/app/models/bs_request.rb and 1 other location - About 15 mins to fix
                            src/api/app/models/bs_request.rb on lines 1043..1045

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

                            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

                                  if xml.source_project
                                    action[:sprj] = xml.source_project
                                    action[:spkg] = xml.source_package if xml.source_package
                                    action[:srev] = xml.source_rev if xml.source_rev
                            Severity: Minor
                            Found in src/api/app/models/bs_request.rb and 1 other location - About 15 mins to fix
                            src/api/app/models/bs_request.rb on lines 974..977

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

                            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