Showing 288 of 288 total issues
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
Function display
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Node.prototype.display = function (depth) {
var parent = this,
stepAngle,
angle;
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
Method index
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
@content_type_class = content_type_from_controller(self.class)
pluralized_content_name = @content_type_class.name.downcase.pluralize
@page_title = "My #{pluralized_content_name}"
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
Method for_field_label
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.for_field_label(label:, content_model: nil)
case content_model.name
when Universe.name
Autocomplete::UniverseAutocompleteService.for_field_label(label)
when Character.name
Function autosave
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
const autosave = function() {
if (autosave_event === null) {
console.log('Queueing autosave');
$('.js-autosave-icon').addClass('grey-text');
Method content_param_list
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def content_param_list
[
:name, :universe_id, :archived_at, :privacy, :favorite, :page_type
] + [ #<relations>
custom_attribute_values: [:name, :value],
Method cache_linkable_content_for_each_content_type
has 33 lines of code (exceeds 25 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
Method link_entity
has 33 lines of code (exceeds 25 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
Method physical_pages_equivalent_for
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.physical_pages_equivalent_for(worldbuilding_page_type)
# TODO: This would be better estimated with [average] word counts from pages (or a real total),
# but we don't have that data computed (and definitely don't want to do so on each page load).
# Until we have a better solution, these page counts come from printing out notebook pages
# from http://www.notebook-paper.com/
Similar blocks of code found in 2 locations. Consider refactoring. Open
<Drawer anchor='right'
open={this.state['open']}
onClose={() => this.setDrawerVisible(false)}>
{this.list()}
</Drawer>
- 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 61.
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
<Drawer anchor='right'
open={this.state['open']}
onClose={() => this.setDrawerVisible(false)}
>
{this.pageData()}
- 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 61.
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
Method backfill_fields_ordering!
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def backfill_fields_ordering!
sorted_fields = attribute_fields.select(&:persisted?).sort do |a, b|
# TODO: we shouldn't need this code anymore
a_value = case a.field_type
when 'name' then 0
- 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 content
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def content(
content_types: Rails.application.config.content_type_names[:all],
page_scoping: { user_id: self.id },
universe_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
Similar blocks of code found in 2 locations. Consider refactoring. Open
$('a.js-remove-contributor[data-remote]').on('ajax:success', function(e, data, status, xhr) {
// Remove the image from the UI
$(this).closest('.collection-item').fadeOut().remove(); // todo use animate.css for something more fun
});
- 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 60.
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
$('a.js-remove-image[data-remote]').on('ajax:success', function(e, data, status, xhr) {
// Remove the image from the UI
$(this).closest('.row').fadeOut().remove(); // todo use animate.css for something more fun
});
- 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 60.
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
Method index
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
@page_title = "My documents"
@recent_documents = current_user
.linkable_documents.order('updated_at DESC')
.includes([:user, :page_tags, :universe])
Function keyboardControlManager
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function keyboardControlManager ( keyboardControls ) {
/**
* Listens to the keyboard events and pushes items into the stack
*
* @param {KeyboardEvent} event
Method new
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def new
@content = content_type_from_controller(self.class)
.new(user: current_user)
.tap { |content|
content.name = "New #{content.class.name}"