indentlabs/notebook

View on GitHub

Showing 183 of 288 total issues

Method from_html has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.from_html(html, line_length = 80, from_charset = 'UTF-8')
      return "" if html.nil?

      txt = html.dup

Severity: Major
Found in app/services/documents/plaintext_service.rb - About 2 hrs to fix

    Method page_stats has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def page_stats
        @page_type = params[:page_type]
        # TODO verify page_type is valid
    
        @commissions = BasilCommission.where(entity_type: @page_type)
    Severity: Major
    Found in app/controllers/basil_controller.rb - About 2 hrs to fix

      Method review_year has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def review_year
          @year = params[:year].to_i
          comparable_year = "Jan 1, #{@year}".to_date
      
          @created_content = {}
      Severity: Major
      Found in app/controllers/data_controller.rb - About 2 hrs to fix

        Method value_for has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        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?
        Severity: Minor
        Found in app/models/serializers/api_content_serializer.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 value_for has a Cognitive Complexity of 18 (exceeds 5 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 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 text_markdown_export has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.text_markdown_export(universe_ids)
            page_types = Rails.application.config.content_types[:all]
            temporary_user_id_reference = Universe.find_by(id: universe_ids).user_id
        
            export_text = StringIO.new
        Severity: Major
        Found in app/services/export_service.rb - About 2 hrs to fix

          Method json_export has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.json_export(universe_ids)
              page_types = Rails.application.config.content_types[:all]
              temporary_user_id_reference = Universe.find_by(id: universe_ids).user_id
          
              export_object = {}
          Severity: Major
          Found in app/services/export_service.rb - About 2 hrs to fix

            Method text_outline_export has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.text_outline_export(universe_ids)
                page_types = Rails.application.config.content_types[:all]
                temporary_user_id_reference = Universe.find_by(id: universe_ids).user_id
            
                export_text = StringIO.new
            Severity: Major
            Found in app/services/export_service.rb - About 2 hrs to fix

              Method analyze has 57 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      def self.analyze(analysis_id)
                        analysis = ::DocumentAnalysis.find(analysis_id)
                        document = analysis.document
              
                        watson_client = new_client
              Severity: Major
              Found in app/services/documents/analysis/third_party/ibm_watson_service.rb - About 2 hrs to fix

                Method perform has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                  def perform(*args)
                    document_id = args.shift
                
                    document = Document.find_by(id: document_id)
                    return unless document.present?
                Severity: Minor
                Found in app/jobs/document_mention_job.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 suggested_tags_for has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def self.suggested_tags_for(class_name)
                    case class_name
                    when Building.name
                      ["School", "Business"]
                    when Character.name
                Severity: Major
                Found in app/services/page_tag_service.rb - About 2 hrs to fix

                  Method commission has a Cognitive Complexity of 16 (exceeds 5 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: Minor
                  Found in app/controllers/basil_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 migrate_fields_for_content has 52 lines of code (exceeds 25 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: Major
                  Found in app/services/temporary_field_migration_service.rb - About 2 hrs to fix

                    Method relates has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def self.relates relation, with:#, where: {}
                          singularized_relation = relation.to_s.singularize
                          connecting_class      = with.to_s.singularize.camelize.constantize
                          connecting_class_name = with
                    
                    
                    Severity: Minor
                    Found in app/models/concerns/has_content_groupers.rb - About 1 hr to fix

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

                        render () {
                          return (
                            <div id="entity-link-modal" className="modal">
                              <div className="modal-content">
                                <h4>Add a quick reference</h4>
                      Severity: Minor
                      Found in app/javascript/components/DocumentEntityLinkModal.js - About 1 hr to fix

                        Method api_sort has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def api_sort
                            sort_params = params.permit(:content_id, :intended_position, :sortable_class)
                            sortable_class = sort_params[:sortable_class].constantize # todo audit
                            return unless sortable_class
                        
                        
                        Severity: Minor
                        Found in app/controllers/content_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

                        Method new has a Cognitive Complexity of 15 (exceeds 5 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

                        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 render has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          render () {
                            return (
                              <React.Fragment>
                                <SpeedDial
                                  ariaLabel="SpeedDial example"
                        Severity: Minor
                        Found in app/javascript/components/QuickPageCreatesFab.js - About 1 hr to fix

                          Method replace_for has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def self.replace_for(text, user)
                              gremlins_phase = 1
                              replaced_text = text.dup
                          
                              # Page tag replacements
                          Severity: Minor
                          Found in app/services/forum_replacement_service.rb - About 1 hr to fix

                            Method cache_linkable_content_for_each_content_type has a Cognitive Complexity of 14 (exceeds 5 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

                            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

                            Severity
                            Category
                            Status
                            Source
                            Language