Showing 183 of 288 total issues
Method timeline
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def timeline
timeline = Timeline.find_by(id: params[:id].to_i)
events = timeline.timeline_events
render json: {
Method link_field_update
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def link_field_update
@attribute_field = AttributeField.find_by(id: params[:field_id].to_i)
attribute_value = @attribute_field.attribute_values.order('created_at desc').find_or_initialize_by(entity_params)
attribute_value.user_id ||= current_user.id
Method update
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
# TODO: most things are stripped out now that we're using per-field updates, so we should
# audit what's left of this function and what needs to stay
content_type = content_type_from_controller(self.class)
@content = content_type.with_deleted.find(params[:id])
Method show
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
@page_title = @folder.title || 'Untitled folder'
@parent_folder = @folder.parent_folder
@child_folders = Folder.where(parent_folder: @folder)
Method create_prepay_invoice
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.create_prepay_invoice(n_months)
# Create a Paypal invoice to redirect to for payment
request = PayPalCheckoutSdk::Orders::OrdersCreateRequest::new
request.request_body({
intent: "CAPTURE",
Method content_to_outline
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def content_to_outline
content_types = current_user.content.except('Document').except('Timeline').keys
text = ""
content_types.each do |content_type|
Function _selectOption
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
_selectOption(optionEl) {
let key = optionEl.id;
if (!$(optionEl).hasClass('disabled') && !$(optionEl).hasClass('optgroup') && key.length) {
let selected = true;
Method perform
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform(*args)
report_date = Date.current - 1.day
timespan = report_date.beginning_of_day..report_date.end_of_day
report = EndOfDayAnalyticsReport.find_or_initialize_by(day: report_date)
Method create_default_attribute_categories
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.create_default_attribute_categories(user)
# Don't create any attribute categories for AttributeCategories or AttributeFields that share the ContentController
return [] if ['attribute_category', 'attribute_field'].include?(content_name)
YAML.load_file(Rails.root.join('config', 'attributes', "#{content_name}.yml")).map do |category_name, defaults|
- 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 perform
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform(*args)
report_date = args.shift.to_date
timespan = report_date.beginning_of_day..report_date.end_of_day
report = EndOfDayAnalyticsReport.find_or_initialize_by(day: report_date)
Method perform
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform(*args)
analysis_id = args.shift
analysis = DocumentAnalysis.find(analysis_id)
return unless analysis.present?
Method redeem_code
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def redeem_code
code = PageUnlockPromoCode.find_by(code: params.require(:promotional_code).permit(:promo_code)[:promo_code])
if code.nil?
redirect_back(fallback_location: subscription_path, alert: "This isn't a valid promo code.")
Method question_for
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.question_for(content)
return unless content.present?
categories_for_this_type = AttributeCategory.where(
user: content.user,
Function bind
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Function.prototype.bind = function bind(that) {
var target = this;
if (typeof target != "function") {
Function isEventSupported
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
isEventSupported = (function() {
var TAGNAMES = {
'select': 'input', 'change': 'input',
'submit': 'form', 'reset': 'form',
Method add_account
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_account
# Tie any universe contributor invites with this email to this user
if resource.persisted?
potential_contributor_records = Contributor.where(email: resource.email.downcase, user_id: nil)
Method analyze
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.analyze(analysis_id)
analysis = DocumentAnalysis.find(analysis_id)
document = analysis.document
# Length counters
Method show
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def show
content_type = content_type_from_controller(self.class)
return redirect_to(root_path, notice: "That page doesn't exist!") unless valid_content_types.include?(content_type.name)
@content = content_type.find_by(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 universe_field_value
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def universe_field_value
universe_field_cache = universe_field
return nil unless self.respond_to?(:universe_id)
return self.universe_id if universe_field_cache.nil?
- 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 keyboardControlManager
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function keyboardControlManager ( keyboardControls ) {
/**
* Listens to the keyboard events and pushes items into the stack
*
* @param {KeyboardEvent} event
- 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"