colinschoen/enrollme

View on GitHub
app/mailers/email_students.rb

Summary

Maintainability
A
20 mins
Test Coverage

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

    def successfully_submitted_email(team)
      @team = team
      
      @team.users.each do |student|
         @user = student
Severity: Minor
Found in app/mailers/email_students.rb and 2 other locations - About 20 mins to fix
app/mailers/admin_mailer.rb on lines 22..29
app/mailers/admin_mailer.rb on lines 34..41

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

Trailing whitespace detected.
Open

    
Severity: Minor
Found in app/mailers/email_students.rb by rubocop

Trailing whitespace detected.
Open

      
Severity: Minor
Found in app/mailers/email_students.rb by rubocop

Use 2 (not 3) spaces for indentation.
Open

         @user = student
Severity: Minor
Found in app/mailers/email_students.rb by rubocop

This cops checks for indentation that doesn't use the specified number of spaces.

See also the IndentationConsistency cop which is the companion to this one.

Example:

# bad
class A
 def test
  puts 'hello'
 end
end

# good
class A
  def test
    puts 'hello'
  end
end

Example: IgnoredPatterns: ['^\s*module']

# bad
module A
class B
  def test
  puts 'hello'
  end
end
end

# good
module A
class B
  def test
    puts 'hello'
  end
end
end

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/email_students.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"

Use 2 (not 4) spaces for indentation.
Open

        @user = user
Severity: Minor
Found in app/mailers/email_students.rb by rubocop

This cops checks for indentation that doesn't use the specified number of spaces.

See also the IndentationConsistency cop which is the companion to this one.

Example:

# bad
class A
 def test
  puts 'hello'
 end
end

# good
class A
  def test
    puts 'hello'
  end
end

Example: IgnoredPatterns: ['^\s*module']

# bad
module A
class B
  def test
  puts 'hello'
  end
end
end

# good
module A
class B
  def test
    puts 'hello'
  end
end
end

Trailing whitespace detected.
Open

    
Severity: Minor
Found in app/mailers/email_students.rb by rubocop

Line is too long. [119/80]
Open

         mail(to: @user.email, subject: 'Your team has successfully submitted team enrollment to EnrollMe') do |format|
Severity: Minor
Found in app/mailers/email_students.rb by rubocop

Trailing whitespace detected.
Open

    
Severity: Minor
Found in app/mailers/email_students.rb by rubocop

Use 2 (not 4) spaces for indentation.
Open

    default from: 'enrollmeberkeley@gmail.com'
Severity: Minor
Found in app/mailers/email_students.rb by rubocop

This cops checks for indentation that doesn't use the specified number of spaces.

See also the IndentationConsistency cop which is the companion to this one.

Example:

# bad
class A
 def test
  puts 'hello'
 end
end

# good
class A
  def test
    puts 'hello'
  end
end

Example: IgnoredPatterns: ['^\s*module']

# bad
module A
class B
  def test
  puts 'hello'
  end
end
end

# good
module A
class B
  def test
    puts 'hello'
  end
end
end

Use 2 (not 3) spaces for indentation.
Open

       @user = user
Severity: Minor
Found in app/mailers/email_students.rb by rubocop

This cops checks for indentation that doesn't use the specified number of spaces.

See also the IndentationConsistency cop which is the companion to this one.

Example:

# bad
class A
 def test
  puts 'hello'
 end
end

# good
class A
  def test
    puts 'hello'
  end
end

Example: IgnoredPatterns: ['^\s*module']

# bad
module A
class B
  def test
  puts 'hello'
  end
end
end

# good
module A
class B
  def test
    puts 'hello'
  end
end
end

Missing top-level class documentation comment.
Open

class EmailStudents < ApplicationMailer
Severity: Minor
Found in app/mailers/email_students.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

Use 2 (not 3) spaces for indentation.
Open

            format.html
Severity: Minor
Found in app/mailers/email_students.rb by rubocop

This cops checks for indentation that doesn't use the specified number of spaces.

See also the IndentationConsistency cop which is the companion to this one.

Example:

# bad
class A
 def test
  puts 'hello'
 end
end

# good
class A
  def test
    puts 'hello'
  end
end

Example: IgnoredPatterns: ['^\s*module']

# bad
module A
class B
  def test
  puts 'hello'
  end
end
end

# good
module A
class B
  def test
    puts 'hello'
  end
end
end

Trailing whitespace detected.
Open

    
Severity: Minor
Found in app/mailers/email_students.rb by rubocop

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

         mail(to: @user.email, subject: 'Your team has successfully submitted team enrollment to EnrollMe') do |format|
            format.html
         end
Severity: Minor
Found in app/mailers/email_students.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