app/models/user.rb

Summary

Maintainability
B
6 hrs
Test Coverage

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

class User < ActiveRecord::Base
  include Concerns::Slackable
  include Concerns::Cacheable

  QUORUM_PERCENTAGE = 0.6
Severity: Minor
Found in app/models/user.rb - About 4 hrs to fix

Method find_trello_user has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def find_trello_user
    [trello_id, email, username, slack_user&.name].each do |query|
      next unless query.present?
      user = begin
        Trello::Member.find(query)
Severity: Minor
Found in app/models/user.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 from_multi has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.from_multi(multi)
    Array.wrap(multi).map do |item|
      return item if item.is_a?(User) || item.is_a?(Team)
      return find(item) if item.is_a?(Integer)
      return where(username: item).first if item.is_a?(String)
Severity: Minor
Found in app/models/user.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 from_trello has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.from_trello(trello_id)
    user = where(trello_id: trello_id).first
    return user if user.present?

    user = Trello::Member.find trello_id
Severity: Minor
Found in app/models/user.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

Ambiguous splat operator. Parenthesize the method arguments if it's surely a splat operator, or add a whitespace to the right of the * if it should be a multiplication.
Open

    from_username_domain *email.split('@')
Severity: Minor
Found in app/models/user.rb by rubocop

This cop checks for ambiguous operators in the first argument of a method invocation without parentheses.

Example:

# bad

# The `*` is interpreted as a splat operator but it could possibly be
# a `*` method invocation (i.e. `do_something.*(some_array)`).
do_something *some_array

Example:

# good

# With parentheses, there's no ambiguity.
do_something(*some_array)

There are no issues that match your filters.

Category
Status