indentlabs/notebook

View on GitHub

Showing 288 of 288 total issues

Method perform has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def perform(*args)
    report_date = Date.current - 1.day
    timespan    = report_date.beginning_of_day..report_date.end_of_day

    report = EndOfDayAnalyticsReport.find_or_initialize_by(day: report_date)
Severity: Minor
Found in app/jobs/end_of_day_analytics_job.rb - About 1 hr to fix

    Method update has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def update
        # TODO: most things are stripped out now that we're using per-field updates, so we should
        # audit what's left of this function and what needs to stay
        content_type = content_type_from_controller(self.class)
        @content = content_type.with_deleted.find(params[:id])
    Severity: Minor
    Found in app/controllers/content_controller.rb - About 1 hr to fix

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

          when 'Sport'
            @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Overview', 'Description')
            @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Setup', 'Play area')
            @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Setup', 'Equipment')
            @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Setup', 'Number of players')
      Severity: Major
      Found in app/controllers/basil_controller.rb and 1 other location - About 1 hr to fix
      app/controllers/basil_controller.rb on lines 135..142

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

      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

          when 'Lore'
            @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Overview', 'Type')
            @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Content', 'Genre')
            @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Content', 'Tone')
            @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Culture', 'Time period')
      Severity: Major
      Found in app/controllers/basil_controller.rb and 1 other location - About 1 hr to fix
      app/controllers/basil_controller.rb on lines 169..175

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

      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 create_default_attribute_categories has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.create_default_attribute_categories(user)
            # Don't create any attribute categories for AttributeCategories or AttributeFields that share the ContentController
            return [] if ['attribute_category', 'attribute_field'].include?(content_name)
      
            YAML.load_file(Rails.root.join('config', 'attributes', "#{content_name}.yml")).map do |category_name, defaults|
      Severity: Minor
      Found in app/models/concerns/has_attributes.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

            custom_attribute_values:                   [:name, :value],
            location_leaderships_attributes:           [:id, :leader_id,       :_destroy],
            capital_cities_relationships_attributes:   [:id, :capital_city_id, :_destroy],
            largest_cities_relationships_attributes:   [:id, :largest_city_id, :_destroy],
            notable_cities_relationships_attributes:   [:id, :notable_city_id, :_destroy],
      Severity: Major
      Found in app/controllers/locations_controller.rb and 1 other location - About 1 hr to fix
      app/controllers/countries_controller.rb on lines 13..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 50.

      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

            custom_attribute_values:                [:name, :value],
            country_towns_attributes:               [:id, :town_id, :_destroy],
            country_locations_attributes:           [:id, :location_id, :_destroy],
            country_languages_attributes:           [:id, :language_id, :_destroy],
            country_religions_attributes:           [:id, :religion_id, :_destroy],
      Severity: Major
      Found in app/controllers/countries_controller.rb and 1 other location - About 1 hr to fix
      app/controllers/locations_controller.rb on lines 18..28

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

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

        def perform(*args)
          report_date = args.shift.to_date
          timespan    = report_date.beginning_of_day..report_date.end_of_day
      
          report = EndOfDayAnalyticsReport.find_or_initialize_by(day: report_date)
      Severity: Minor
      Found in app/jobs/backfilled_end_of_day_analytics_job.rb - About 1 hr to fix

        Method perform has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def perform(*args)
            analysis_id = args.shift
        
            analysis = DocumentAnalysis.find(analysis_id)
            return unless analysis.present?
        Severity: Minor
        Found in app/jobs/document_analysis_job.rb - About 1 hr to fix

          Method redeem_code has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def redeem_code
              code = PageUnlockPromoCode.find_by(code: params.require(:promotional_code).permit(:promo_code)[:promo_code])
          
              if code.nil?
                redirect_back(fallback_location: subscription_path, alert: "This isn't a valid promo code.")
          Severity: Minor
          Found in app/controllers/subscriptions_controller.rb - About 1 hr to fix

            Method question_for has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.question_for(content)
                return unless content.present?
            
                categories_for_this_type = AttributeCategory.where(
                  user:        content.user,
            Severity: Minor
            Found in app/services/serendipitous_service.rb - About 1 hr to fix

              Method add_account has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def add_account
                  # Tie any universe contributor invites with this email to this user
                  if resource.persisted?
                    potential_contributor_records = Contributor.where(email: resource.email.downcase, user_id: nil)
                    
              Severity: Minor
              Found in app/controllers/registrations_controller.rb - About 1 hr to fix

                Function bind has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      Function.prototype.bind = function bind(that) {
                
                        var target = this;
                
                        if (typeof target != "function") {
                Severity: Minor
                Found in app/assets/javascripts/modernizr.js - About 1 hr to fix

                  Function isEventSupported has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      isEventSupported = (function() {
                  
                        var TAGNAMES = {
                          'select': 'input', 'change': 'input',
                          'submit': 'form', 'reset': 'form',
                  Severity: Minor
                  Found in app/assets/javascripts/modernizr.js - About 1 hr to fix

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

                          def self.analyze(analysis_id)
                            analysis = DocumentAnalysis.find(analysis_id)
                            document = analysis.document
                    
                            # Length counters
                    Severity: Minor
                    Found in app/services/documents/analysis/counting_service.rb - About 1 hr to fix

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

                                  if a[:position] && b[:position]
                                    a[:position] <=> b[:position]
                      
                                  else
                                    # TODO why do we still have this?
                      Severity: Minor
                      Found in app/models/serializers/content_serializer.rb and 1 other location - About 1 hr to fix
                      app/models/serializers/categories_and_fields_serializer.rb on lines 32..49

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

                      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 a[:position] && b[:position]    
                                  a[:position] <=> b[:position]
                      
                                else    
                                  a_value = case a[:type]    
                      Severity: Minor
                      Found in app/models/serializers/categories_and_fields_serializer.rb and 1 other location - About 1 hr to fix
                      app/models/serializers/content_serializer.rb on lines 78..96

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

                      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

                            if (this.obj.activeNode === this || this.obj.activeNode === this.parent || this.obj.activeNode.parent === this) {
                              this.el.show();
                              this.visible = true;
                            }
                      Severity: Minor
                      Found in public/navigator/js-mindmap.js and 1 other location - About 55 mins to fix
                      public/navigator/js-mindmap.js on lines 189..193

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

                      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

                          var blobCircleWrapper = g.selectAll(".radarCircleWrapper")
                              .data(data)
                              .enter().append("g")
                              .attr("class", "radarCircleWrapper");
                      Severity: Minor
                      Found in app/assets/javascripts/d3-charts/radar_chart.js and 1 other location - About 55 mins to fix
                      app/assets/javascripts/d3-charts/radar_chart.js on lines 113..117

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

                      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

                            if (this.obj.activeNode !== this && this.obj.activeNode !== this.parent && this.obj.activeNode.parent !== this) {
                              // TODO hide me!
                              this.el.hide();
                              this.visible = false;
                            }
                      Severity: Minor
                      Found in public/navigator/js-mindmap.js and 1 other location - About 55 mins to fix
                      public/navigator/js-mindmap.js on lines 195..198

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

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language