ArtOfCode-/qpixel

View on GitHub

Showing 164 of 164 total issues

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

  def mod_privilege_action
    ability = Ability.find_by internal_id: params[:ability]
    return not_found if ability.internal_id == 'mod'

    ua = @user.community_user.privilege(ability.internal_id)
Severity: Minor
Found in app/controllers/users_controller.rb - About 1 hr to fix

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

      def full_log
        @posts = Post.where(user: @user).count
        @comments = Comment.where(user: @user).count
        @flags = Flag.where(user: @user).count
        @suggested_edits = SuggestedEdit.where(user: @user).count
    Severity: Minor
    Found in app/controllers/users_controller.rb - About 1 hr to fix

      Function createNotification has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        createNotification: function(type, message) {
          // Some messages include a date stamp, `append_date` governs that.
          let append_date = false;
          let message_with_date = message;
          if (type === 'danger') {
      Severity: Minor
      Found in app/assets/javascripts/qpixel_api.js - About 1 hr to fix

        Method close has 32 lines of code (exceeds 25 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

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

            def tab(text, link_url, **opts, &block)
              active = opts[:is_active] || false
              opts.delete :is_active
              opts[:class] = if opts[:class]
                               "#{opts[:class]} tabs--tab#{active ? ' tab__active' : ''}"
          Severity: Minor
          Found in app/helpers/tabs_helper.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 qualifier_presence has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def qualifier_presence
              return unless ['tag', 'user', 'category'].include? type
          
              if type == 'tag' && (qualifier.blank? || Tag.find_by(name: qualifier).nil?)
                errors.add(:qualifier, 'must provide a valid tag name for tag subscriptions')
          Severity: Minor
          Found in app/models/subscription.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 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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                        if (data.status === 'OK') {
                          $up.text(`+${data.upvotes}`);
                          $down.html(`−${data.downvotes}`);
                          $tgt.removeClass('is-active')
                              .removeAttr('data-vote-id');
                  Severity: Major
                  Found in app/assets/javascripts/votes.js and 1 other location - About 1 hr to fix
                  app/assets/javascripts/votes.js on lines 38..54

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 59.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                        if (data.status === 'modified' || data.status === 'OK') {
                          $up.text(`+${data.upvotes}`);
                          $down.html(`−${data.downvotes}`);
                          $tgt.addClass('is-active')
                              .attr('data-vote-id', data.vote_id);
                  Severity: Major
                  Found in app/assets/javascripts/votes.js and 1 other location - About 1 hr to fix
                  app/assets/javascripts/votes.js on lines 18..28

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 59.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  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

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                            if icon_path.present?
                              icon = community_icon(icon_path)
                              icon.resize_to_fit!(175, 75)
                              ad.composite!(icon, SouthWestGravity, 20, 15, SrcAtopCompositeOp)
                            else
                      Severity: Major
                      Found in app/controllers/advertisement_controller.rb and 1 other location - About 1 hr to fix
                      app/controllers/advertisement_controller.rb on lines 316..328

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 51.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                            if icon_path.present?
                              icon = community_icon(icon_path)
                              icon.resize_to_fit!(120, 50)
                              ad.composite!(icon, SouthWestGravity, 20, 15, SrcAtopCompositeOp)
                            else
                      Severity: Major
                      Found in app/controllers/advertisement_controller.rb and 1 other location - About 1 hr to fix
                      app/controllers/advertisement_controller.rb on lines 239..251

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 51.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Severity
                      Category
                      Status
                      Source
                      Language