Showing 183 of 288 total issues
Method index
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
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}"
Method for_field_label
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Method cache_linkable_content_for_each_content_type
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def cache_linkable_content_for_each_content_type
cache_contributable_universe_ids
cache_current_user_content
linkable_classes = @activated_content_types
Method content_param_list
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def content_param_list
[
:name, :universe_id, :archived_at, :privacy, :favorite, :page_type
] + [ #<relations>
custom_attribute_values: [:name, :value],
Method link_entity
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Function autosave
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const autosave = function() {
if (autosave_event === null) {
console.log('Queueing autosave');
$('.js-autosave-icon').addClass('grey-text');
Method physical_pages_equivalent_for
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
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/
Method backfill_fields_ordering!
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
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
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
Method value_for
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def value_for(attribute_field, content)
case attribute_field.field_type
when 'link'
page_links = self.attribute_values.detect do |value|
value.entity_type == content.class.name && value.entity_id == content.id && value.attribute_field_id == attribute_field.id
Method new
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def new
@content = content_type_from_controller(self.class)
.new(user: current_user)
.tap { |content|
content.name = "New #{content.class.name}"
Method index
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Open
function keyboardControlManager ( keyboardControls ) {
/**
* Listens to the keyboard events and pushes items into the stack
*
* @param {KeyboardEvent} event
Method base_open_characters_export
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def base_open_characters_export
{
"name": "New character",
"modelName": "gpt-3.5-turbo",
"fitMessagesInContextMethod": "summarizeOld",
Method create
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def create
content_type = content_type_from_controller(self.class)
initialize_object
unless current_user.can_create?(content_type) \
Function injectElementWithStyles
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
injectElementWithStyles = function( rule, callback, nodes, testnames ) {
var style, ret, node, docOverflow,
div = document.createElement('div'),
// After page load injecting a fake body doesn't work so check if body exists
Method content_param_list
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def content_param_list
[
#todo remove all these (for all pages) now that we use custom attributes for them all (minus links)
# all but
#custom_attribute_values: [:name, :value],
Function updatePosition
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Node.prototype.updatePosition = function () {
var forces, showx, showy;
if (this.el.hasClass("ui-draggable-dragging")) {
this.x = parseInt(this.el.css('left'), 10) + (this.el.width() / 2);
Function render
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render () {
return (
<footer className="grey-text no-print">
<div className="container center">
<div className="row">
Method value_for
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
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?