mateuszdw/qaror

View on GitHub

Showing 63 of 63 total issues

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

  def initialize(user)
    user = User.new if user.nil?

    #
    #guest
Severity: Minor
Found in app/models/ability.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

Class User has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

class User < ActiveRecord::Base

  delegate :can?, :cannot?, :to => :ability

  STATUS_ANONYMOUS = 0
Severity: Minor
Found in app/models/user.rb - About 3 hrs to fix

    Function tagit has 88 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        $.fn.tagit = function(options) {
                    var el = this;
                    create_preview()
                    function split( val ) {
                return val.split(/[\s]+/);
    Severity: Major
    Found in app/assets/javascripts/tag-it.js - About 3 hrs to fix

      Method initialize has 76 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def initialize(user)
          user = User.new if user.nil?
      
          #
          #guest
      Severity: Major
      Found in app/models/ability.rb - About 3 hrs to fix

        Method find_or_create has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.find_or_create(*args)
            return false unless APP_CONFIG['gain_achievements']
        
            name = args[0]
            user = args[1][:user]
        Severity: Minor
        Found in app/models/achievement.rb - About 2 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 vote has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

              def vote(voter,vote) # self.user # thr owner
        
                unless ["up","down"].include?(vote)
                  errors[:base] << I18n.t("voteable.bad_param")
                  return false
        Severity: Minor
        Found in lib/extender/voteable.rb - About 2 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

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

              $('body').on('click','a.remote-update', function () {
                  $.ajax({
                     type: 'post',
                     url: this.href,
                     data: { _method: 'put',
        Severity: Major
        Found in app/assets/javascripts/qaror.js and 1 other location - About 2 hrs to fix
        app/assets/javascripts/qaror.js on lines 141..151

        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 84.

        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

              $('body').on('click','a.remote-delete', function () {
                  $.ajax({
                     type: 'post',
                     url: this.href,
                     data: { _method: 'delete',
        Severity: Major
        Found in app/assets/javascripts/qaror.js and 1 other location - About 2 hrs to fix
        app/assets/javascripts/qaror.js on lines 129..139

        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 84.

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

              def achievement_for_vote_up
                if activityable.class.name == 'Thr' # ask
        
                  if activityable.vote_count >= APP_BADGES_CONFIG['nice_question']
                    # uniq_activityable for each thr, an or comment
        Severity: Minor
        Found in lib/extender/achievements.rb - About 2 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

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

                  if activityable.vote_count >= APP_BADGES_CONFIG['nice_question']
                    # uniq_activityable for each thr, an or comment
                    Achievement.find_or_create('nice_question',:user=>activityable.user, :activity=>self , :uniq_activityable=>true)
                  end
        
        
        Severity: Major
        Found in lib/extender/achievements.rb and 1 other location - About 1 hr to fix
        lib/extender/achievements.rb on lines 151..165

        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 71.

        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 activityable.vote_count >= APP_BADGES_CONFIG['nice_answer']
                    Achievement.find_or_create('nice_answer',:user=>activityable.user ,:activity=>self ,:uniq_activityable=>true)
                  end
        
                  if activityable.vote_count >= APP_BADGES_CONFIG['good_answer']
        Severity: Major
        Found in lib/extender/achievements.rb and 1 other location - About 1 hr to fix
        lib/extender/achievements.rb on lines 131..146

        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 71.

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

              def self.sortable(sort_by={})
                default = [:created_at,:desc].join(" ")
                valid = ['created_at','uploaded_at','sizebyte','name']
                return order(default) if sort_by.nil?
                sortable = []
        Severity: Minor
        Found in lib/extender/sortable.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 a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

          def create
        
            @thr = Thr.new
            @thr.title = params[:thr][:title]
            @thr.content = params[:thr][:content]
        Severity: Minor
        Found in app/controllers/thrs_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 change_password has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def change_password
            # check hash
            @user = User.active.where(:remind_token=>params[:hash]).first
            if @user.nil?
              redirect_to root_url
        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 login_with_omniauth has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def login_with_omniauth
            omniauth = request.env["omniauth.auth"]
            authentication = Authentication.find_by_provider_and_uid(omniauth['provider'],omniauth['uid'])
            if authentication
              # jesli uid juz istnieje loguje odrazu
        Severity: Minor
        Found in app/controllers/login_controller.rb - About 1 hr to fix

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

                  def set_tags
                    return unless self.tagnames
                    tags_arr = tags_array_from_string
                    self.tagnames = tags_arr.join(' ')
                    return unless self.tagnames_changed?
          Severity: Minor
          Found in lib/extender/taggable.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 vote has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def vote(voter,vote) # self.user # thr owner
          
                  unless ["up","down"].include?(vote)
                    errors[:base] << I18n.t("voteable.bad_param")
                    return false
          Severity: Minor
          Found in lib/extender/voteable.rb - About 1 hr to fix

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

              def create
                @badge = Badge.new(params[:badge])
            
                respond_to do |format|
                  if @badge.save
            Severity: Major
            Found in app/controllers/badges_controller.rb and 1 other location - About 1 hr to fix
            app/controllers/admin/badges_controller.rb on lines 48..57

            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 52.

            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

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

                def create
                  @badge = Badge.new(params[:badge])
            
                  respond_to do |format|
                    if @badge.save
            Severity: Major
            Found in app/controllers/admin/badges_controller.rb and 1 other location - About 1 hr to fix
            app/controllers/badges_controller.rb on lines 42..51

            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 52.

            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 achievement_for_vote_up has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def achievement_for_vote_up
                    if activityable.class.name == 'Thr' # ask
            
                      if activityable.vote_count >= APP_BADGES_CONFIG['nice_question']
                        # uniq_activityable for each thr, an or comment
            Severity: Minor
            Found in lib/extender/achievements.rb - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language