helpyio/helpy

View on GitHub

Showing 68 of 242 total issues

Method create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    @user = User.new(user_params)
    fetch_counts

    # Set the password if it is not provided
Severity: Minor
Found in app/controllers/admin/users_controller.rb - About 35 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_user_for_email has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.create_user_for_email(email_address, token, name, ticket_status)
    # create user
    @user = User.new

    @token, enc = Devise.token_generator.generate(User, :reset_password_token)
Severity: Minor
Found in lib/email_processor.rb - About 35 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

Avoid too many return statements within this method.
Open

    return if ['trash','spam'].include?(@topic.current_status)
Severity: Major
Found in app/mailers/post_mailer.rb - About 30 mins to fix

    Method avatar_image has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def avatar_image(user, size=40, font=16)
        return if user.nil?
        if user.profile_image.present?
          image_tag(user.profile_image.url, width: "#{size}px", class: 'img-circle') 
        elsif cloudinary_enabled? && user.avatar.present?
    Severity: Minor
    Found in app/helpers/users_helper.rb - About 25 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 search_topics has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def search_topics
        if @start_date.present? && @end_date.present?
          topics_to_search = Topic.where('created_at >= ?', @start_date).where('created_at <= ?', @end_date)
        else
          topics_to_search = Topic.all
    Severity: Minor
    Found in app/controllers/concerns/search_concern.rb - About 25 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 get_topics_cohort has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def get_topics_cohort
        #  If affect is all, that means all matching tickets should be bulk updated
        if params[:affect].present? && params[:affect] == "all"
          if params[:status].present?
            @topics = Topic.where(current_status: params[:status]).all
    Severity: Minor
    Found in app/controllers/admin/topics_controller.rb - About 25 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

    Function ready has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    Helpy.ready = function(){
    
      $('.selectpicker').selectpicker({});
    
      $(".best_in_place").best_in_place();
    Severity: Minor
    Found in app/assets/javascripts/app.js - About 25 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 current_user has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

              def current_user
                passed_token = request.headers["X-Token"] || params["token"]
                token = ApiKey.where(access_token: passed_token).first
    
                if token && !token.expired?
    Severity: Minor
    Found in app/controllers/api/v1/defaults.rb - About 25 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