mysociety/alaveteli

View on GitHub

Showing 463 of 630 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 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 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 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 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 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 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 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 get_present_file_extensions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def get_present_file_extensions
                ret = {}
                for attachment in self.get_attachments_for_display
                  ext = AlaveteliFileTypes.mimetype_to_extension(attachment.content_type)
                  ext = File.extname(attachment.filename).gsub(/^[.]/, "") if ext.nil? && !attachment.filename.nil?
            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_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 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 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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                AlaveteliLocalization.with_locale(AlaveteliLocalization.default_locale) do
                  @public_body_category = PublicBodyCategory.new(public_body_category_params)
                  if @public_body_category.save
                    # FIXME: This can't handle failure (e.g. if a PublicBodyHeading
            Severity: Minor
            Found in app/controllers/admin_public_body_categories_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 info_request_params has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def info_request_params(batch = false)
                if batch
                  unless params[:info_request].nil? || params[:info_request].empty?
                    params.require(:info_request).permit(:title, :tag_string)
                  end
            Severity: Minor
            Found in app/controllers/request_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 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 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

            Severity
            Category
            Status
            Source
            Language