asm-products/mana-rails

View on GitHub

Showing 8 of 8 total issues

Class User has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

class User < ActiveRecord::Base
  def to_param #overrides
    name
  end

Severity: Minor
Found in app/models/user.rb - About 2 hrs to fix

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

  def capture_mention(source)
    output = HTML::Pipeline::MentionFilter.mentioned_logins_in(source) do |mention|
      pre = mention[0] == "@" ? "" : mention.slice!(0)
      mention_user = User.find_for_mention(mention)
      mention_client = Client.find_for_mention(mention)
Severity: Minor
Found in app/models/concerns/markdown_concern.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 seed has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def self.seed only=[]
    only = [only] if only.class==String
    seed_data.each do |attributes|
      if only.empty? || only.include?(attributes[:klass])
        Permission.create!(attributes) unless Permission.where(attributes).any?
Severity: Minor
Found in app/models/permission.rb - About 45 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 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    user = User.find_by(name: username) || User.find_by(email: username)
    if user && user.authenticate(password) && current_team.users.include?(user)
      log_in user
      remember_me == '1' ? remember(user) : forget(user)
Severity: Minor
Found in app/controllers/sessions_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 default_values has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def default_values
    self.name = name.nil? ? generate_temp_username : name
    self.password = password.nil? ? SecureRandom.base64.tr('+/=', 'Qrt') : password
    self.password_confirmation = password_confirmation.nil? ? self.password : password_confirmation
  end
Severity: Minor
Found in app/models/contact.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 current_team has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def current_team
    return nil if request.subdomains.first == "www"
    if Rails.env == "development" && request.subdomains.empty?
      @current_team ||= Team.first
    else
Severity: Minor
Found in app/controllers/concerns/session.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 current_user has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def current_user
    if (user_id = session[:user_id])
      @current_user ||= User.find_by(id: user_id)
    elsif (user_id = cookies.signed[:user_id])
      user = User.find_by(id: user_id)
Severity: Minor
Found in app/controllers/concerns/session.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def initialize(user)
    if user.nil? || (user && user.current_team.nil?)
      user = User.new
      can :create, User
      can :create, Team
Severity: Minor
Found in app/models/ability.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