colinschoen/enrollme

View on GitHub
app/mailers/admin_mailer.rb

Summary

Maintainability
A
40 mins
Test Coverage

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

  def send_disapproved_email(team)
    @team = team

    @team.users.each do |disapproved_user|
      @user = disapproved_user
Severity: Minor
Found in app/mailers/admin_mailer.rb and 2 other locations - About 20 mins to fix
app/mailers/admin_mailer.rb on lines 22..29
app/mailers/email_students.rb on lines 14..21

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

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 3 locations. Consider refactoring.
Open

  def send_approved_email(team)
    @team = team

    @team.users.each do |approved_user|
      @user = approved_user
Severity: Minor
Found in app/mailers/admin_mailer.rb and 2 other locations - About 20 mins to fix
app/mailers/admin_mailer.rb on lines 34..41
app/mailers/email_students.rb on lines 14..21

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

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

Operator = should be surrounded by a single space.
Open

    @url  = 'http://www.gmail.com'
Severity: Minor
Found in app/mailers/admin_mailer.rb by rubocop

Checks that operators have space around them, except for ** which should not have surrounding space.

Example:

# bad
total = 3*4
"apple"+"juice"
my_number = 38/4
a ** b

# good
total = 3 * 4
"apple" + "juice"
my_number = 38 / 4
a**b

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

      @url = ENV["SERVER_EMAIL"]
Severity: Minor
Found in app/mailers/admin_mailer.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"

Trailing whitespace detected.
Open

      #{params[:status]} teams in EnrollMe") do |format| 
Severity: Minor
Found in app/mailers/admin_mailer.rb by rubocop

Pass &:html as an argument to mail instead of a block.
Open

      as admin for EnrollMe") do |format|
      format.html
    end
Severity: Minor
Found in app/mailers/admin_mailer.rb by rubocop

Use symbols as procs when possible.

Example:

# bad
something.map { |s| s.upcase }

# good
something.map(&:upcase)

Missing top-level class documentation comment.
Open

class AdminMailer < ApplicationMailer
Severity: Minor
Found in app/mailers/admin_mailer.rb by rubocop

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

Example:

# bad
class Person
  # ...
end

# good
# Description/Explanation of Person class
class Person
  # ...
end

Pass &:html as an argument to mail instead of a block.
Open

      mail(to: @user.email, subject: 'Your team has been approved') do |format|
        format.html
      end
Severity: Minor
Found in app/mailers/admin_mailer.rb by rubocop

Use symbols as procs when possible.

Example:

# bad
something.map { |s| s.upcase }

# good
something.map(&:upcase)

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

    if !(Team.where("approved = ? AND submitted = ?", false, true).nil?)
Severity: Minor
Found in app/mailers/admin_mailer.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"

Don't use parentheses around a method call.
Open

    if !(Team.where("approved = ? AND submitted = ?", false, true).nil?)
Severity: Minor
Found in app/mailers/admin_mailer.rb by rubocop

This cop checks for redundant parentheses.

Example:

# bad
(x) if ((y.z).nil?)

# good
x if y.z.nil?

Line is too long. [82/80]
Open

      mail(to: @user.email, subject: 'Your team has been disapproved') do |format|
Severity: Minor
Found in app/mailers/admin_mailer.rb by rubocop

Pass &:html as an argument to mail instead of a block.
Open

      All data that was deleted') do |format|
      format.html
    end
Severity: Minor
Found in app/mailers/admin_mailer.rb by rubocop

Use symbols as procs when possible.

Example:

# bad
something.map { |s| s.upcase }

# good
something.map(&:upcase)

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

    @url = ENV["SERVER_EMAIL"]
Severity: Minor
Found in app/mailers/admin_mailer.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"

Pass &:html as an argument to mail instead of a block.
Open

      mail(to: @user.email, subject: 'Your team has been disapproved') do |format|
        format.html
      end
Severity: Minor
Found in app/mailers/admin_mailer.rb by rubocop

Use symbols as procs when possible.

Example:

# bad
something.map { |s| s.upcase }

# good
something.map(&:upcase)

Unnecessary spacing detected.
Open

    @url  = 'http://www.gmail.com'
Severity: Minor
Found in app/mailers/admin_mailer.rb by rubocop

This cop checks for extra/unnecessary whitespace.

Example:

# good if AllowForAlignment is true
name      = "RuboCop"
# Some comment and an empty line

website  += "/bbatsov/rubocop" unless cond
puts        "rubocop"          if     debug

# bad for any configuration
set_app("RuboCop")
website  = "https://github.com/bbatsov/rubocop"

Trailing whitespace detected.
Open

    mail(to: @admin.email, subject: "Here is list of 
Severity: Minor
Found in app/mailers/admin_mailer.rb by rubocop

Favor unless over if for negative conditions.
Open

    if !(Team.where("approved = ? AND submitted = ?", false, true).nil?)
      Admin.all.each do |admin|
        look_at_submission(admin.email).deliver
      end
    end
Severity: Minor
Found in app/mailers/admin_mailer.rb by rubocop

Checks for uses of if with a negated condition. Only ifs without else are considered. There are three different styles:

- both
- prefix
- postfix

Example: EnforcedStyle: both (default)

# enforces `unless` for `prefix` and `postfix` conditionals

# bad

if !foo
  bar
end

# good

unless foo
  bar
end

# bad

bar if !foo

# good

bar unless foo

Example: EnforcedStyle: prefix

# enforces `unless` for just `prefix` conditionals

# bad

if !foo
  bar
end

# good

unless foo
  bar
end

# good

bar if !foo

Example: EnforcedStyle: postfix

# enforces `unless` for just `postfix` conditionals

# bad

bar if !foo

# good

bar unless foo

# good

if !foo
  bar
end

Use a guard clause instead of wrapping the code inside a conditional expression.
Open

    if !(Team.where("approved = ? AND submitted = ?", false, true).nil?)
Severity: Minor
Found in app/mailers/admin_mailer.rb by rubocop

Use a guard clause instead of wrapping the code inside a conditional expression

Example:

# bad
def test
  if something
    work
  end
end

# good
def test
  return unless something
  work
end

# also good
def test
  work if something
end

# bad
if something
  raise 'exception'
else
  ok
end

# good
raise 'exception' if something
ok

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

      @url = ENV["SERVER_EMAIL"]
Severity: Minor
Found in app/mailers/admin_mailer.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"

Pass &:html as an argument to mail instead of a block.
Open

      #{params[:status]} teams in EnrollMe") do |format| 
      format.html
    end
Severity: Minor
Found in app/mailers/admin_mailer.rb by rubocop

Use symbols as procs when possible.

Example:

# bad
something.map { |s| s.upcase }

# good
something.map(&:upcase)

There are no issues that match your filters.

Category
Status