mateuszdw/qaror

View on GitHub

Showing 63 of 63 total issues

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

    def update
      @contact_u = ContactU.find(params[:id])

      respond_to do |format|
        if @contact_u.update_attributes(params[:contact_u])
Severity: Major
Found in app/controllers/admin/contact_us_controller.rb and 1 other location - About 1 hr to fix
app/controllers/admin/pages_controller.rb on lines 64..73

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

    def update
      @page = Page.find(params[:id])

      respond_to do |format|
        if @page.update_attributes(params[:page])
Severity: Major
Found in app/controllers/admin/pages_controller.rb and 1 other location - About 1 hr to fix
app/controllers/admin/contact_us_controller.rb on lines 38..47

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

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

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

  def unresolved
    @an = An.active.find(params[:id])
    Extender::Activities.an_unresolved(@an,current_user)
    respond_to do |format|
      if @an.thr.user == current_user && @an.unresolve # rozwiazuje
Severity: Major
Found in app/controllers/ans_controller.rb and 1 other location - About 1 hr to fix
app/controllers/ans_controller.rb on lines 69..79

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

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

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

  def resolved
    @an = An.active.find(params[:id])
    Extender::Activities.an_resolved(@an,current_user) # oznaczam jako rozwiazane
    respond_to do |format|
      if @an.thr.user == current_user && @an.resolve # rozwiazuje
Severity: Major
Found in app/controllers/ans_controller.rb and 1 other location - About 1 hr to fix
app/controllers/ans_controller.rb on lines 83..93

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

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

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

        def update
          @badge = Badge.find(params[:id])
    
          respond_to do |format|
            if @badge.update_attributes(params[:badge])
    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 58..67

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

    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 update
        @badge = Badge.find(params[:id])
    
        respond_to do |format|
          if @badge.update_attributes(params[:badge])
    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 64..73

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

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

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

        def close
          @thr = Thr.active.find(params[:id])
          Extender::Activities.close(@thr, current_user,params[:acomment])
          respond_to do |format|
            if @thr.mark_as_closed
      Severity: Major
      Found in app/controllers/thrs_controller.rb and 2 other locations - About 1 hr to fix
      app/controllers/ans_controller.rb on lines 111..120
      app/controllers/thrs_controller.rb on lines 218..227

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

      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 3 locations. Consider refactoring.
      Open

        def flag
          @thr = Thr.active_or_closed.find(params[:id])
          Extender::Activities.flag(@thr, current_user,params[:acomment])
          respond_to do |format|
            if @thr.mark_as_hidden_if_needed
      Severity: Major
      Found in app/controllers/thrs_controller.rb and 2 other locations - About 1 hr to fix
      app/controllers/ans_controller.rb on lines 111..120
      app/controllers/thrs_controller.rb on lines 204..213

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

      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 3 locations. Consider refactoring.
      Open

        def flag
          @an = An.active.find(params[:id])
          Extender::Activities.flag(@an, current_user,params[:acomment])
          respond_to do |format|
            if @an.mark_as_hidden_if_needed
      Severity: Major
      Found in app/controllers/ans_controller.rb and 2 other locations - About 1 hr to fix
      app/controllers/thrs_controller.rb on lines 204..213
      app/controllers/thrs_controller.rb on lines 218..227

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

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

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

            def set_achievement
              self.increment!(:hotness)
              self.increment!(:hits)
          #    impressionable.reload # reload hits, hotness
              if self.class.name == 'Thr'
      Severity: Minor
      Found in lib/extender/impressionable.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 login_with_email_and_pass has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def login_with_email_and_pass
          if request.post? && params[:login] && params[:login][:email] && params[:login][:password]
              if params[:login][:email].blank? || params[:login][:password].blank?
                flash[:login_error] = t :all_fields_required
                redirect_to login_index_url
      Severity: Minor
      Found in app/controllers/login_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

      Consider simplifying this complex logical expression.
      Open

              if (sub.user.user_setting.notify_answers==1 && answer_created?) ||
                 (sub.user.user_setting.notify_comments==1 && comment_created?) ||
                 (sub.user.user_setting.notify_answer_resolved==1 && answer_resolved?)
      
                p "send mail to #{sub.user.name}"
      Severity: Major
      Found in app/models/activity.rb - About 40 mins to fix

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

              def self.vote_down_an(current_object,user)
                a = current_object.activities.build(:user_id=>user.id,:name=>'vote_down')
                a.build_points(:value=>APP_REPUTATION['vote_down_an'])
                a.build_points(:reduce_points_if_needed=>true,:user_id=>current_object.user.id,:value=>APP_REPUTATION['an_receives_down_vote'])
                self.on_vote_an(current_object,user)
        Severity: Major
        Found in lib/extender/activities.rb and 3 other locations - About 40 mins to fix
        lib/extender/activities.rb on lines 127..131
        lib/extender/activities.rb on lines 134..138
        lib/extender/activities.rb on lines 142..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 37.

        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 4 locations. Consider refactoring.
        Open

              def self.vote_up_an(current_object,user)
                a = current_object.activities.build(:user_id=>user.id,:name=>'vote_up')
                a.build_points(:value=>APP_REPUTATION['vote_up_an'])
                a.build_points(:reduce_points_if_needed=>true,:user_id=>current_object.user.id,:value=>APP_REPUTATION['an_receives_up_vote'])
                self.on_vote_an(current_object,user)
        Severity: Major
        Found in lib/extender/activities.rb and 3 other locations - About 40 mins to fix
        lib/extender/activities.rb on lines 127..131
        lib/extender/activities.rb on lines 134..138
        lib/extender/activities.rb on lines 149..153

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

        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