indentlabs/notebook

View on GitHub

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
Severity: Minor
Found in app/controllers/documents_controller.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

Function display has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  Node.prototype.display = function (depth) {
    var parent = this,
      stepAngle,
      angle;

Severity: Minor
Found in public/navigator/js-mindmap.js - About 1 hr to fix

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

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

        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

                      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>
                      Severity: Major
                      Found in app/javascript/components/QuickActionsSidebar.js and 1 other location - About 1 hr to fix
                      app/javascript/components/PageLookupSidebar.js on lines 368..373

                      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

                      Further Reading

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                            <Drawer anchor='right'
                                    open={this.state['open']}
                                    onClose={() => this.setDrawerVisible(false)}
                            >
                              {this.pageData()}
                      Severity: Major
                      Found in app/javascript/components/PageLookupSidebar.js and 1 other location - About 1 hr to fix
                      app/javascript/components/QuickActionsSidebar.js on lines 192..196

                      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

                      Further Reading

                      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

                      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
                      });
                      Severity: Major
                      Found in app/assets/javascripts/collaboration.js and 1 other location - About 1 hr to fix
                      app/assets/javascripts/image_uploads.js on lines 2..5

                      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

                      Further Reading

                      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
                      });
                      Severity: Major
                      Found in app/assets/javascripts/image_uploads.js and 1 other location - About 1 hr to fix
                      app/assets/javascripts/collaboration.js on lines 2..5

                      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

                      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
                            Severity
                            Category
                            Status
                            Source
                            Language