Method mass_update
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
def mass_update
params[:page] = '1' if params[:page].blank?
params[:sort_column] = 'name' unless valid_sort_column(params[:sort_column], 'tag')
params[:sort_direction] = 'ASC' unless valid_sort_direction(params[:sort_direction])
options = { show: params[:show], page: params[:page], sort_column: params[:sort_column], sort_direction: params[:sort_direction], status: params[:status] }
- 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
File tags_controller.rb
has 333 lines of code (exceeds 250 allowed). Consider refactoring. Open
class TagsController < ApplicationController
include TagWrangling
before_action :load_collection
before_action :check_user_status, except: [:show, :index, :show_hidden, :search, :feed]
Method show_hidden
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def show_hidden
unless params[:creation_id].blank? || params[:creation_type].blank? || params[:tag_type].blank?
model = case params[:creation_type].downcase
when "series"
Series
- 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 mass_update
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
def mass_update
params[:page] = '1' if params[:page].blank?
params[:sort_column] = 'name' unless valid_sort_column(params[:sort_column], 'tag')
params[:sort_direction] = 'ASC' unless valid_sort_direction(params[:sort_direction])
options = { show: params[:show], page: params[:page], sort_column: params[:sort_column], sort_direction: params[:sort_direction], status: params[:status] }
Method wrangle
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def wrangle
@page_subtitle = ts('%{tag_name} - Wrangle', tag_name: @tag.name)
@counts = {}
@tag.child_types.map { |t| t.underscore.pluralize.to_sym }.each do |tag_type|
@counts[tag_type] = @tag.send(tag_type).count
- 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_hidden
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show_hidden
unless params[:creation_id].blank? || params[:creation_type].blank? || params[:tag_type].blank?
model = case params[:creation_type].downcase
when "series"
Series
Method edit
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def edit
@page_subtitle = ts('%{tag_name} - Edit', tag_name: @tag.name)
if @tag.is_a?(Banned) && !logged_in_as_admin?
flash[:error] = ts('Please log in as admin')
- 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
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create
type = tag_params[:type] if params[:tag]
unless type
flash[:error] = ts("Please provide a category.")
- 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 11 (exceeds 5 allowed). Consider refactoring. Open
def show
@page_subtitle = @tag.name
if @tag.is_a?(Banned) && !logged_in_as_admin?
flash[:error] = ts('Please log in as admin')
redirect_to(tag_wranglings_path) && 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 feed
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def feed
begin
@tag = Tag.find(params[:id])
rescue ActiveRecord::RecordNotFound
raise ActiveRecord::RecordNotFound, "Couldn't find tag with id '#{params[: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 update
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def update
# update everything except for the synonym,
# so that the associations are there to move when the synonym is created
syn_string = params[:tag].delete(:syn_string)
new_tag_type = params[:tag].delete(: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"