Method view_page
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def view_page
path = get_path(params[:page], params[:format])
@version = params[:version].to_i
@npage = params[:npage] || "1"
- 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
Class ContentViewerController
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
class ContentViewerController < ApplicationController
needs_profile
helper ProfileHelper
helper TagsHelper
Method view_page
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def view_page
path = get_path(params[:page], params[:format])
@version = params[:version].to_i
@npage = params[:npage] || "1"
Method redirect_to_translation
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def redirect_to_translation
locale = FastGettext.locale
if !@page.language.nil? && @page.language != locale
translations = [@page.native_translation] + @page.native_translation.translations
urls = translations.map { |t| URI.parse(url_for(t.url)).path }
- 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 rendered_file_download
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def rendered_file_download(view = nil)
if @page.download? view
data = @page.data
# TODO test the condition
- 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
Avoid too many return
statements within this method. Open
return
Avoid too many return
statements within this method. Open
return if rendered_versioned_article
Avoid too many return
statements within this method. Open
return if rendered_file_download(params[:view])
Avoid too many return
statements within this method. Open
return render partial: "comment/comment", collection: @comments
Avoid too many return
statements within this method. Open
redirect_to_translation && (return) if @page.profile.redirect_l10n