mysociety/alaveteli

View on GitHub

Showing 328 of 433 total issues

Method create_request has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create_request
    json = ActiveSupport::JSON.decode(params[:request_json])
    request = InfoRequest.new(
      title: json["title"],
      public_body_id: @public_body.id,
Severity: Minor
Found in app/controllers/api_controller.rb - About 1 hr to fix

    Method other_country_message has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def other_country_message
        flash.keep
    
        text = ""
        site_country_code = AlaveteliConfiguration.iso_country_code.downcase
    Severity: Minor
    Found in app/controllers/services_controller.rb - About 1 hr to fix

      Method calculate_last_event_forming_initial_request has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def calculate_last_event_forming_initial_request
          # TODO: This can be removed when last_event_forming_initial_request_id has
          # been populated for all requests
      
          expecting_clarification = false
      Severity: Minor
      Found in app/models/info_request.rb - About 1 hr 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_image has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def convert_image
          return if data.nil?
          return if image.nil?
      
          # convert to PNG if it isn't, and to right size
      Severity: Minor
      Found in app/models/profile_photo.rb - About 1 hr 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 update has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def update
          if @user.suspended?
            flash[:error] = _('Suspended users cannot edit their profile')
            redirect_to edit_profile_about_me_path
            return
      Severity: Minor
      Found in app/controllers/user_profile/about_me_controller.rb - About 1 hr 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 single_xapian_value has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def single_xapian_value(field, type = nil)
            value = send(field.to_sym) || self[field]
            if type == :date
              if value.is_a?(Time)
                value.utc.strftime("%Y%m%d")
      Severity: Minor
      Found in lib/acts_as_xapian/acts_as_xapian.rb - About 1 hr 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 on_rescue has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def on_rescue(node)
            return unless node.body.multiline?
      
            node.resbody_branches.each do |resbody|
              next unless resbody.body && resbody.body.multiline?
      Severity: Minor
      Found in lib/custom_cops/empty_lines_around_rescued_exceptions.rb - About 1 hr 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 gettext_interpolate has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def gettext_interpolate(string, values)
        return string unless string.is_a?(String)
      
        # $1, $2 don't work with SafeBuffer so casting to string as workaround
        safe = string.html_safe?
      Severity: Minor
      Found in lib/i18n_fixes.rb - About 1 hr 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 init_values has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.init_values(values)
          values.each do |_method, index, prefix, value_type|
            unless index.is_a? Integer
              raise "Value index '#{index}' must be an Integer, is #{index.class}"
            end
      Severity: Minor
      Found in lib/acts_as_xapian/acts_as_xapian.rb - About 1 hr 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 apply_pdf_masks has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def apply_pdf_masks(text, options = {})
          uncompressed_text = uncompress_pdf(text)
          # if we managed to uncompress the PDF...
          if uncompressed_text.blank?
            text
      Severity: Minor
      Found in lib/alaveteli_text_masker.rb - About 1 hr 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 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def create
          unless @user || params[:password_change_user]
            @email_field_options = {}
            render :new
            return
      Severity: Minor
      Found in app/controllers/password_changes_controller.rb - About 1 hr to fix

        Method permanently_failed_addresses has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.permanently_failed_addresses(message)
              if MailHandler.empty_return_path?(message)
                # Some sort of auto-response
        
                # Check for Exim’s X-Failed-Recipients header
        Severity: Minor
        Found in lib/mail_handler/reply_handler.rb - About 1 hr to fix

          Method show has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def show
              long_cache
              @display_user = set_display_user
              set_view_instance_variables
              @same_name_users = User.find_similar_named_users(@display_user)
          Severity: Minor
          Found in app/controllers/user_controller.rb - About 1 hr to fix

            Function _update has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              RefusalWizard.prototype._update = function($current_question) {
                var wizard = this;
                var $next_question = wizard._nextQuestion();
            
                if ($current_question) {
            Severity: Minor
            Found in app/assets/javascripts/wizard.js - About 1 hr to fix

              Method internal_admin_body has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def self.internal_admin_body
                  matching_pbs = AlaveteliLocalization.
                    with_locale(AlaveteliLocalization.default_locale) do
                    default_scoped.where(url_name: 'internal_admin_authority')
                  end
              Severity: Minor
              Found in app/models/public_body.rb - About 1 hr to fix

                Method get_request_percentages has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def self.get_request_percentages(column, n, highest, minimum_requests)
                    total_column = "info_requests_visible_classified_count"
                    ordering = "y_value"
                    ordering += " DESC" if highest
                    y_value_column = "(cast(#{column} as float) / #{total_column})"
                Severity: Minor
                Found in app/models/public_body.rb - About 1 hr to fix

                  Method decode_attached_part has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def decode_attached_part(part, parent_mail)
                          if get_content_type(part) == 'message/rfc822'
                            # An email attached as text
                            part.rfc822_attachment = mail_from_raw_email(part.body)
                            if part.rfc822_attachment.nil?
                  Severity: Minor
                  Found in lib/mail_handler/backends/mail_backend.rb - About 1 hr to fix

                    Method receive has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def receive(email, raw_email_data, *args)
                        return if already_received?(email)
                    
                        defaults = { override_stop_new_responses: false,
                                     rejected_reason: nil,
                    Severity: Minor
                    Found in app/models/info_request.rb - About 1 hr to fix

                      Method authenticate has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def authenticate
                          if AlaveteliConfiguration.skip_admin_auth
                            session[:using_admin] = 1
                            nil
                          elsif session[:using_admin].nil? || session[:admin_name].nil?
                      Severity: Minor
                      Found in app/controllers/admin_controller.rb - About 1 hr to fix

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

                          def accept_incoming?(email, raw_email_data)
                            # See if new responses are prevented
                            gatekeeper = ResponseGatekeeper.for(allow_new_responses_from, self)
                            # Take action if the message looks like spam
                            spam_checker = ResponseGatekeeper::SpamChecker.new
                        Severity: Minor
                        Found in app/models/info_request.rb - About 1 hr 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