indentlabs/notebook

View on GitHub

Showing 183 of 288 total issues

Function fieldData has 98 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  fieldData(field) {
    switch (field.type) {
      case "name":
      case "text_area":
        // console.log(field.value);
Severity: Major
Found in app/javascript/components/PageLookupSidebar.js - About 3 hrs to fix

    Function getForceVector has 97 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      Node.prototype.getForceVector = function () {
        var i, x1, y1, xsign, dist, theta, f,
          xdist, rightdist, bottomdist, otherend,
          fx = 0,
          fy = 0,
    Severity: Major
    Found in public/navigator/js-mindmap.js - About 3 hrs to fix

      Method content_to_outline has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

        def content_to_outline
          content_types = current_user.content.except('Document').except('Timeline').keys
      
          text = ""
          content_types.each do |content_type|
      Severity: Minor
      Found in app/controllers/export_controller.rb - About 3 hrs 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 migrate_fields_for_content has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.migrate_fields_for_content(content_model, user, force: false)
          return unless content_model.present? && user.present?
          return unless content_model.user == user
          return if content_model.is_a?(ContentPage)
          return if !force && content_model.persisted? && content_model.created_at > 'May 1, 2018'.to_datetime
      Severity: Minor
      Found in app/services/temporary_field_migration_service.rb - About 3 hrs 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 create has a Cognitive Complexity of 25 (exceeds 5 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 3 hrs 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 commission has 87 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def commission
          @generated_images_count  = current_user.basil_commissions.with_deleted.count
          if !current_user.on_premium_plan? && @generated_images_count > BasilService::FREE_IMAGE_LIMIT
            redirect_back fallback_location: basil_path, notice: "You've reached your free image limit. Please upgrade to generate more images."
            return
      Severity: Major
      Found in app/controllers/basil_controller.rb - About 3 hrs to fix

        Function exports has 83 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function(api) {
          var validEnv = ['development', 'test', 'production']
          var currentEnv = api.env()
          var isDevelopmentEnv = api.env('development')
          var isProductionEnv = api.env('production')
        Severity: Major
        Found in babel.config.js - About 3 hrs to fix

          Function _setupDropdown has 80 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              _setupDropdown() {
                this.wrapper = document.createElement('div');
                $(this.wrapper).addClass('select-wrapper ' + this.options.classes);
                this.$el.before($(this.wrapper));
                // Move actual select element into overflow hidden wrapper
          Severity: Major
          Found in app/assets/javascripts/z_select.js - About 3 hrs to fix

            Method initialize has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

              def initialize(content)
                # One query per table; lets not muck with joins yet
                # self.attribute_values = Attribute.where(entity_type: content.page_type, entity_id: content.id)
                # self.fields           = AttributeField.where(id: self.attribute_values.pluck(:attribute_field_id).uniq)
                self.categories       = content.class.attribute_categories(content.user)
            Severity: Minor
            Found in app/models/serializers/content_serializer.rb - About 3 hrs 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

            File z_select.js has 289 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            (function($) {
              'use strict';
            
              let _defaults = {
                classes: '',
            Severity: Minor
            Found in app/assets/javascripts/z_select.js - About 2 hrs to fix

              Function getStepContent has 73 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                getStepContent(step) {
                  switch (step) {
                    case 0:
                      return(
                        <div className="spaced-paragraphs">
              Severity: Major
              Found in app/javascript/components/PageCollectionCreationForm.js - About 2 hrs to fix

                Method stats has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def stats
                    @commissions = BasilCommission.all.with_deleted
                
                    @queued = BasilCommission.where(completed_at: nil)
                    @completed = BasilCommission.where.not(completed_at: nil).with_deleted
                Severity: Major
                Found in app/controllers/basil_controller.rb - About 2 hrs to fix

                  Method fill_relations has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def fill_relations(ar_class, ar_relation)
                      attribute_categories = ar_class.attribute_categories(current_user)
                  
                      ar_relation.map do |content|
                        content_repr = {}
                  Severity: Minor
                  Found in app/controllers/export_controller.rb - About 2 hrs 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 from_html has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def self.from_html(html, line_length = 80, from_charset = 'UTF-8')
                        return "" if html.nil?
                  
                        txt = html.dup
                  
                  
                  Severity: Minor
                  Found in app/services/documents/plaintext_service.rb - About 2 hrs 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 initialize has 71 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def initialize(content)
                      # One query per table; lets not muck with joins yet
                      # self.attribute_values = Attribute.where(entity_type: content.page_type, entity_id: content.id)
                      # self.fields           = AttributeField.where(id: self.attribute_values.pluck(:attribute_field_id).uniq)
                      self.categories       = content.class.attribute_categories(content.user)
                  Severity: Major
                  Found in app/models/serializers/content_serializer.rb - About 2 hrs to fix

                    Method to_csv has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def to_csv ar_relation
                        # todo change this and (ALL `.build.class` to `.klass`)
                        ar_class = ar_relation.build.class
                        attribute_categories = ar_class.attribute_categories(current_user)
                    
                    
                    Severity: Minor
                    Found in app/controllers/export_controller.rb - About 2 hrs 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

                    Class DocumentsController has 24 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    class DocumentsController < ApplicationController
                      before_action :authenticate_user!, except: [:show, :analysis]
                    
                      # todo Uh, this is a hack. The CSRF token on document editor model to add entities is being rejected... for whatever reason.
                      skip_before_action :verify_authenticity_token, only: [:link_entity]
                    Severity: Minor
                    Found in app/controllers/documents_controller.rb - About 2 hrs to fix

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

                        render () {
                          return (
                            <React.Fragment>
                              <ul id="document-entities-right" className="sidenav">
                                <li className="teal">
                      Severity: Major
                      Found in app/javascript/components/DocumentEntitiesSidebar.js - About 2 hrs to fix

                        File user.rb has 274 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        class User < ApplicationRecord
                          acts_as_paranoid
                        
                          # Include default devise modules. Others available are:
                          # :confirmable, :lockable, :timeoutable and :omniauthable
                        Severity: Minor
                        Found in app/models/users/user.rb - About 2 hrs to fix

                          Method attribute_categories has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              def self.attribute_categories(user, show_hidden: false)
                                # TODO: this is a code smell; we should probably either be whitelisting or fixing whatever is calling
                                #       this with the wrong models
                                return [] if ['attribute_category', 'attribute_field'].include?(content_name)
                          
                          
                          Severity: Major
                          Found in app/models/concerns/has_attributes.rb - About 2 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language