File materials_controller.rb
has 454 lines of code (exceeds 250 allowed). Consider refactoring. Open
class API::V1::MaterialsController < API::APIController
include Materials::DataHelpers
#
# Default number of related materials to return
Method add_materials_standard
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_materials_standard
key = ENV['ASN_API_KEY']
uri = params[:identifier]
type = params[:material_type]
Method get_standard_statements
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_standard_statements
key = ENV['ASN_API_KEY']
document_id = params[:asn_document_id]
statement_notation_q = params[:asn_statement_notation_query]
Method add_favorite
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_favorite
if !current_user || current_user.anonymous?
render json: {:message => "Cannot add favorite for non-logged in user."},
:status => 400
Method remove_favorite
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def remove_favorite
if !current_user || current_user.anonymous?
render json: {:message => "Cannot remove favorite for non-logged in user."}, :status => 400
return
Method show
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
type = params[:material_type]
id = params[:id]
include_related = params.has_key?(:include_related) ?
Method get_standard_statements
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def get_standard_statements
key = ENV['ASN_API_KEY']
document_id = params[:asn_document_id]
statement_notation_q = params[:asn_statement_notation_query]
- 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 add_materials_standard
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def add_materials_standard
key = ENV['ASN_API_KEY']
uri = params[:identifier]
type = params[:material_type]
- 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 show
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def show
type = params[:material_type]
id = params[:id]
include_related = params.has_key?(:include_related) ?
- 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 process_asn_response
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def process_asn_response(hits, applied_map = {})
#
# Find our local peristed copy of the document these statements belong to.
#
- 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 featured
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def featured
materials = ExternalActivity.published.where(:is_featured => true).includes([:user]).to_a
if params[:prioritize].present?
prioritize = params[:prioritize].split(',').map { |p| p.to_i rescue 0 }
- 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 add_favorite
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def add_favorite
if !current_user || current_user.anonymous?
render json: {:message => "Cannot add favorite for non-logged in user."},
:status => 400
- 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 too many return
statements within this method. Open
return
Method assign_to_class
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def assign_to_class
# only add/delete if assign parameter exists to avoid deleting data on a bad request
status = 200
if params[:assign].present?
portal_clazz = Portal::Clazz.find(params[:class_id])
- 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 remove_favorite
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def remove_favorite
if !current_user || current_user.anonymous?
render json: {:message => "Cannot remove favorite for non-logged in user."}, :status => 400
return
- 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 get_favorites
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_favorites
if !current_user || current_user.anonymous?
render json: {:message => "Cannot retrieve favorites for non-logged in user."}, :status => 400
return
- 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"