Showing 288 of 288 total issues
Method replace_for
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.replace_for(text, user)
gremlins_phase = 0
replaced_text = text.dup
# Page tag replacements
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 cache_linkable_content_for_each_content_type
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def cache_linkable_content_for_each_content_type
cache_contributable_universe_ids
cache_current_user_content
linkable_classes = @activated_content_types
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
axisGrid.selectAll(".levels")
.data(d3.range(1,(cfg.levels+1)).reverse())
.enter()
.append("circle")
.attr("class", "gridCircle")
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 70.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
axisGrid.selectAll(".axisLabel")
.data(d3.range(1,(cfg.levels+1)).reverse())
.enter().append("text")
.attr("class", "axisLabel")
.attr("x", 4)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 70.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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 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
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
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 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"