ArtOfCode-/qpixel

View on GitHub

Showing 99 of 164 total issues

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

  def close
    unless check_your_privilege('flag_close', nil, false)
      render json: { status: 'failed', message: helpers.ability_err_msg(:flag_close, 'close this post') },
             status: :forbidden
      return
Severity: Minor
Found in app/controllers/posts_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 flag_verify has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def flag_verify
    @flag = Flag.find params[:id]
    return false if current_user.nil?

    type = @flag.post_flag_type
Severity: Minor
Found in app/controllers/flags_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 lock has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def lock
    return not_found unless current_user.privilege? 'flag_curate'
    return not_found if @post.locked?

    length = params[:length].present? ? params[:length].to_i : nil
Severity: Minor
Found in app/controllers/posts_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 do_xml_transform has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def self.do_xml_transform(site_domain, data_type, options)
    dump_path = options.path
    community_id = options.community
    category_id = options.category

Severity: Minor
Found in scripts/import/dump_import.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 restore has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def restore
    unless check_your_privilege('flag_curate', @post, false)
      flash[:danger] = helpers.ability_err_msg(:flag_curate, 'restore this post')
      redirect_to post_path(@post)
      return
Severity: Minor
Found in app/controllers/posts_controller.rb - About 1 hr to fix

    Method do_rtl_witchcraft has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def do_rtl_witchcraft(str)
        chars = str.chars
        output_buffer = ''
        scan_buffer = []
        current_mode = rtl?(chars[0]) ? :rtl : :ltr
    Severity: Minor
    Found in app/helpers/advertisement_helper.rb - About 1 hr to fix

      Method delete has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def delete
          unless check_your_privilege('flag_curate', @post, false)
            flash[:danger] = helpers.ability_err_msg(:flag_curate, 'delete this post')
            redirect_to post_path(@post)
            return
      Severity: Minor
      Found in app/controllers/posts_controller.rb - About 1 hr to fix

        Method role_toggle has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def role_toggle
            role_map = { mod: :is_moderator, admin: :is_admin, mod_global: :is_global_moderator, admin_global: :is_global_admin,
                         staff: :staff }
            permission_map = { mod: :is_admin, admin: :is_global_admin, mod_global: :is_global_admin,
            admin_global: :is_global_admin, staff: :staff }
        Severity: Minor
        Found in app/controllers/users_controller.rb - About 1 hr to fix

          Method method_missing has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.method_missing(name, *args, **opts)
              unless args.length >= 2
                raise NoMethodError
              end
          
          
          Severity: Minor
          Found in app/models/post_history.rb - About 1 hr to fix

            Method soft_delete has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def soft_delete
                if @user.is_admin || @user.is_moderator
                  render json: { status: 'failed', message: 'Admins and moderators cannot be deleted.' },
                         status: :unprocessable_entity
                  return
            Severity: Minor
            Found in app/controllers/users_controller.rb - About 1 hr to fix

              Method soft_delete has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                def soft_delete
                  if @user.is_admin || @user.is_moderator
                    render json: { status: 'failed', message: 'Admins and moderators cannot be deleted.' },
                           status: :unprocessable_entity
                    return
              Severity: Minor
              Found in app/controllers/users_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 create has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def create
                  post = Post.find(params[:post_id])
              
                  if post.user == current_user && !SiteSetting['AllowSelfVotes']
                    render(json: { status: 'failed', message: 'You may not vote on your own posts.' }, status: :forbidden) && return
              Severity: Minor
              Found in app/controllers/votes_controller.rb - About 1 hr to fix

                Method update_profile has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def update_profile
                    profile_params = params.require(:user).permit(:username, :profile_markdown, :website, :twitter)
                    profile_params[:twitter] = profile_params[:twitter].delete('@')
                
                    if profile_params[:website].present? && URI.parse(profile_params[:website]).instance_of?(URI::Generic)
                Severity: Minor
                Found in app/controllers/users_controller.rb - About 1 hr to fix

                  Method useful_err_msg has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def self.useful_err_msg
                      [
                        'The inverted database guide has found an insurmountable problem. Please poke it with a ' \
                          'paperclip before anyone finds out.',
                        'The modular cable meter has found a problem. You need to kick your IT technician in the ' \
                  Severity: Minor
                  Found in app/models/application_record.rb - About 1 hr to fix

                    Method read has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def read
                        @notification = Notification.unscoped.find params[:id]
                    
                        unless @notification.user == current_user
                          respond_to do |format|
                    Severity: Minor
                    Found in app/controllers/notifications_controller.rb - About 1 hr to fix

                      Method search has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def search
                          @posts = if params[:search].present?
                                     search_data = helpers.parse_search(params[:search])
                                     posts = (current_user&.is_moderator || current_user&.is_admin ? Post : Post.undeleted)
                                             .qa_only.where(helpers.qualifiers_to_sql(search_data[:qualifiers]))
                      Severity: Minor
                      Found in app/controllers/search_controller.rb - About 55 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 create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def create
                          if !current_user.is_global_admin && params[:global] == '1'
                            not_found
                            return
                          end
                      Severity: Minor
                      Found in app/controllers/close_reasons_controller.rb - About 55 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 create has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def create
                          post = Post.find(params[:post_id])
                      
                          if post.user == current_user && !SiteSetting['AllowSelfVotes']
                            render(json: { status: 'failed', message: 'You may not vote on your own posts.' }, status: :forbidden) && return
                      Severity: Minor
                      Found in app/controllers/votes_controller.rb - About 55 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_sort has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def user_sort(term_opts, **field_mappings)
                          default = term_opts[:default] || :created_at
                          requested = term_opts[:term]
                          direction = term_opts[:direction] || :desc
                          if requested.nil? || field_mappings.exclude?(requested.to_sym)
                      Severity: Minor
                      Found in app/models/application_record.rb - About 55 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 method_missing has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def self.method_missing(name, *args, **opts)
                          unless args.length >= 2
                            raise NoMethodError
                          end
                      
                      
                      Severity: Minor
                      Found in app/models/post_history.rb - About 55 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