mateuszdw/qaror

View on GitHub

Showing 36 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

        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

        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

            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

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

                def sortable(column, title = nil)
                  title ||= column.titleize
                  sort_param = params[:sort].nil? ? []:params[:sort]
                  css_class = sort_param.include?(column) ? "current #{sort_param[column]}" : nil
                  direction = sort_param.include?(column) && sort_param[column] == "asc" ? "desc" : "asc"
              Severity: Minor
              Found in app/helpers/application_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 set_activity_for_thr has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                def set_activity_for_thr(thr)
                  thr.last_activity_user_id = user_id
                  thr.last_activity_id = id
                  set_activity_for(thr)
              
              
              Severity: Minor
              Found in app/models/activity.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 answer has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                def answer
                  
                  show_action
              
                  if request.post?
              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 27 lines of code (exceeds 25 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

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

                    def convert_and_pass_on(env)
                      if env['rack.input'].kind_of?(Tempfile)
                        tempfile = env['rack.input']
                      else
                        tempfile = Tempfile.new('raw-upload.')
                Severity: Minor
                Found in lib/rack/raw_upload.rb - About 1 hr to fix

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

                    def set_activity_at_for_activityable
                      if ['create','delete','revise','an_resolved','an_unresolved','close'].include? name
                        if activityable.class == Thr
                          set_activity_for_thr(activityable)
                        elsif activityable.class == An
                  Severity: Minor
                  Found in app/models/activity.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