mysociety/alaveteli

View on GitHub

Showing 338 of 434 total issues

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

  def authenticate_attachment
    # Test for hidden
    if cannot?(:read, @info_request)
      request.format = :html
      return render_hidden
Severity: Minor
Found in app/controllers/attachments_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 lookup_query has a Cognitive Complexity of 7 (exceeds 5 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 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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(model_classes, query_string, options = {}, user_query = nil)
      # Check parameters, convert to actual array of model classes
      new_model_classes = []
      model_classes = [model_classes] if model_classes.class != Array
      model_classes.each do |model_class|
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 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 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 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 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 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

                  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 true if @user
              Severity: Major
              Found in app/controllers/user_controller.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                      handle_spam_subject(@info_request.user) && 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

                    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 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
                          Severity
                          Category
                          Status
                          Source
                          Language