discourse/discourse

View on GitHub

Showing 1,588 of 1,895 total issues

Class CookedPostProcessor has 46 methods (exceeds 20 allowed). Consider refactoring.
Open

class CookedPostProcessor
  INLINE_ONEBOX_LOADING_CSS_CLASS = "inline-onebox-loading"
  INLINE_ONEBOX_CSS_CLASS = "inline-onebox"
  LIGHTBOX_WRAPPER_CSS_CLASS = "lightbox-wrapper"
  LOADING_SIZE = 10
Severity: Minor
Found in lib/cooked_post_processor.rb - About 6 hrs to fix

    Method default_results has 158 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def default_results(options = {})
        options.reverse_merge!(@options)
        options.reverse_merge!(per_page: per_page_setting)
    
        # Whether to return visible topics
    Severity: Major
    Found in lib/topic_query.rb - About 6 hrs to fix

      Method create_for has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.create_for(upload, width, height, opts = {})
          return unless width > 0 && height > 0
          return if upload.try(:sha1).blank?
      
          # no extension so try to guess it
      Severity: Minor
      Found in app/models/optimized_image.rb - About 6 hrs 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

      File session_controller.rb has 421 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require_dependency 'rate_limiter'
      require_dependency 'single_sign_on'
      require_dependency 'single_sign_on_provider'
      require_dependency 'url_helper'
      
      
      Severity: Minor
      Found in app/controllers/session_controller.rb - About 6 hrs to fix

        Method filter_allowed_tags has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.filter_allowed_tags(query, guardian, opts = {})
            selected_tag_ids = opts[:selected_tags] ? Tag.where_name(opts[:selected_tags]).pluck(:id) : []
        
            if !opts[:for_topic] && !selected_tag_ids.empty?
              query = query.where('tags.id NOT IN (?)', selected_tag_ids)
        Severity: Minor
        Found in lib/discourse_tagging.rb - About 6 hrs 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 start_element has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
        Open

          def start_element(name, attributes = [])
            case name
            when "img"
              attributes = Hash[*attributes.flatten]
        
        
        Severity: Minor
        Found in lib/excerpt_parser.rb - About 6 hrs 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

        File theme.rb has 419 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require_dependency 'distributed_cache'
        require_dependency 'stylesheet/compiler'
        require_dependency 'stylesheet/manager'
        require_dependency 'theme_settings_parser'
        require_dependency 'theme_settings_manager'
        Severity: Minor
        Found in app/models/theme.rb - About 6 hrs to fix

          File site_setting_extension.rb has 419 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require_dependency 'site_settings/deprecated_settings'
          require_dependency 'site_settings/type_supervisor'
          require_dependency 'site_settings/defaults_provider'
          require_dependency 'site_settings/db_provider'
          
          
          Severity: Minor
          Found in lib/site_setting_extension.rb - About 6 hrs to fix

            File theme_field.rb has 415 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require_dependency 'theme_settings_parser'
            require_dependency 'theme_translation_parser'
            require_dependency 'theme_javascript_compiler'
            
            class ThemeField < ActiveRecord::Base
            Severity: Minor
            Found in app/models/theme_field.rb - About 5 hrs to fix

              Method recover has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
              Open

                def recover(posts = Post)
                  posts.have_uploads.find_each do |post|
              
                    begin
                      analyzer = PostAnalyzer.new(post.raw, post.topic_id)
              Severity: Minor
              Found in lib/upload_recovery.rb - About 5 hrs 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

              File post_creator.rb has 412 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require_dependency 'rate_limiter'
              require_dependency 'topic_creator'
              require_dependency 'post_jobs_enqueuer'
              require_dependency 'distributed_mutex'
              require_dependency 'has_errors'
              Severity: Minor
              Found in lib/post_creator.rb - About 5 hrs to fix

                File application_helper.rb has 410 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                require 'current_user'
                require 'canonical_url'
                require_dependency 'guardian'
                require_dependency 'unread'
                require_dependency 'age_words'
                Severity: Minor
                Found in app/helpers/application_helper.rb - About 5 hrs to fix

                  File new_user_narrative.rb has 408 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  require 'distributed_mutex'
                  
                  module DiscourseNarrativeBot
                    class NewUserNarrative < Base
                      I18N_KEY = "discourse_narrative_bot.new_user_narrative".freeze

                    Method process_internal has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def process_internal
                          handle_bounce if is_bounce?
                          raise NoSenderDetectedError if @from_email.blank?
                          raise FromReplyByAddressError if is_from_reply_by_email_address?
                          raise ScreenedEmailError if ScreenedEmail.should_block?(@from_email)
                    Severity: Minor
                    Found in lib/email/receiver.rb - About 5 hrs 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 tag_topic_by_names has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def self.tag_topic_by_names(topic, guardian, tag_names_arg, append: false)
                        if guardian.can_tag?(topic)
                          tag_names = DiscourseTagging.tags_for_saving(tag_names_arg, guardian) || []
                    
                          old_tag_names = topic.tags.pluck(:name) || []
                    Severity: Minor
                    Found in lib/discourse_tagging.rb - About 5 hrs 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 download has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def self.download(url,
                                        max_file_size:,
                                        tmp_file_name:,
                                        follow_redirect: false,
                                        read_timeout: 5,
                    Severity: Minor
                    Found in lib/file_helper.rb - About 5 hrs 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

                    File 006_badges.rb has 404 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    require 'badge_queries'
                    
                    BadgeGrouping.seed do |g|
                      g.id = BadgeGrouping::GettingStarted
                      g.name = "Getting Started"
                    Severity: Minor
                    Found in db/fixtures/006_badges.rb - About 5 hrs to fix

                      Class TopicViewSerializer has 42 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      class TopicViewSerializer < ApplicationSerializer
                        include PostStreamSerializerMixin
                        include SuggestedTopicsMixin
                        include TopicTagsMixin
                        include ApplicationHelper
                      Severity: Minor
                      Found in app/serializers/topic_view_serializer.rb - About 5 hrs to fix

                        Method save_custom_fields has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def save_custom_fields(force = false)
                            if force || !custom_fields_clean?
                              dup = @custom_fields.dup
                              array_fields = {}
                        
                        
                        Severity: Minor
                        Found in app/models/concerns/has_custom_fields.rb - About 5 hrs 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

                        File plugin.rb has 396 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        register_asset "stylesheets/common/poll.scss"
                        register_asset "stylesheets/common/poll-ui-builder.scss"
                        register_asset "stylesheets/desktop/poll.scss", :desktop
                        register_asset "stylesheets/mobile/poll.scss", :mobile
                        
                        
                        Severity: Minor
                        Found in plugins/poll/plugin.rb - About 5 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language