mysociety/alaveteli

View on GitHub

Showing 328 of 433 total issues

Method create has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    unless @user || params[:password_change_user]
      @email_field_options = {}
      render :new
      return
Severity: Minor
Found in app/controllers/password_changes_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 track_search_query has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def track_search_query
    @query = params[:query_array]

    # TODO: more hackery to make alternate formats still work with query_array
    if /^(.*)\.json$/.match(@query)
Severity: Minor
Found in app/controllers/track_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 compare has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def compare(previous = nil)
      if previous.nil?
        changes = []
      else
        v = self
Severity: Minor
Found in app/models/public_body.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 highlight_matches has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def highlight_matches(text, phrases, options = {})
    if options.fetch(:sanitize, true)
      text = ActionController::Base.helpers.sanitize(text).try(:html_safe)
    end

Severity: Minor
Found in app/helpers/highlight_helper.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 indexed_by_search? has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def indexed_by_search?
    if %w[sent followup_sent response comment].include?(event_type)
      return false unless info_request.indexed_by_search?
      if event_type == 'response' && !incoming_message.indexed_by_search?
        return false
Severity: Minor
Found in app/models/info_request_event.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 make_request_zip has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def make_request_zip(info_request, file_path)
    Zip::File.open(file_path, create: true) do |zipfile|
      file_info = make_request_summary_file(info_request)
      zipfile.get_output_stream(file_info[:filename]) { |f| f.write(file_info[:data]) }
      message_index = 0
Severity: Minor
Found in app/controllers/request_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 prepare_environment has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def self.prepare_environment
    return unless @@db_path.nil?

    # barf if we can't figure out the environment
    environment = (ENV['RAILS_ENV'] or Rails.env)
Severity: Minor
Found in lib/acts_as_xapian/acts_as_xapian.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 xapian_value has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def xapian_value(field, type = nil, index_translations = false)
      if index_translations && respond_to?("translations")
        if (type == :date) || (type == :boolean)
          value = single_xapian_value(field, type = type)
        else
Severity: Minor
Found in lib/acts_as_xapian/acts_as_xapian.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 move has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def move
    editor = admin_current_user

    if params[:commit] == 'Move request to user' && !params[:user_url_name].blank?
      destination_user = User.find_by_url_name(params[:user_url_name])
Severity: Minor
Found in app/controllers/admin_request_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 load has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  that.load = function() {
    var cardError = document.getElementById('card-errors');

    // Sync initial state for terms checkbox and submit button
    that.submit.setAttribute('disabled', 'true');
Severity: Minor
Found in app/assets/javascripts/alaveteli_pro/stripe.js - About 1 hr to fix

    Method log_overdue_event_type has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.log_overdue_event_type(event_type)
        date_field = case event_type
        when 'overdue'
          'date_response_required_by'
        when 'very_overdue'
    Severity: Minor
    Found in app/models/info_request.rb - About 1 hr to fix

      Method play has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def play
          session[:request_game] = Time.zone.now
      
          @missing = InfoRequest.
            where_old_unclassified.
      Severity: Minor
      Found in app/controllers/request_game_controller.rb - About 1 hr to fix

        Method generate_upload_url has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def generate_upload_url
            if params[:incoming_message_id]
              incoming_message = IncomingMessage.find(params[:incoming_message_id])
              email = incoming_message.from_email
              name = incoming_message.safe_from_name || @info_request.public_body.name
        Severity: Minor
        Found in app/controllers/admin_request_controller.rb - About 1 hr to fix

          Method create_batch has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def create_batch
              @info_request_batch =
                InfoRequestBatch.find(params[:info_request_batch_id])
          
              authorize! :update, @info_request_batch
          Severity: Minor
          Found in app/controllers/alaveteli_pro/embargo_extensions_controller.rb - About 1 hr to fix

            Method hidden_user_explanation has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def hidden_user_explanation
                prominence_reason = render_to_string(
                  partial: "admin_request/hidden_user_explanation/#{params[:message]}",
                  formats: [:text],
                  locals: {
            Severity: Minor
            Found in app/controllers/services_controller.rb - About 1 hr to fix

              Method make_request_summary_file has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def make_request_summary_file(info_request)
                  done = false
                  @render_to_file = true
                  assign_variables_for_show_template(info_request)
                  if HTMLtoPDFConverter.exist?
              Severity: Minor
              Found in app/controllers/request_controller.rb - About 1 hr to fix

                Method load_file has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def self.load_file(file_name)
                    is_gz = file_name.include?(".gz")
                    file_name_db = is_gz ? file_name.gsub(".gz", "") : file_name
                
                    modified = File.stat(file_name).mtime
                Severity: Minor
                Found in app/models/mail_server_log.rb - About 1 hr to fix

                  Method import_values_from_csv_row has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def import_values_from_csv_row(row, line, name, options)
                      is_new = new_record?
                      edit_info = if is_new
                        { action: "creating new authority",
                          comment: 'Created from spreadsheet' }
                  Severity: Minor
                  Found in app/models/public_body.rb - About 1 hr to fix

                    Method phases has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def self.phases
                          [
                            { capital_label: _('Awaiting response'),
                              label: _('awaiting response'),
                              scope: :awaiting_response,
                    Severity: Minor
                    Found in app/models/info_request/state.rb - About 1 hr to fix

                      Method lookup_query has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def lookup_query
                          @locale = AlaveteliLocalization.locale
                          AlaveteliLocalization.with_locale(@locale) do
                            @query = params[:query]
                            @query = nil if @query == ""
                      Severity: Minor
                      Found in app/controllers/admin_public_body_controller.rb - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language