Showing 4,033 of 4,033 total issues

Method importer_process has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring.
Open

  def importer_process(record, params)
    current_record = @results[:records_processed] + 1
    logger.info("starting record #{current_record}")

    # clear this out so last related_topic
Severity: Minor
Found in lib/workers/past_perfect4_importer_worker.rb - About 1 day 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 has too many lines. [95/10]
Open

    def importer_prepare_extended_field(options = {})
      params = options[:params]
      field = options[:field]
      value = options[:value]
      zoom_class_for_params = options[:zoom_class_for_params]
Severity: Minor
Found in lib/importer.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.

Module has too many lines. [155/100]
Open

module ExtendedContentHelpers
  unless included_modules.include? ExtendedContentHelpers

    def oai_dc_xml_dc_extended_content(xml, item = self)
      @builder_instance = xml
Severity: Minor
Found in lib/extended_content_helpers.rb by rubocop

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

Class has too many lines. [154/100]
Open

class Topic < ActiveRecord::Base
  include PgSearch
  include PgSearchCustomisations
  multisearchable against: %i[
    title
Severity: Minor
Found in app/models/topic.rb by rubocop

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

Assignment Branch Condition size for terms_to_page_url_redirect is too high. [99.84/15]
Open

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

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 setup_related_topic_and_zoom_and_redirect is too high. [99.22/15]
Open

  def setup_related_topic_and_zoom_and_redirect(item, commented_item = nil, options = {})
    where_to_redirect = 'show_self'
    if !commented_item.nil? && @successful
      update_zoom_and_related_caches_for(commented_item)
      where_to_redirect = 'commentable'

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

  def process_value(value)
    @logger.info "in process_value: #{value}"
    return unless within_table && within_data

    if self.current_row == 1
Severity: Minor
Found in lib/workers/excel_based_importer_worker.rb - About 1 day 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 has too many lines. [149/100]
Open

class SearchSource < ActiveRecord::Base
  acts_as_list

  validates_presence_of :title, :source_type
  validates_format_of :base_url, with: /^http:\/\/.*/, message: I18n.t('search_source_model.requires_http')
Severity: Minor
Found in app/models/search_source.rb by rubocop

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

File item_privacy_test_helper.rb has 632 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module ItemPrivacyTestHelper
  module Model
    # Normally, testing attachment_fu methods will cause real files to be written into your
    # development and production environment file folders, as defined in the models.
    # To work around this, this override forces the files to be saved into the
Severity: Major
Found in lib/item_privacy_test_helper.rb - About 1 day to fix

    Class has too many lines. [148/100]
    Open

    class IndexPageController < ApplicationController
      include ImageSlideshow
    
      def index
        if !@current_basket.index_page_redirect_to_all.blank?

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

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

      def update
        params[:source_form] ||= 'edit'
        params[:basket] ||= {}
    
        @basket = Basket.find(params[:id])

    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

    Module has too many lines. [147/100]
    Open

        module TaggingWithPrivacyContext
          def test_class_responds_to_class_methods_as_expected
            klass = eval(@base_class)
    
            should_respond_to = %i[
    Severity: Minor
    Found in lib/item_privacy_test_helper.rb by rubocop

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

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

        def extended_content_field_xml_tag(options = {})
          xml = options[:xml]
          field = options[:field]
          value = options[:value] || nil
          xml_element_name = options[:xml_element_name] || nil
    Severity: Minor
    Found in lib/extended_content_helpers.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.

    Class Basket has 72 methods (exceeds 20 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: Major
    Found in app/models/basket.rb - About 1 day to fix

      File application_controller.rb has 611 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      class ApplicationController < ActionController::Base
        # helper :all # include all helpers, all the time
        protect_from_forgery # See ActionController::RequestForgeryProtection for details
      
        include DefaultUrlOptions
      Severity: Major
      Found in app/controllers/application_controller.rb - About 1 day to fix

        Class has too many lines. [139/100]
        Open

        class TopicsController < ApplicationController
          include ExtendedContentController
        
          include ImageSlideshow
        
        

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

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

        namespace :tools do
          rake_whitelist = [
            'acts_as_licensed:import_au_cc_licenses', 'acts_as_licensed:import_nz_cc_licenses',
            'kete:export:users', 'kete:import:users',
            'kete:repair:check_uploaded_files', 'kete:repair:correct_upload_locations', 'kete:repair:fix_topic_versions', 'kete:repair:set_missing_contributors',
        Severity: Minor
        Found in lib/recipes/tools.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.

        Assignment Branch Condition size for login is too high. [90.36/15]
        Open

          def login
            if request.post?
        
              # check for login/password
              # else anonymous user

        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 has too many lines. [131/100]
        Open

        class ExtendedField < ActiveRecord::Base
          include ExtendedFieldsHelpers
        
          # Choices/enumerations
          has_many :choice_mappings, as: :field
        Severity: Minor
        Found in app/models/extended_field.rb by rubocop

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

        Assignment Branch Condition size for extended_content_field_xml_tag is too high. [87.64/15]
        Open

            def extended_content_field_xml_tag(options = {})
              xml = options[:xml]
              field = options[:field]
              value = options[:value] || nil
              xml_element_name = options[:xml_element_name] || nil
        Severity: Minor
        Found in lib/extended_content_helpers.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

        Severity
        Category
        Status
        Source
        Language