Showing 183 of 288 total issues
Method update
has a Cognitive Complexity of 14 (exceeds 5 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])
- 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 replacement_for_token
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def self.replacement_for_token(token, viewing_user, plaintext=false)
return unknown_link_template(token) unless token.key?(:content_type) && token.key?(:content_id)
begin
content_class = token[:content_type].titleize.constantize
rescue
- 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 render
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
render () {
return (
<FormControl component="fieldset">
<FormLabel component="legend">
<i className={`material-icons ${this.props.content_color}-text left`}>
Method initialize
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(categories)
self.categories = categories
categories = categories.dup.to_a
self.fields = AttributeField.where(attribute_category_id: categories.map(&:id)).to_a
Method initialize
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def initialize(categories)
self.categories = categories
categories = categories.dup.to_a
self.fields = AttributeField.where(attribute_category_id: categories.map(&:id)).to_a
- 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 set_universe_session
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def set_universe_session
if params[:universe].present? && user_signed_in?
if params[:universe] == 'all'
session.delete(:universe_id)
elsif params[:universe].is_a?(String) && params[:universe].to_i.to_s == params[:universe]
- 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 creatable_by?
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.creatable_by?(user)
return false unless user.present?
return false if ENV.key?('CONTENT_BLACKLIST') && ENV['CONTENT_BLACKLIST'].split(',').include?(user.email)
if resource.page_type == 'Universe'
- 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 add_subscription
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.add_subscription(user, plan_id)
related_plan = BillingPlan.find_by(stripe_plan_id: plan_id, available: true)
raise "Plan #{plan_id} not available for user #{user.id}" if related_plan.nil?
# Sync with Stripe (todo pipe into StripeService)
- 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 prosify_irc_log
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.prosify_irc_log(thredded_topic, strip_parentheticals=true)
prose = "-!- Topic: #{thredded_topic.title}#{ENDLINE}"
user_display_name_cache = {}
thredded_topic.posts.find_each do |post|
- 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 render
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
render () {
return (
<div className='card-panel'>
<Stepper activeStep={this.state.active_step} orientation="vertical">
{this.steps().map((label, index) => (
Function list
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
list() {
return (
<div role="presentation">
<List>
<ListItem>
Function loadPage
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
async loadPage(page_type, page_id) {
this.setDrawerVisible(true);
this.setState({
show_data: false,
category_open: {}
Method add_subscription
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.add_subscription(user, plan_id)
related_plan = BillingPlan.find_by(stripe_plan_id: plan_id, available: true)
raise "Plan #{plan_id} not available for user #{user.id}" if related_plan.nil?
# Sync with Stripe (todo pipe into StripeService)
Method analyze_entity
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.analyze_entity(document_entity)
watson_client = new_client
entity = ::DocumentEntity.find(document_entity.to_i) # raises unless found :+1:
analysis = entity.document_analysis
Method perform
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def perform(*args)
invoice_id = args.shift
invoice = PaypalInvoice.find_by(paypal_id: invoice_id)
info = PaypalService.order_info(invoice_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 relates
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.relates relation, with:#, where: {}
singularized_relation = relation.to_s.singularize
connecting_class = with.to_s.singularize.camelize.constantize
connecting_class_name = with
- 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 link_entity
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def link_entity
# Preconditions lol
unless (Rails.application.config.content_types[:all].map(&:name) + [Timeline.name, Document.name]).include?(linked_entity_params[:entity_type])
raise "Invalid entity type #{linked_entity_params[:entity_type]}"
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"
Further reading
Method initialize
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(content, include_blank_fields: false)
self.categories = content.class.attribute_categories(content.user).where(hidden: [false, nil]).eager_load(attribute_fields: :attribute_values)
self.fields = AttributeField.where(attribute_category_id: self.categories.map(&:id), hidden: [false, nil])
self.attribute_values = Attribute.where(attribute_field_id: self.fields.map(&:id), entity_type: content.page_type, entity_id: content.id).order('created_at desc')
self.universe = (content.class.name == Universe.name) ? nil : content.universe
Function display
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Node.prototype.display = function (depth) {
var parent = this,
stepAngle,
angle;
Function webforms
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function webforms() {
/*>>input*/
// Run through HTML5's new input attributes to see if the UA understands any.
// We're using f which is the <input> element created early on
// Mike Taylr has created a comprehensive resource for testing these attributes