helpyio/helpy

View on GitHub

Showing 242 of 242 total issues

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

    if ($('.tiny-topic-active').length > 0) {
      $startingTopic = $('.tiny-topic-active').first();
    } else {
      $startingTopic = $('.topic').first();
    }
Severity: Major
Found in app/assets/javascripts/shortcuts.js and 1 other location - About 1 hr to fix
app/assets/javascripts/shortcuts.js on lines 164..168

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

  def anonymize
    return if self.is_admin?

    # anonymize own attributes
    self.update!(
Severity: Minor
Found in app/models/user.rb - About 1 hr to fix

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

        if ($('.tiny-topic-active').length > 0) {
          $startingTopic = $('.tiny-topic-active').first();
        } else {
          $startingTopic = $('.topic').last();
        }
    Severity: Major
    Found in app/assets/javascripts/shortcuts.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/shortcuts.js on lines 141..145

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

      def create
        @topic = Topic.find(params[:topic_id])
        @post = @topic.posts.new(post_params)
        @post.topic_id = @topic.id
        @post.user_id = current_user.id
    Severity: Minor
    Found in app/controllers/posts_controller.rb - About 1 hr to fix

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

        $('.post-vote').off().on("click", function(){
          var $voted = $(this).data("voted");
          ga('send', 'event', 'Vote','Post', $voted);
        });
      Severity: Major
      Found in app/assets/javascripts/event-tracking.js and 2 other locations - About 1 hr to fix
      app/assets/javascripts/event-tracking.js on lines 99..102
      app/assets/javascripts/event-tracking.js on lines 105..108

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

      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

        $('.oauth').off().on("click", function(){
          var $provider = $(this).data("provider");
          ga('send', 'event', 'oauth','provider', $provider);
        });
      Severity: Major
      Found in app/assets/javascripts/event-tracking.js and 2 other locations - About 1 hr to fix
      app/assets/javascripts/event-tracking.js on lines 94..97
      app/assets/javascripts/event-tracking.js on lines 99..102

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

      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

        $('.topic-vote').off().on("click", function(){
          var $voted = $(this).data("voted");
          ga('send', 'event', 'Vote','Topic', $voted);
        });
      Severity: Major
      Found in app/assets/javascripts/event-tracking.js and 2 other locations - About 1 hr to fix
      app/assets/javascripts/event-tracking.js on lines 94..97
      app/assets/javascripts/event-tracking.js on lines 105..108

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

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

        def get_tickets_by_status
          @status = params[:status] || "active"
          if current_user.is_restricted? && teams?
            topics_raw = Topic.all.tagged_with(current_user.team_list, any: true)
          else
      Severity: Minor
      Found in app/controllers/admin/base_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 find_for_oauth has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.find_for_oauth(auth)
          user = find_by(email: auth.info.email)
          if user
            user.tap do |u|
              u.provider = auth.provider
      Severity: Minor
      Found in app/models/user.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 update_waiting_on_cache has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def update_waiting_on_cache
      
          status = self.topic.current_status
          waiting_on = self.topic.waiting_on
      
      
      Severity: Minor
      Found in app/models/post.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 ticketing_ui has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def ticketing_ui
          @updated_topics = @topics
          if params[:q].present?
            search_date_from_params
            search_topics
      Severity: Minor
      Found in app/controllers/admin/topics_controller.rb - About 1 hr to fix

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

                  $('.widget-iframe').on('load', function(){
                    this.style.height=this.contentDocument.body.scrollHeight +'px';
                  });
        Severity: Major
        Found in app/assets/javascripts/widget.v1.js and 1 other location - About 1 hr to fix
        app/assets/javascripts/widget.v2.js on lines 86..88

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

        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

                  $('.widget-iframe').on('load', function(){
                    this.style.height=this.contentDocument.body.scrollHeight +'px';
                  });
        Severity: Major
        Found in app/assets/javascripts/widget.v2.js and 1 other location - About 1 hr to fix
        app/assets/javascripts/widget.v1.js on lines 86..88

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

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

          def user_params
            params.require(:user).permit(
              :profile_image,
              :name,
              :bio,
        Severity: Minor
        Found in app/controllers/admin/users_controller.rb - About 1 hr to fix

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

              if (window.jQuery === undefined || window.jQuery.fn.jquery !== jqueryVersion) {
                  loadScript(jqueryPath, initjQuery);
              } else {
                  initjQuery();
              }
          Severity: Major
          Found in app/assets/javascripts/widget.v2.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/widget.v1.js on lines 52..56

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

          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

              if (window.jQuery === undefined || window.jQuery.fn.jquery !== jqueryVersion) {
                  loadScript(jqueryPath, initjQuery);
              } else {
                  initjQuery();
              }
          Severity: Major
          Found in app/assets/javascripts/widget.v1.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/widget.v2.js on lines 52..56

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

          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 category_import(obj_hash, row_num, object=nil)
              @@submited_record_count += 1
              begin
                if object.present?
                  object.attributes = obj_hash
          Severity: Minor
          Found in app/jobs/import_job.rb and 1 other location - About 55 mins to fix
          app/jobs/import_job.rb on lines 123..138

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

          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 forum_import(obj_hash, row_num, object=nil)
              @@submited_record_count += 1
              begin
                if object.present?
                  object.attributes = obj_hash
          Severity: Minor
          Found in app/jobs/import_job.rb and 1 other location - About 55 mins to fix
          app/jobs/import_job.rb on lines 142..157

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

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

            def index
              #@topics = Topic.mine(current_user.id).pending.page params[:page]
          
              if (current_user.is_admin? || current_user.is_agent?) && (forums? || tickets?)
                redirect_to admin_topics_path
          Severity: Minor
          Found in app/controllers/admin/dashboard_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_forwarded_message_from_email has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.create_forwarded_message_from_email(email, subject, raw, message, token, to, cc, number_of_attachments, spam_score, spam_report)
          
              # Parse from out of the forwarded raw body
              from = raw[/From: .*<(.*?)>/, 1]
              from_token = from.split("@")[0]
          Severity: Minor
          Found in lib/email_processor.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