mysociety/alaveteli

View on GitHub

Showing 509 of 1,313 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
          Severity: Major
          Found in app/controllers/user_controller.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

              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

                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'
                  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

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

                        def self.get_attachment_by_url_part_number_and_filename(attachments, found_url_part_number, display_filename)
                          attachment_by_part_number = attachments.detect { |a| a.url_part_number == found_url_part_number }
                          if attachment_by_part_number && attachment_by_part_number.display_filename == display_filename
                            # Then the filename matches, which is fine:
                            attachment_by_part_number
                      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 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

                      Severity
                      Category
                      Status
                      Source
                      Language