helpyio/helpy

View on GitHub

Showing 242 of 242 total issues

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

    for (var i in allScripts) {
        var name = allScripts[i].src;
        if(name && name.indexOf(scriptName) > 0)
            targetScripts.push(allScripts[i]);
    }
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 16..20

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

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

    for (var i in allScripts) {
        var name = allScripts[i].src;
        if(name && name.indexOf(scriptName) > 0)
            targetScripts.push(allScripts[i]);
    }
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 16..20

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

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

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

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

      $(window).off().on("popstate", function(){
        console.log("Popstate fired: " + location.href);
        $.getScript(location.href);
      });
    Severity: Major
    Found in app/assets/javascripts/admin.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/app.js on lines 158..161

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

    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-link').find('a').off().on('click', function(){
        ga('send', 'event', 'Inpage-nav','Click', "Topic: " + $(this).text());
      });
    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 61..63
    app/assets/javascripts/event-tracking.js on lines 69..71

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

    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

        $(window).off().on("popstate", function(){
          console.log("Popstate fired: " + location.href);
          $.getScript(location.href);
        });
    Severity: Major
    Found in app/assets/javascripts/app.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/admin.js on lines 260..263

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

    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

      $('.user-link').find('a').off().on('click', function(){
        ga('send', 'event', 'Inpage-nav','Click', "User: " + $(this).text());
      });
    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 61..63
    app/assets/javascripts/event-tracking.js on lines 65..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 61.

    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

      $('tr.forum').find('a').off().on('click', function(){
        ga('send', 'event', 'Inpage-nav','Click', "Forum: " + $(this).text());
      });
    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 65..67
    app/assets/javascripts/event-tracking.js on lines 69..71

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

    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_forwarded_message_from_email has 32 lines of code (exceeds 25 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 1 hr to fix

      Method split_topic has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def split_topic
          parent_topic = Topic.find(params[:topic_id])
          parent_post = Post.find(params[:post_id])
      
          @topic = Topic.new(
      Severity: Minor
      Found in app/controllers/admin/topics_controller.rb - About 1 hr to fix

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

          def topic_search
        
            # search for user, if [one] found, we'll give details on that person
            # if more than one found, we'll list them, if search is for "users" then show all
            if params[:q] == 'users'
        Severity: Minor
        Found in app/controllers/admin/search_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

            if ($('.selected').size() === 0) {
              $startingTopic.addClass('selected');
              pressEnter($('.topic').last().find('a.topic-link'));
            } else {
              var $nowSelected = $('.selected').prev('.topic');
        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 147..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 60.

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

          def import(file_path, file_name, klass, user, import)
            started_at = Time.now
            spreadsheet = open_spreadsheet(file_path, file_name)
            header = spreadsheet.row(1)
            if true #header == klass.new.attributes.keys
        Severity: Minor
        Found in app/jobs/import_job.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 11 (exceeds 5 allowed). Consider refactoring.
        Open

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

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

          $('#did-this-help-no').off().on("click", function(){
            Helpy.didthisHelp("no");
            ga('send', 'event', 'Feedback','No', $('#page-title h1').text());
          });
        Severity: Major
        Found in app/assets/javascripts/event-tracking.js and 1 other location - About 1 hr to fix
        app/assets/javascripts/event-tracking.js on lines 85..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 60.

        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_forwarded_message_from_email has 10 arguments (exceeds 4 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)
        Severity: Major
        Found in lib/email_processor.rb - About 1 hr to fix

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

            $('#did-this-help-yes').off().on("click", function(){
              Helpy.didthisHelp("yes");
              ga('send', 'event', 'Feedback','Yes', $('#page-title h1').text());
            });
          Severity: Major
          Found in app/assets/javascripts/event-tracking.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/event-tracking.js on lines 80..83

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

          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 ($('.selected').size() === 0) {
                $startingTopic.addClass('selected');
                // $('.topic').first().addClass('selected');
                pressEnter($('.topic').first().find('a.topic-link'));
              } else {
          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 170..178

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

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

            def serialize_autocomplete_result(results)
              serialized_result = []
              results.each do |result|
                if result.searchable_type == "Topic"
                  serialized_result << {
          Severity: Minor
          Found in app/controllers/result_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 create_new_ticket_from_email has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.create_new_ticket_from_email(email, email_address, email_name, subject, raw, message, token, to, cc, number_of_attachments, spam_score, spam_report)
          
              # flag as spam if below spam score threshold
              ticket_status = (spam_score > AppSettings["email.spam_assassin_filter"].to_f) ? "spam" : "new"
          
          
          Severity: Minor
          Found in lib/email_processor.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

          Severity
          Category
          Status
          Source
          Language