Method fetch
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def fetch
set_site_title(I18n.t('upload.niconico.title'))
@track = Track.new(track_params)
if @track.niconico.empty?
flash.now[:error] = I18n.t('upload.niconico.blank_niconico_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 fetch
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
def fetch
set_site_title(I18n.t('upload.niconico.title'))
@track = Track.new(track_params)
if @track.niconico.empty?
flash.now[:error] = I18n.t('upload.niconico.blank_niconico_id')
Avoid too many return
statements within this method. Open
render 'new' and return
Avoid too many return
statements within this method. Open
render 'new' and return
Avoid too many return
statements within this method. Open
render 'new' and return
Method update
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def update
set_site_title(I18n.t('upload.niconico.title'))
@track = Track.find(track_id)
redirect_to_index_if_not_permitted(@track); return if performed?
@track.attributes = track_params
- 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_niconico_thumb_info
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_niconico_thumb_info(video_id)
res_body = http_get_response_body("http://ext.nicovideo.jp/api/getthumbinfo/#{video_id}") rescue nil
return false if res_body.nil?
thumb_info_doc = Nokogiri::XML(res_body)
thumb_element = thumb_info_doc.xpath('/nicovideo_thumb_response/thumb')
- 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"