File api_v1.rb
has 479 lines of code (exceeds 250 allowed). Consider refactoring. Open
class API_v1 < Grape::API
version 'v1', using: :path, format: :json, vendor: 'hummingbird'
formatter :json, lambda {|object, env| MultiJson.dump(object) }
rescue_from ActiveRecord::RecordNotFound
Method present_story
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def present_story(story, current_user, title_language_preference)
json = {
id: story.id,
story_type: story.story_type,
user: present_miniuser(story.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 present_story
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def present_story(story, current_user, title_language_preference)
json = {
id: story.id,
story_type: story.story_type,
user: present_miniuser(story.user),
Method current_user
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def current_user
return env['current_user'] if env.has_key?('current_user')
if params[:auth_token] || cookies[:auth_token]
token = Token.new(params[:auth_token] || cookies[:auth_token])
- 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 present_anime
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def present_anime(anime, title_language_preference)
if anime
{
id: anime.id,
mal_id: anime.mal_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 find_user
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def find_user(id)
begin
if id == "me" and user_signed_in?
current_user
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"