Class RequestController
has 43 methods (exceeds 20 allowed). Consider refactoring. Open
class Webui::RequestController < Webui::WebuiController
helper 'webui/package'
before_action :require_login,
except: %i[show sourcediff diff request_action request_action_changes inline_comment build_results rpm_lint changes mentioned_issues]
Method changerequest
has a Cognitive Complexity of 18 (exceeds 8 allowed). Consider refactoring. Open
def changerequest
changestate = (%w[accepted declined revoked new] & params.keys).last
if change_state(changestate, params)
# TODO: Make this work for each submit action individually
- 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
Consider simplifying this complex logical expression. Open
if Flipper.enabled?(:request_show_redesign, User.session)
@history_elements = @bs_request.history_elements.includes(:user)
@active_tab = 'conversation'
render :beta_show
else
Method show
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
# TODO: Remove this `if` condition, and the `else` clause once request_show_redesign is rolled out
if Flipper.enabled?(:request_show_redesign, User.session)
@history_elements = @bs_request.history_elements.includes(:user)
@active_tab = 'conversation'
Method prepare_request_data
has a Cognitive Complexity of 12 (exceeds 8 allowed). Consider refactoring. Wontfix
def prepare_request_data
@is_target_maintainer = @bs_request.is_target_maintainer?(User.session)
@my_open_reviews = ReviewsFinder.new(@bs_request.reviews).open_reviews_for_user(User.session).reject(&:staging_project?)
# Handling request actions
- 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
target.add_maintainer(@bs_request.creator) if target.can_be_modified_by?(User.possibly_nobody)
Avoid deeply nested control flow statements. Confirmed
target = if tpkg
Package.find_by_project_and_name(tprj, tpkg)
else
Project.find_by_name(tprj)
end
Method show
has a Cognitive Complexity of 9 (exceeds 8 allowed). Consider refactoring. Open
def show
# TODO: Remove this `if` condition, and the `else` clause once request_show_redesign is rolled out
if Flipper.enabled?(:request_show_redesign, User.session)
@history_elements = @bs_request.history_elements.includes(:user)
@active_tab = 'conversation'
- 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"