Showing 183 of 288 total issues
Method value_for
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def value_for(attribute_field, content)
case attribute_field.field_type
when 'link'
page_links = attribute_field.attribute_values.find_by(entity_type: content.class.name, entity_id: content.id)
if page_links.nil?
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 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 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|
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 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 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)
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 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 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 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 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 add_account
has a Cognitive Complexity of 9 (exceeds 5 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)
- 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"