indentlabs/notebook

View on GitHub

Showing 183 of 288 total issues

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
Severity: Minor
Found in app/assets/javascripts/modernizr.js - About 1 hr to fix

    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
    Severity: Minor
    Found in app/services/autocomplete/autocomplete_service.rb - About 1 hr to fix

      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');
      Severity: Minor
      Found in app/assets/javascripts/document_editor.js - About 1 hr to fix

        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],
        Severity: Minor
        Found in app/controllers/lores_controller.rb - About 1 hr to fix

          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
          Severity: Minor
          Found in app/controllers/application_controller.rb - About 1 hr to fix

            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
            Severity: Minor
            Found in app/controllers/documents_controller.rb - About 1 hr to fix

              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/
              Severity: Minor
              Found in app/services/green_service.rb - About 1 hr to fix

                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
                Severity: Minor
                Found in app/models/page_data/attribute_category.rb - About 1 hr to fix

                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
                    )
                Severity: Minor
                Found in app/models/concerns/has_content.rb - About 1 hr to fix

                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 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])
                Severity: Minor
                Found in app/controllers/documents_controller.rb - About 1 hr to fix

                  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
                  Severity: Minor
                  Found in app/assets/javascripts/keyboardControls.js - About 1 hr to fix

                    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}"
                    Severity: Minor
                    Found in app/controllers/content_controller.rb - About 1 hr to fix

                      Method value_for has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      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
                      Severity: Minor
                      Found in app/models/serializers/content_serializer.rb - About 1 hr to fix

                        Method base_open_characters_export has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def base_open_characters_export
                            {
                              "name": "New character",
                              "modelName": "gpt-3.5-turbo",
                              "fitMessagesInContextMethod": "summarizeOld",
                        Severity: Minor
                        Found in app/controllers/conversation_controller.rb - About 1 hr to fix

                          Function injectElementWithStyles has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                          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
                          Severity: Minor
                          Found in app/assets/javascripts/modernizr.js - About 1 hr to fix

                            Function updatePosition has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                            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);
                            Severity: Minor
                            Found in public/navigator/js-mindmap.js - About 1 hr to fix

                              Method create has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def create
                                  content_type = content_type_from_controller(self.class)
                                  initialize_object
                              
                                  unless current_user.can_create?(content_type) \
                              Severity: Minor
                              Found in app/controllers/content_controller.rb - About 1 hr to fix

                                Method content_param_list has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                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],
                                Severity: Minor
                                Found in app/controllers/characters_controller.rb - About 1 hr to fix

                                  Function render has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    render () {
                                      return (
                                        <footer className="grey-text no-print">
                                          <div className="container center">
                                            <div className="row">
                                  Severity: Minor
                                  Found in app/javascript/components/Footer.js - About 1 hr to fix

                                    Method link_field_update has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      def link_field_update
                                        @attribute_field = AttributeField.find_by(id: params[:field_id].to_i)
                                        attribute_value = @attribute_field.attribute_values.order('created_at desc').find_or_initialize_by(entity_params)
                                        attribute_value.user_id ||= current_user.id
                                    
                                    
                                    Severity: Minor
                                    Found in app/controllers/content_controller.rb - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language