mysociety/alaveteli

View on GitHub

Showing 339 of 435 total issues

Method set_show_requests has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def set_show_requests
    # Use search query for this so can collapse and paginate easily
    # TODO: really should just use SQL query here rather than Xapian.

    @request_states = assign_request_states(@display_user)
Severity: Minor
Found in app/controllers/user_controller.rb - About 35 mins 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 run_job has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.run_job(job, flush, verbose)
    if verbose
      STDOUT.puts("ActsAsXapian.update_index #{job.action} #{job.model} #{job.model_id} #{Time.now}")
    end

Severity: Minor
Found in lib/acts_as_xapian/acts_as_xapian.rb - About 35 mins 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 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def destroy
    begin
      @customer = current_user.pro_account.try(:stripe_customer)
      raise ActiveRecord::RecordNotFound unless @customer

Severity: Minor
Found in app/controllers/alaveteli_pro/subscriptions_controller.rb - About 35 mins 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_about_me? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def show_about_me?
    return true if @is_you
    return false unless @display_user.get_about_me_for_html_display.present?
    return false unless @display_user.active?
    return true if @display_user.confirmed_not_spam?
Severity: Minor
Found in app/controllers/user_controller.rb - About 35 mins 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 results has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def results
      # If they've already pulled out the results, just return them.
      return cached_results unless cached_results.nil?

      docs = []
Severity: Minor
Found in lib/acts_as_xapian/acts_as_xapian.rb - About 35 mins 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 7 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    if params[:change_request_id]
      @change_request = PublicBodyChangeRequest.find(params[:change_request_id])
    end
    AlaveteliLocalization.with_locale(AlaveteliLocalization.default_locale) do
Severity: Minor
Found in app/controllers/admin_public_body_controller.rb - About 35 mins 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 check_for_env_vars has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def check_for_env_vars(env_vars, example)
    missing = []
    env_vars.each do |env_var|
      missing << env_var unless ENV[env_var]
    end
Severity: Minor
Found in lib/tasks/usage.rb - About 35 mins 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 csv_export has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.csv_export(model, to_run, query=nil, header=nil, override={}, header_map={})
    return unless is_required?(model.name, to_run)

    # set query and header to default values unless supplied
    query  ||= model
Severity: Minor
Found in lib/data_export.rb - About 35 mins 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

Avoid too many return statements within this method.
Open

    return 0
Severity: Major
Found in script/handle-mail-replies.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

          return true
    Severity: Major
    Found in app/models/info_request_event.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

          return false if empty_return_path?
      Severity: Major
      Found in app/models/raw_email.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

            return false if auto_submitted?
        Severity: Major
        Found in app/models/raw_email.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

              return 2 if MailHandler::ReplyHandler.is_oof?(message)
          Severity: Major
          Found in script/handle-mail-replies.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                  return
            Severity: Major
            Found in app/controllers/request_controller.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    return false if data[:hidden_rows] == total_count && total_count <= 50
              Severity: Major
              Found in gems/excel_analyzer/lib/excel_analyzer/xlsx_analyzer.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                    return render_new_preview if params[:preview].to_i == 1
                Severity: Major
                Found in app/controllers/request_controller.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                        handle_blocked_ip(@info_request) && return
                  Severity: Major
                  Found in app/controllers/request_controller.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return
                    Severity: Major
                    Found in app/controllers/request_controller.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                              return
                      Severity: Major
                      Found in app/controllers/request_controller.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                              return
                        Severity: Major
                        Found in app/controllers/user_controller.rb - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language