app/view_utils/transaction_view_utils.rb
Method create_message_from_action
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def create_message_from_action(transition, old_state, author, starter, payment_sum, payment_gateway, community, show_sum)
preauthorize_accepted = ->(new_state) { new_state == "paid" && old_state == "preauthorized" }
post_pay_accepted = ->(new_state) {
# The condition here is simply "if new_state is paid", since due to migrations from old system there might be
# transitions in "paid" state without previous state.
Method create_content_from_action
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
Open
def create_content_from_action(state, old_state, payment_sum, payment_gateway, author, community, show_sum)
preauthorize_accepted = ->(new_state) { new_state == "paid" && old_state == "preauthorized" }
post_pay_accepted = ->(new_state) {
# The condition here is simply "if new_state is paid", since due to migrations from old system there might be
# transitions in "paid" state without previous state.
- 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 create_content_from_action
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def create_content_from_action(state, old_state, payment_sum, payment_gateway, author, community, show_sum)
preauthorize_accepted = ->(new_state) { new_state == "paid" && old_state == "preauthorized" }
post_pay_accepted = ->(new_state) {
# The condition here is simply "if new_state is paid", since due to migrations from old system there might be
# transitions in "paid" state without previous state.
Method create_message_from_action
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def create_message_from_action(transition, old_state, author, starter, payment_sum, payment_gateway, community, show_sum)
Method create_content_from_action
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def create_content_from_action(state, old_state, payment_sum, payment_gateway, author, community, show_sum)
Method create_messages_from_actions
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def create_messages_from_actions(transitions, author, starter, payment_sum, payment_gateway, community, show_sum=true)