mysociety/alaveteli

View on GitHub

Showing 462 of 632 total issues

Avoid too many return statements within this method.
Open

        return true
Severity: Major
Found in lib/mail_handler/reply_handler.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            return true
    Severity: Major
    Found in lib/mail_handler/reply_handler.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

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

          def short_or_long_name
            if short_name.nil? || short_name.empty?
              name.nil? ? "" : name
            else
              short_name
        Severity: Minor
        Found in app/models/concerns/public_body_derived_fields.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 ensure_filename! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def ensure_filename!
            if self.filename.blank?
              calc_ext = AlaveteliFileTypes.mimetype_to_extension(self.content_type)
              if !calc_ext
                calc_ext = "bin"
        Severity: Minor
        Found in app/models/foi_attachment.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

        Function d3TimeSeries has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function d3TimeSeries(selector, data, title, metric_name) {
        
          // Add the title
          var wrapper_element = document.querySelectorAll(selector)[0];
        
        
        Severity: Minor
        Found in app/assets/javascripts/time_series.js - 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 delivery_status has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def delivery_status
            begin
              unless attributes['delivery_status'].present?
                # attempt to parse the status from the log line and store if successful
                set_delivery_status
        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 line has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def line(opts = {})
            _line = read_attribute(:line)
        
            if opts[:redact]
              _line = strip_syslog_prefix(_line)
        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 calculated_home_page has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def calculated_home_page
            if home_page && !home_page.empty?
              home_page[URI::regexp(%w(http https))] ? home_page : "http://#{home_page}"
            elsif request_email_domain
              "http://www.#{request_email_domain}"
        Severity: Minor
        Found in app/models/public_body.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 is_followupable? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def is_followupable?(incoming_message)
            if is_external?
              @followup_bad_reason = "external"
              false
            elsif !OutgoingMailer.is_followupable?(self, incoming_message)
        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 _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 user_link_for_request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def user_link_for_request(request, cls=nil)
            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 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 add_post_redirect_param_to_uri has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def add_post_redirect_param_to_uri(uri)
            # TODO: what is the built in Ruby URI munging function that can do this
            # choice of & vs. ? more elegantly than this dumb if statement?
            if uri.include?("?")
              # TODO: This looks odd. What would a fragment identifier be doing server-side?
        Severity: Minor
        Found in app/controllers/application_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 get_body_for_html_display has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def get_body_for_html_display(collapse_quoted_sections = true)
            # Find the body text and remove emails for privacy/anti-spam reasons
            text = get_main_body_text_unfolded
            folded_quoted_text = get_main_body_text_folded
        
        
        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 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 status_text_waiting_clarification has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def status_text_waiting_clarification(info_request, opts = {})
            is_owning_user = opts.fetch(:is_owning_user)
        
            str = ''.html_safe
        
        
        Severity: Minor
        Found in app/helpers/info_request_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 track_set has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def track_set
            if @user
              @existing_track = TrackThing.find_existing(@user, @track_thing)
              if @existing_track
                flash[:notice] =
        Severity: Minor
        Found in app/controllers/track_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

        Severity
        Category
        Status
        Source
        Language