helpyio/helpy

View on GitHub

Showing 242 of 242 total issues

Class ApplicationController has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception
  helper_method :recaptcha_enabled?
Severity: Minor
Found in app/controllers/application_controller.rb - About 3 hrs to fix

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

      $('.settings-uploader').off().on('change', function(){
        var $this = $(this);
        var f = $this.val().split("\\");
        var filename = f[f.length-1];
        $('.hidden-header-logo').val("/uploads/logos/" + filename);
    Severity: Major
    Found in app/assets/javascripts/admin.js and 1 other location - About 3 hrs to fix
    app/assets/javascripts/admin.js on lines 160..165

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 98.

    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

      $('.favicon-uploader').off().on('change', function(){
        var $this = $(this);
        var f = $this.val().split("\\");
        var filename = f[f.length-1];
        $('.hidden-favicon').val("/uploads/logos/" + filename);
    Severity: Major
    Found in app/assets/javascripts/admin.js and 1 other location - About 3 hrs to fix
    app/assets/javascripts/admin.js on lines 153..158

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

    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

    Class Topic has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Topic < ActiveRecord::Base
    
      include SentenceCase
      include Hashid::Rails
      
    Severity: Minor
    Found in app/models/topic.rb - About 3 hrs to fix

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

          function loadCss(href) {
              var link_tag = document.createElement('link');
              link_tag.setAttribute("type", "text/css");
              link_tag.setAttribute("rel", "stylesheet");
              link_tag.setAttribute("href", href);
      Severity: Major
      Found in app/assets/javascripts/widget.v1.js and 1 other location - About 3 hrs to fix
      app/assets/javascripts/widget.v2.js on lines 43..49

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

      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

          function loadCss(href) {
              var link_tag = document.createElement('link');
              link_tag.setAttribute("type", "text/css");
              link_tag.setAttribute("rel", "stylesheet");
              link_tag.setAttribute("href", href);
      Severity: Major
      Found in app/assets/javascripts/widget.v2.js and 1 other location - About 3 hrs to fix
      app/assets/javascripts/widget.v1.js on lines 43..49

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

      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

      Class TopicsController has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class Admin::TopicsController < Admin::BaseController
      
        include SearchConcern
      
        before_action :verify_agent
      Severity: Minor
      Found in app/controllers/admin/topics_controller.rb - About 2 hrs to fix

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

                    login: permitted_params[:login],
                    email: permitted_params[:email],
                    account_number: permitted_params[:account_number],
                    password: permitted_params[:password],
                    name: permitted_params[:name],
        Severity: Major
        Found in app/controllers/api/v1/users.rb and 1 other location - About 2 hrs to fix
        app/controllers/api/v1/users.rb on lines 96..121

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

        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

                    login: permitted_params[:login],
                    email: permitted_params[:email],
                    account_number: permitted_params[:account_number],
                    password: permitted_params[:password],
                    name: permitted_params[:name],
        Severity: Major
        Found in app/controllers/api/v1/users.rb and 1 other location - About 2 hrs to fix
        app/controllers/api/v1/users.rb on lines 161..186

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

        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 a Cognitive Complexity of 19 (exceeds 5 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 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

        Function track has 61 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Helpy.track = function(){
        
          // Put the Google Analytics clientID into the Helpy data layer
          ga(function(tracker) {
            Helpy.clientId = tracker.get('clientId');
        Severity: Major
        Found in app/assets/javascripts/event-tracking.js - About 2 hrs to fix

          File admin_helper.rb has 257 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module AdminHelper
          
            include StatsHelper
            def assigned_to(topic)
              if topic.assigned_user.present?
          Severity: Minor
          Found in app/helpers/admin_helper.rb - About 2 hrs to fix

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

                    params do
                      requires :id, type: Integer, desc: "The ID of the Doc being updated"
                      optional :title, type: String, desc: "The name of the category of articles"
                      optional :category_id, type: Integer, desc: "The category the doc belongs to"
                      optional :body, type: String, desc: "The body/text of the article"
            Severity: Major
            Found in app/controllers/api/v1/docs.rb and 1 other location - About 2 hrs to fix
            app/controllers/api/v1/topics.rb on lines 83..95

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

            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

                    params do
                      requires :name, type: String, desc: "The subject of the ticket"
                      requires :body, type: String, desc: "The post body"
                      optional :team_list, type: String, desc: "The group that this ticket is assigned to"
                      optional :channel, type: String, desc: "The source channel the ticket was created from, Defaults to API if no value provided."
            Severity: Major
            Found in app/controllers/api/v1/topics.rb and 1 other location - About 2 hrs to fix
            app/controllers/api/v1/docs.rb on lines 67..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 80.

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

              def topic_import(obj_hash, row_num, object=nil)
                @@submited_record_count += 1
                obj_hash.reject!{|k| k=="posts_count" }
            
                if obj_hash["forum_id"].present? && obj_hash["user_id"].present?
            Severity: Minor
            Found in app/jobs/import_job.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 post_import has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

              def post_import(obj_hash, row_num, object=nil)
                @@submited_record_count += 1
                obj_hash.reject!{|k| k=="attachments" }
                if obj_hash["topic_id"].present? && obj_hash["user_id"].present?
                  if Topic.find_by_id(obj_hash["topic_id"]).present? && User.find_by_id(obj_hash["user_id"]).present?
            Severity: Minor
            Found in app/jobs/import_job.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 doc_import has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

              def doc_import(obj_hash, row_num, object=nil)
                @@submited_record_count += 1
                if obj_hash["user_id"].present? && obj_hash["category_id"].present?
                  if User.find_by_id(obj_hash["user_id"]).present? && Category.find_by_id(obj_hash["category_id"]).present?
                    begin
            Severity: Minor
            Found in app/jobs/import_job.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 create has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                params[:id].nil? ? @forum = Forum.find(params[:topic][:forum_id]) : @forum = Forum.find(params[:id])
            
                @topic = @forum.topics.new(
                  name: params[:topic][:name],
            Severity: Minor
            Found in app/controllers/topics_controller.rb - About 2 hrs to fix

            Cognitive Complexity

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

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

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

            Further reading

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

                if ($(this).hasClass('selected') !== true) {
                  $(this).css('cursor','auto');
                  $(this).css('border','1px solid #ddd');
                  $(this).css('box-shadow', '');
                  $(this).closest('.has-arrow').removeClass('over');
            Severity: Major
            Found in app/assets/javascripts/app.js and 1 other location - About 1 hr to fix
            app/assets/javascripts/app.js on lines 54..59

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

            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

              $('.thumbnail, .stats').on('mouseover',function(){
                $(this).css('cursor','pointer');
                $(this).css('border','1px solid #666');
                $(this).css('box-shadow', '0px 0px 10px #eee');
                $(this).closest('.has-arrow').addClass('over');
            Severity: Major
            Found in app/assets/javascripts/app.js and 1 other location - About 1 hr to fix
            app/assets/javascripts/app.js on lines 168..173

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

            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