indentlabs/notebook

View on GitHub

Showing 288 of 288 total issues

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 = 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 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 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 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 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 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

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

                      if (x1 === 0) {
                        theta = Math.PI / 2;
                        xsign = 0;
                      } else {
                        theta = Math.atan(y1 / x1);
              Severity: Major
              Found in public/navigator/js-mindmap.js and 1 other location - About 2 hrs to fix
              public/navigator/js-mindmap.js on lines 343..350

              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 77.

              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

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

                      if (x1 === 0) {
                        theta = Math.PI / 2;
                        xsign = 0;
                      }
                      else {
              Severity: Major
              Found in public/navigator/js-mindmap.js and 1 other location - About 2 hrs to fix
              public/navigator/js-mindmap.js on lines 293..299

              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 77.

              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 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

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

                              ( $(this).offset().top <= $(window).scrollTop()+$(window).height()*offset && $(this).find('.cd-timeline-img').hasClass('is-hidden') ) && $(this).find('.cd-timeline-img, .cd-timeline-content').removeClass('is-hidden').addClass('bounce-in');
                  Severity: Major
                  Found in app/assets/javascripts/timeline.js and 1 other location - About 1 hr to fix
                  app/assets/javascripts/timeline.js on lines 17..17

                  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 74.

                  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

                              ( $(this).offset().top > $(window).scrollTop()+$(window).height()*offset ) && $(this).find('.cd-timeline-img, .cd-timeline-content').addClass('is-hidden');
                  Severity: Major
                  Found in app/assets/javascripts/timeline.js and 1 other location - About 1 hr to fix
                  app/assets/javascripts/timeline.js on lines 23..23

                  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 74.

                  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

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