Showing 4,033 of 4,033 total issues

File basket.rb has 489 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Basket < ActiveRecord::Base
  scope :except_certain_baskets, lambda { |baskets| where("id not in (?) AND status = 'approved'", baskets) }

  def self.settings
    # * EOIN: we are pretty sure this is not called - raise an exception to be sure
Severity: Minor
Found in app/models/basket.rb - About 7 hrs to fix

    Assignment Branch Condition size for importer_process is too high. [67.68/15]
    Open

        def importer_process(record, params)
          current_record = @results[:records_processed] + 1
          logger.info("starting record #{current_record}")
    
          record_hash = {}
    Severity: Minor
    Found in lib/importer.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Class TopicTest has 54 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class TopicTest < ActiveSupport::TestCase
      # fixtures preloaded
      include KeteUrlFor
    
      def setup
    Severity: Major
    Found in old_test/unit/topic_test.rb - About 7 hrs to fix

      Method has too many lines. [61/10]
      Open

        def title_or_any_text_includes(terms)
          query_part = QUALIFYING_ATTRIBUTE_SPECS['relevance']
          operator = '@and'
          terms = pqf_format(terms)
      
      
      Severity: Minor
      Found in app/models/pqf_query.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Assignment Branch Condition size for show_comments_for is too high. [66.95/15]
      Open

        def show_comments_for(item)
          html_string = "<p>#{t('application_helper.show_comments_for.comment_count', count: @comments.size)}</p><p>"
      
          unless @comments.empty?
            html_string += t('application_helper.show_comments_for.read_and')
      Severity: Minor
      Found in app/helpers/application_helper.rb by rubocop

      This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

      Assignment Branch Condition size for update is too high. [66.47/15]
      Open

        def update
          @topic = Topic.find(params[:id])
          public_or_private_version_of(@topic)
      
          # if they have changed the topic type, make the edit fail so they can review

      This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

      Method has too many lines. [61/10]
      Open

          def self.included(klass)
            # stuff related to flagging and moderation
            klass.send :include, FlaggingController
      
            # Kieran Pilkington, 2008/10/23
      Severity: Minor
      Found in lib/extended_content_controller.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method get_progress has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
      Open

        def get_progress
          if !request.xhr?
            flash[:notice] = t('importers_controller.get_progress.import_failed')
            redirect_to action: 'list'
          else
      Severity: Minor
      Found in app/controllers/importers_controller.rb - About 7 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

      Block has too many lines. [112/25]
      Open

            base.class_eval do
              if base.name == 'IndexPageControllerTest'
                context 'The index page' do
                  setup do
                    3.times { |i| create_new_still_image_with(title: "site basket image #{i + 1}") }
      Severity: Minor
      Found in lib/image_slideshow_test_helper.rb by rubocop

      This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

      Block has too many lines. [111/25]
      Open

          namespace :topics do
            desc "Given a passed in CONDITIONS string (conditions in sql form), move topics that fit CONDITIONS to TARGET (as specified by passed in id) and also USER for id that should be attributed with the move actions. E.g. 'rake kete:tools:topics:move_to_basket TARGET=6 CONDITIONS=\"topic_type_id = 4\" USER=1'. You can optionally specify whether zoom records should be built progressively with ZOOM=true (false by default). If you have a large number of topics that match CONDITIONS, you may want to alter this task to handle batches (otherwise you risk memory issues). Other thing to keep in mind is that this doesn't currently leave any sort of redirect behind for a moved item. Best done before you have a public site. Also Comments are not currently dealt with here."
            task move_to_basket: :environment do
              to_basket = Basket.find(ENV['TARGET'])
              target_basket_path = to_basket.urlified_name
      Severity: Minor
      Found in lib/old_tasks/tools.rake by rubocop

      This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

      File integration_test_helper.rb has 478 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      SKIP_SYSTEM_CONFIGURATION = true
      
      # Standard test initialization code
      ENV["RAILS_ENV"] = "test"
      require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
      Severity: Minor
      Found in old_test/integration/integration_test_helper.rb - About 7 hrs to fix

        Assignment Branch Condition size for short_search_title_from_params is too high. [64.83/15]
        Open

            def short_search_title_from_params
              zoom_class = zoom_class_from_controller(params[:controller_name_for_zoom_class])
              plural_item_type = zoom_class_plural_humanize(zoom_class)
              title_parts = []
              title_parts << libt(:search_terms, search_terms: params[:search_terms]) if params[:action] == 'for'
        Severity: Minor
        Found in lib/previous_searches.rb by rubocop

        This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

        File search_controller.rb has 473 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        class SearchController < ApplicationController
          # Walter McGinnis, 2008-02-07
          # search forms never add anything to db
          # so don't need csrf protection, which is problematic with search forms
          # in kete
        Severity: Minor
        Found in app/controllers/search_controller.rb - About 7 hrs to fix

          Block has too many lines. [108/25]
          Open

          namespace :deploy do
            task :default do
              puts "This task shouldn't be run. Use deploy:first_time or deploy:update"
            end
          
          
          Severity: Minor
          Found in lib/recipes/kete.rb by rubocop

          This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

          Block has too many lines. [108/25]
          Open

                task move_to_basket: :environment do
                  to_basket = Basket.find(ENV['TARGET'])
                  target_basket_path = to_basket.urlified_name
          
                  # gather topics
          Severity: Minor
          Found in lib/old_tasks/tools.rake by rubocop

          This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

          Block has too many lines. [108/25]
          Open

            describe 'Access control' do
              describe 'An anonymous user' do
                it 'can view other users comments on a topic' do
                  # given ...
                  comment_attrs = FactoryGirl.attributes_for(:comment)

          This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

          Method has too many lines. [57/10]
          Open

            def terms_to_page_url_redirect
              basket_name =
                params[:target_basket].nil? ? \
                     params[:urlified_name] : params[:target_basket]
          
          

          This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

          Method has too many lines. [57/10]
          Open

            def find_related
              # related items are now shown on basket homepage topics, small change to allow linking here
              params[:relate_to_type] = 'Topic' if params[:relate_to_type] == 'IndexPage'
          
              @relate_to_item = params[:relate_to_type].constantize.find(params[:relate_to_item])

          This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

          Assignment Branch Condition size for prepare_and_validate_profile_for is too high. [62.06/15]
          Open

            def prepare_and_validate_profile_for(form_type)
              # this var is used in form helpers
              @form_type = form_type
          
              # we don't run this method is we don't have profile rules

          This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

          Method has too many lines. [57/10]
          Open

              def oai_record_xml(options = {})
                item = options[:item] || self
                request = @import_request || simulated_request
                record =
                  Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
          Severity: Minor
          Found in lib/oai_zoom.rb by rubocop

          This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

          Severity
          Category
          Status
          Source
          Language