mysociety/alaveteli

View on GitHub

Showing 277 of 433 total issues

Method _convert_part_body_to_text has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def _convert_part_body_to_text(part)
    if part.nil?
      text = "[ Email has no body, please see attachments ]"
    else
      # whatever kind of attachment it is, get the UTF-8 encoded text
Severity: Minor
Found in app/models/incoming_message.rb - About 25 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 find_all_unknown_mime_types has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.find_all_unknown_mime_types
    IncomingMessage.find_each do |incoming_message|
      incoming_message.get_attachments_for_display.each do |attachment|
        if attachment.content_type.nil?
          raise "internal error incoming_message " + incoming_message.id.to_s
Severity: Minor
Found in app/models/incoming_message.rb - About 25 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 cut_excerpt_part has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def cut_excerpt_part(part_position, part, separator, options)
    return "", "" unless part

    radius   = options.fetch(:radius, 100)
    omission = options.fetch(:omission, "...")
Severity: Minor
Found in app/helpers/highlight_helper.rb - About 25 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 default_config has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def default_config
  tmp_dir = File.join(File.dirname(__FILE__), '../tmp')

  GEM_VERSIONS.inject({}) do |m, (r, v)|
    uri = URI(
Severity: Minor
Found in script/update-rubocop-config.rb - About 25 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 request_exim_sent? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.request_exim_sent?(ir)
    # Look for line showing request was sent
    found = false
    ir.mail_server_logs.each do |mail_server_log|
      test_outgoing = " <= " + ir.incoming_email + " "
Severity: Minor
Found in app/models/mail_server_log.rb - About 25 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 user_name_slug has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def user_name_slug
    if is_external?
      if external_user_name.nil?
        fake_slug = "anonymous"
      else
Severity: Minor
Found in app/models/info_request.rb - About 25 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 user_link_for_request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def user_link_for_request(request)
    if request.is_external?
      user_name = request.external_user_name || _("Anonymous user")
      if !request.external_url.nil?
        link_to user_name, request.external_url
Severity: Minor
Found in app/helpers/link_to_helper.rb - About 25 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 search_redirect has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def search_redirect
    @query = params.delete(:query)
    if @query.nil? || @query.empty?
      @query = nil
      @page = 1
Severity: Minor
Found in app/controllers/general_controller.rb - About 25 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 normalise_content_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def normalise_content_type(content_type)
    # e.g. http://www.whatdotheyknow.com/request/93/response/250
    if (content_type == 'application/excel') || (content_type == 'application/msexcel') || (content_type == 'application/x-ms-excel')
      content_type = 'application/vnd.ms-excel'
    end
Severity: Minor
Found in lib/mail_handler.rb - About 25 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 alert_survey has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.alert_survey
    return unless Survey.enabled?

    InfoRequest.surveyable.each do |info_request|
      # Exclude users who have already completed the survey or
Severity: Minor
Found in app/mailers/survey_mailer.rb - About 25 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 readable_init has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.readable_init
    unless ActsAsXapian.bindings_available
      raise NoXapianRubyBindingsError, "Xapian Ruby bindings not installed"
    end
    if @@init_values.empty?
Severity: Minor
Found in lib/acts_as_xapian/acts_as_xapian.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    raise ActiveRecord::RecordNotFound if cannot? :admin, @comment

    old_body = @comment.body.dup
    old_visible = @comment.visible
Severity: Minor
Found in app/controllers/admin_comment_controller.rb - About 25 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 filename_and_content_to_mimetype has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def filename_and_content_to_mimetype(filename, content)
      # Try filename
      ret = filename_to_mimetype(filename)
      return ret unless ret.nil?

Severity: Minor
Found in lib/alaveteli_file_types.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    if @admin_user.update(user_params)
      if @admin_user == @user && !@admin_user.is_admin?
        flash[:notice] = 'User successfully updated - ' \
                         'you are no longer an admin.'
Severity: Minor
Found in app/controllers/admin_user_controller.rb - About 25 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 view_email has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def view_email
    @public_body = PublicBody.find_by_url_name_with_historic(params[:url_name])
    raise ActiveRecord::RecordNotFound, "None found" if @public_body.nil?

    AlaveteliLocalization.with_locale(AlaveteliLocalization.locale) do
Severity: Minor
Found in app/controllers/public_body_controller.rb - About 25 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 new_stripe_users has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def new_stripe_users
      count = 0
      sub_ids = []
      stripe_plans.each do |plan_id|
        Stripe::Subscription.list(
Severity: Minor
Found in lib/alaveteli_pro/metrics_report.rb - About 25 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 get_all_addresses has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def get_all_addresses(mail, include_invalid: false)
        addrs = []
        addrs << mail.to
        addrs << mail[:to].try(:value) if mail.to.nil? && include_invalid
        addrs << mail.cc
Severity: Minor
Found in lib/mail_handler/backends/mail_backend.rb - About 25 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

Severity
Category
Status
Source
Language