18F/dolores-landingham-slack-bot

View on GitHub
app/models/employee.rb

Summary

Maintainability
A
0 mins
Test Coverage

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Open

      message: I18n.t('employees.errors.slack_username_format'),
Severity: Minor
Found in app/models/employee.rb by rubocop

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"

Redundant self detected.
Open

    results = self.all.where("slack_username like ?", "%#{params[:slack_username]}%")
Severity: Minor
Found in app/models/employee.rb by rubocop

This cop checks for redundant uses of self.

The usage of self is only needed when:

  • Sending a message to same object with zero arguments in presence of a method name clash with an argument or a local variable.

  • Calling an attribute writer to prevent an local variable assignment.

Note, with using explicit self you can only send messages with public or protected scope, you cannot send private messages this way.

Note we allow uses of self with operators because it would be awkward otherwise.

Example:

# bad
def foo(bar)
  self.baz
end

# good
def foo(bar)
  self.bar  # Resolves name clash with the argument.
end

def foo
  bar = 1
  self.bar  # Resolves name clash with the local variable.
end

def foo
  %w[x y z].select do |bar|
    self.bar == bar  # Resolves name clash with argument of the block.
  end
end

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Open

          'employees.errors.slack_username_in_org',
Severity: Minor
Found in app/models/employee.rb by rubocop

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"

Line is too long. [85/80]
Open

    results = self.all.where("slack_username like ?", "%#{params[:slack_username]}%")
Severity: Minor
Found in app/models/employee.rb by rubocop

Line is too long. [84/80]
Open

  validates_uniqueness_of :slack_username, conditions: -> { where(deleted_at: nil) }
Severity: Minor
Found in app/models/employee.rb by rubocop

There are no issues that match your filters.

Category
Status