mysociety/alaveteli

View on GitHub

Showing 338 of 434 total issues

Method contact has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def contact
    # if they clicked remove for link to request/body, remove it
    if params[:remove]
      @last_request = nil
      cookies['last_request_id'] = nil
Severity: Minor
Found in app/controllers/help_controller.rb - About 55 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 mass_tag has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def mass_tag
    lookup_query

    if params[:tag] && (params[:tag] != "")
      if params[:table_name] == 'exact'
Severity: Minor
Found in app/controllers/admin_public_body_controller.rb - About 55 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 signchangeemail has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def signchangeemail
    # "authenticated?" has done the redirect to signin page for us
    return unless authenticated? || ask_to_login(
      web: _('To change your email address used on {{site_name}}',
             site_name: site_name),
Severity: Minor
Found in app/controllers/user_controller.rb - About 55 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 to_admin_message has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def to_admin_message(name, email, subject, message, logged_in_user, last_request, last_body)
Severity: Major
Found in app/mailers/contact_mailer.rb - About 50 mins to fix

    Method set_described_state has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def set_described_state(new_state, set_by = nil, message = "")
        old_described_state = described_state
        ActiveRecord::Base.transaction do
          self.awaiting_description = false
          last_event = info_request_events.last
    Severity: Minor
    Found in app/models/info_request.rb - About 45 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 import_csv has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def self.import_csv(csv, tag, tag_behaviour, dry_run, editor, available_locales = [])
    Severity: Minor
    Found in app/models/public_body.rb - About 45 mins to fix

      Method valid_to_reply_to? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def valid_to_reply_to?
          email = from_email.try(:downcase)
      
          # check validity of email
          return false if email.nil? || !MySociety::Validate.is_valid_email(email)
      Severity: Minor
      Found in app/models/raw_email.rb - About 45 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 populate_from_ical_feed has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def populate_from_ical_feed
          cal_file = open(ical_feed_url)
          cal_parser = Icalendar::Parser.new(cal_file)
          cals = cal_parser.parse
          cal = cals.first
      Severity: Minor
      Found in app/models/holiday_import.rb - About 45 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 import_csv_from_file has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def self.import_csv_from_file(csv_filename, tag, tag_behaviour, dry_run, editor, available_locales = [])
      Severity: Minor
      Found in app/models/public_body.rb - About 45 mins to fix

        Method unmasked_body has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def unmasked_body
            MailHandler.attachment_body_for_hexdigest(
              raw_email.mail,
              hexdigest: hexdigest
            )
        Severity: Minor
        Found in app/models/foi_attachment.rb - About 45 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 explorable_in_datasette? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def explorable_in_datasette?(attachment)
            return false unless attachment.is_public?
            return false unless attachment.incoming_message.is_public?
            return false unless info_request_is_public?(attachment)
            return false unless attachment.content_type == 'text/csv'
        Severity: Minor
        Found in app/helpers/datasette_helper.rb - About 45 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 with_query has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.with_query(query, tag)
            like_query = "%#{query}%"
            has_first_letter = tag.size == 1
        
            underscore_locale = AlaveteliLocalization.locale
        Severity: Minor
        Found in app/models/public_body.rb - About 45 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_main_body_text_part has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def get_main_body_text_part(leaves=[])
            leaves = foi_attachments if leaves.empty?
        
            # Find first part which is text/plain or text/html
            # (We have to include HTML, as increasingly there are mail clients that
        Severity: Minor
        Found in app/models/incoming_message.rb - About 45 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 params_diff has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def params_diff
            # split out parameters into old/new diffs, and other ones
            old_params = {}
            new_params = {}
            other_params = {}
        Severity: Minor
        Found in app/models/info_request_event.rb - About 45 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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def create
            @reason = params[:reason]
            @message = params[:message] || ""
            if @reason.empty?
              flash[:error] = _("Please choose a reason")
        Severity: Minor
        Found in app/controllers/reports_controller.rb - About 45 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 bulk_destroy has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def bulk_destroy
            if params[:commit] == "No"
              redirect_to(admin_request_url(params[:request_id]))
            end
        
        
        Severity: Minor
        Found in app/controllers/admin_incoming_message_controller.rb - About 45 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 contact has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def contact
            return unless params[:submitted_contact_form]
        
            if @recaptcha_required && !verify_recaptcha
              flash.now[:error] = _('There was an error with the reCAPTCHA. ' \
        Severity: Minor
        Found in app/controllers/users/messages_controller.rb - About 45 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 deeply nested control flow statements.
        Open

                rescue
                  $stderr.puts("Error processing zip file: #{$ERROR_INFO.inspect}")
        Severity: Major
        Found in lib/mail_handler.rb - About 45 mins to fix

          Method destroy_and_rebuild_index has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def self.destroy_and_rebuild_index(model_classes, verbose = false, terms = true, values = true, texts = true, safe_rebuild = true)
          Severity: Minor
          Found in lib/acts_as_xapian/acts_as_xapian.rb - About 45 mins to fix

            Method redeliver has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def redeliver
                message_ids = params[:url_title].split(',').map(&:strip)
                previous_request = @incoming_message.info_request
                destination_request = nil
            
            
            Severity: Minor
            Found in app/controllers/admin_incoming_message_controller.rb - About 45 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