mysociety/alaveteli

View on GitHub

Showing 507 of 1,317 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 false
    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 'waiting_response'
          Severity: Major
          Found in spec/models/customstates.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                return 'waiting_response_very_overdue' if
            Severity: Major
            Found in spec/models/customstates.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    return 'waiting_response_overdue'
              Severity: Major
              Found in spec/models/customstates.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                    return 'waiting_response_overdue' if
                Severity: Major
                Found in spec/models/customstates.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

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

                    def self.with_tag(tag)
                      return all if tag.size == 1
                  
                      where_condition = ''
                      where_parameters = []
                  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 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

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

                    def title_formatting
                      return unless title
                      unless MySociety::Validate.uses_mixed_capitals(title, 1) ||
                        title_starts_with_number || title_is_acronym(6)
                        errors.add(:title, _('Please write the summary using a mixture of capital and lower case letters. This makes it easier for others to read.'))
                  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 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

                  Severity
                  Category
                  Status
                  Source
                  Language