mysociety/alaveteli

View on GitHub

Showing 416 of 632 total issues

Method start has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def self.start(opt={})
    opt = DEFAULTS.dup.merge(opt)

    Thread.new do
      prev = Hash.new(0)
Severity: Minor
Found in lib/memory_profiler.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 calculate_event_states has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def calculate_event_states
    curr_state = nil
    for event in info_request_events.reverse
      event.xapian_mark_needs_index  # we need to reindex all events in order to update their latest_* terms
      if curr_state.nil?
Severity: Minor
Found in app/models/info_request.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 new has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def new
    if params[:comment]
      @comment = Comment.new(comment_params.merge({ :user => @user }))
    end

Severity: Minor
Found in app/controllers/comment_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 _destroy_and_rebuild_index_safely has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def self._destroy_and_rebuild_index_safely(model_classes, verbose, terms, values, texts)
    batch_size = 1000
    for model_class in model_classes
      model_class_count = model_class.count
      0.step(model_class_count, batch_size) do |i|
Severity: Minor
Found in lib/acts_as_xapian/acts_as_xapian.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 create has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    begin
      @token = Stripe::Token.retrieve(params[:stripeToken])

      customer = current_user.pro_account.try(:stripe_customer)
Severity: Minor
Found in app/controllers/alaveteli_pro/subscriptions_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 other_country_message has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def other_country_message
    flash.keep

    text = ""
    site_country_code = AlaveteliConfiguration.iso_country_code.downcase
Severity: Minor
Found in app/controllers/services_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 show has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def show
    long_cache
    @page = get_search_page_from_params
    requests_per_page = 25

Severity: Minor
Found in app/controllers/public_body_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

Class MailServerLog has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

class MailServerLog < ActiveRecord::Base
  # `serialize` needs to be called before all other ActiveRecord code.
  # See http://stackoverflow.com/a/15610692/387558
  serialize :delivery_status, DeliveryStatusSerializer

Severity: Minor
Found in app/models/mail_server_log.rb - About 2 hrs to fix

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

      def set_locale_fields_from_csv_row(is_new, locale, row, options)
        changed = ActiveSupport::OrderedHash.new
        csv_field_names = options[:field_names]
        csv_import_fields.each do |field_name, field_notes|
          localized_field_name = self.class.localized_csv_field_name(locale, field_name)
    Severity: Minor
    Found in app/models/public_body.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 set_profile_photo has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

      def set_profile_photo
        # check they are logged in (the upload photo option is anyway only available when logged in)
        if authenticated_user.nil?
          flash[:error] = _("You need to be logged in to change your profile photo.")
          redirect_to frontpage_url
    Severity: Minor
    Found in app/controllers/user_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

    Class InfoRequestBatch has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class InfoRequestBatch < ActiveRecord::Base
      include AlaveteliPro::RequestSummaries
      include AlaveteliFeatures::Helpers
    
      has_many :info_requests,
    Severity: Minor
    Found in app/models/info_request_batch.rb - About 2 hrs to fix

      File admin_public_body_controller.rb has 256 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      class AdminPublicBodyController < AdminController
      
        include TranslatableParams
      
        before_action :set_public_body, :only => [:edit, :update, :destroy]
      Severity: Minor
      Found in app/controllers/admin_public_body_controller.rb - About 2 hrs to fix

        Method describe_state has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

          def describe_state
            info_request = InfoRequest.not_embargoed.find(params[:id].to_i)
            set_last_request(info_request)
        
            # If this is an external request, go to the request page - we don't allow
        Severity: Minor
        Found in app/controllers/request_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 update has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

          def update
            @tagged_public_bodies = PublicBody.find_by_tag(@public_body_category.category_tag)
        
            heading_ids = []
        
        
        Severity: Minor
        Found in app/controllers/admin_public_body_categories_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 down has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

          def down
            # reinstate the columns
            add_column :public_body_categories, :locale, :string
            add_column :public_body_headings, :locale, :string
            add_column :public_body_headings, :name, :string
        Severity: Minor
        Found in db/migrate/20140716131107_create_category_translation_tables.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 upload_response has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def upload_response
            @locale = AlaveteliLocalization.locale
            AlaveteliLocalization.with_locale(@locale) do
              @info_request = InfoRequest.not_embargoed.find_by_url_title!(params[:url_title])
        
        
        Severity: Minor
        Found in app/controllers/request_controller.rb - About 2 hrs to fix

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

            def signchangeemail
              # "authenticated?" has done the redirect to signin page for us
              return unless authenticated?(
                  :web => _("To change your email address used on {{site_name}}",:site_name=>site_name),
                  :email => _("Then you can change your email address used on {{site_name}}",:site_name=>site_name),
          Severity: Minor
          Found in app/controllers/user_controller.rb - About 1 hr to fix

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

              def set_profile_photo
                # check they are logged in (the upload photo option is anyway only available when logged in)
                if authenticated_user.nil?
                  flash[:error] = _("You need to be logged in to change your profile photo.")
                  redirect_to frontpage_url
            Severity: Minor
            Found in app/controllers/user_controller.rb - About 1 hr to fix

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

                  def table_rows
                    now = ActiveRecord::Base.default_timezone == :utc ? Time.now.utc : Time.now
                    now = now.to_s(:db)
              
                    # allow a standard key to be used for doing defaults in YAML
              Severity: Minor
              Found in lib/fixture_set_table_rows_patch.rb - About 1 hr to fix

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

                    var autoGrow = function($input) {
                        var currentWidth = null;
                    
                        var update = function(e, options) {
                            var value, keyCode, printable, placeholder, width;
                Severity: Minor
                Found in app/assets/javascripts/alaveteli_pro/selectize.js - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language