Showing 16 of 64 total issues
Method update
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
def update
problem = Problem.find(params[:id])
if !params[:privacy].nil?
authorize! :set_privacy, problem
- 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 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
problem = Problem.find(params[:id])
if !params[:privacy].nil?
authorize! :set_privacy, problem
Method create
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def create
parent_uid = params[:parent_uid]
if parent_uid
previous_version = Problem.find_by_uid(params[:parent_uid])
if !previous_version
- 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 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
parent_uid = params[:parent_uid]
if parent_uid
previous_version = Problem.find_by_uid(params[:parent_uid])
if !previous_version
Method filter
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.filter(user, filters, bump_problem)
problems = Problem.search do
any_of do
with(:instructor_id, user.id)
with(:is_public, true)
Method set_filters
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def set_filters
session[:filters] = session[:filters].merge params.slice(:search, :tags, :sort_by)
if session[:filters][:tags].is_a? String
session[:filters][:tags] = self.class.parse_list session[:filters][:tags]
- 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 filter
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.filter(user, filters, bump_problem)
problems = Problem.search do
any_of do
with(:instructor_id, user.id)
with(:is_public, true)
- 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 store_as_json
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.store_as_json(user, file)
filename = file.path
Quiz.nuke_from_orbit
Quiz.instance_eval "#{IO.read(filename)}"
collections = []
- 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
Function setup
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
setup: function() {
$('.bloom-buttons').each(function() {
var container = $(this);
container.find('form').submit(function() {
$.ajax({
Method update_whitelist
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def update_whitelist
authorize! :manage, Whitelist
username = params[:username] ? params[:username].strip : nil
provider = params[:provider]
privilege = params[:privilege]
- 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_whitelist
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_whitelist
authorize! :manage, Whitelist
username = params[:username] ? params[:username].strip : nil
provider = params[:provider]
privilege = params[:privilege]
Method set_filters
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_filters
session[:filters] = session[:filters].merge params.slice(:search, :tags, :sort_by)
if session[:filters][:tags].is_a? String
session[:filters][:tags] = self.class.parse_list session[:filters][:tags]
Method render_from_json
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.render_from_json(json_code, uid, prev_uid)
result = ""
return "" if json_code == nil || json_code.length <= 2
json_hash = JSON.parse(json_code)
answers = json_hash["answers"]
- 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_multiple_tags
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def update_multiple_tags
new_tags = self.class.parse_list params[:tag_names]
selected = params[:checked_problems] ? params[:checked_problems].keys : []
if new_tags == []
flash[:error] = "You need to enter a tag."
- 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 export
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def export(format)
if problems.empty?
return nil
else
if format == 'ruql'
- 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 html5
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def html5
if rendered_text
return rendered_text
end
- 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"