mysociety/alaveteli

View on GitHub

Showing 339 of 435 total issues

Avoid too many return statements within this method.
Open

    return true if @user
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/request_controller.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return
      Severity: Major
      Found in app/controllers/request_controller.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              handle_spam_subject(@info_request.user) && return
        Severity: Major
        Found in app/controllers/request_controller.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                redirect_to frontpage_path and return
          Severity: Major
          Found in app/controllers/request_controller.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                  return
            Severity: Major
            Found in app/controllers/request_controller.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                    return true if subject == "out of office"
              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 if subject.start_with? "out of office autoreply:"
                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 if subject == "out of office reply"
                  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 if subject.end_with? "is out of the office"
                    Severity: Major
                    Found in lib/mail_handler/reply_handler.rb - About 30 mins to fix

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

                            def pending_states(opts)
                              # Which pending states can we transition into
                              if opts.fetch(:in_internal_review, false)
                                states = %w[internal_review gone_postal]
                              else
                      Severity: Minor
                      Found in app/models/info_request/state/calculator.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_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def track_list
                          @view = params[:view]
                      
                          if @view == 'recent' || @view.nil? # the blank one for backwards compatibility
                            @track_thing = TrackThing.create_track_for_all_new_requests
                      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

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

                        def translated_fields
                          fields = @template.tag.div id: 'div-locales' do
                            @template.concat(locale_tabs)
                      
                            locales = @template.tag.div class: 'tab-content' do
                      Severity: Minor
                      Found in app/helpers/admin/translated_record_form.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 = {}
                          get_attachments_for_display.each do |attachment|
                            ext = AlaveteliFileTypes.mimetype_to_extension(attachment.content_type)
                            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 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 default_config has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def default_config
                        tmp_dir = File.join(File.dirname(__FILE__), '../tmp')
                      
                        GEM_VERSIONS.inject({}) do |m, (r, v)|
                          uri = URI(
                      Severity: Minor
                      Found in script/update-rubocop-config.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 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

                      Severity
                      Category
                      Status
                      Source
                      Language