Class BsRequest
has 82 methods (exceeds 20 allowed). Consider refactoring. Open
class BsRequest < ApplicationRecord
include BsRequest::Errors
MAX_DESCRIPTION_LENGTH_ALLOWED = 64_000
Method action_details
has a Cognitive Complexity of 52 (exceeds 8 allowed). Consider refactoring. Open
def action_details(opts = {}, xml:)
with_diff = opts.delete(:diffs)
action = { type: xml.action_type }
action[:id] = xml.id
action[:number] = xml.bs_request.number
- Read upRead up
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 a Cognitive Complexity of 42 (exceeds 8 allowed). Consider refactoring. Wontfix
def self.new_from_hash(hashed)
if hashed['id']
theid = hashed.delete('id') { raise 'not found' }
theid = Integer(theid)
else
- Read upRead up
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 27 (exceeds 8 allowed). Consider refactoring. Open
def change_review_state(new_review_state, opts = {})
with_lock do
new_review_state = new_review_state.to_sym
raise InvalidStateError, 'request is not in a changeable state (new, review or declined)' unless state == :review || (state.in?(%i[new declined]) && new_review_state == :new)
- Read upRead up
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 8 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]
- Read upRead up
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 action_details
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Confirmed
def action_details(opts = {}, xml:)
with_diff = opts.delete(:diffs)
action = { type: xml.action_type }
action[:id] = xml.id
action[:number] = xml.bs_request.number
Method render_xml
has a Cognitive Complexity of 24 (exceeds 8 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)
- Read upRead up
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 8 allowed). Consider refactoring. Open
def is_reviewer?(user)
return false if reviews.blank?
reviews.each do |r|
if r.by_user
- Read upRead up
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 8 allowed). Consider refactoring. Open
def apply_default_reviewers
reviewers = collect_default_reviewers!
# apply reviewers
reviewers.each do |r|
if r.instance_of?(User)
- Read upRead up
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 65 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
Method assignreview
has a Cognitive Complexity of 19 (exceeds 8 allowed). Consider refactoring. Open
def assignreview(opts = {})
raise InvalidStateError, 'request is not in review state' unless state == :review || state == :new
reviewer = User.find_by_login!(opts[:reviewer])
- Read upRead up
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 auto_accept
has a Cognitive Complexity of 18 (exceeds 8 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
- Read upRead up
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 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change_state(opts)
with_lock do
permission_check_change_state!(opts)
changestate_revoked(opts) if opts[:newstate] == 'revoked'
changestate_accepted(opts) if opts[:newstate] == 'accepted'
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)
Method change_state
has a Cognitive Complexity of 14 (exceeds 8 allowed). Consider refactoring. Open
def change_state(opts)
with_lock do
permission_check_change_state!(opts)
changestate_revoked(opts) if opts[:newstate] == 'revoked'
changestate_accepted(opts) if opts[:newstate] == 'accepted'
- Read upRead up
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 30 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
raise InvalidStateError, 'request is not in a changeable state (new, review or declined)' unless state == :review || (state.in?(%i[new declined]) && new_review_state == :new)
Method obsolete_reviews
has a Cognitive Complexity of 12 (exceeds 8 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)
- Read upRead up
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 12 (exceeds 8 allowed). Consider refactoring. Open
def changestate_accepted(opts)
# all maintenance_incident actions go into the same incident project
incident_project = nil
bs_request_actions.each do |action|
next unless action.is_maintenance_incident?
- Read upRead up
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. Confirmed
if r.by_package
pkg = Package.find_by_project_and_name(r.by_project, r.by_package)
return true if pkg && user.can_modify?(pkg)
else
prj = Project.find_by_name(r.by_project)
Avoid deeply nested control flow statements. Confirmed
if action[:forward]
action[:forward].each do |forward|
if forward[:project] == lprj && forward[:package] == lpkg
link_is_already_devel = true
break
Avoid deeply nested control flow statements. Confirmed
next if reviews.any? { |a| a.by_project == r.name && a.by_package.nil? }
Avoid deeply nested control flow statements. Confirmed
unless link_is_already_devel
action[:forward] ||= []
action[:forward] << { project: linkinfo['project'], package: linkinfo['package'], type: 'link' }
end
Avoid deeply nested control flow statements. Confirmed
elsif r.instance_of?(Package)
next if reviews.any? { |a| a.by_project == r.project.name && a.by_package == r.name }
reviews.new(by_project: r.project.name, by_package: r.name, state: :new)
else
Method check_creator
has a Cognitive Complexity of 9 (exceeds 8 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?
- Read upRead up
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"