njazari/sef-founderwall

View on GitHub
app/controllers/donors_controller.rb

Summary

Maintainability
A
35 mins
Test Coverage

Method has too many lines. [14/10]
Open

    def show
        @donor = Donor.find_by_id(params[:id])
        if @donor.nil? or @donor.status == false
            @error = 'Donor'
            render 'errors/status'

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for show is too high. [17.92/15]
Open

    def show
        @donor = Donor.find_by_id(params[:id])
        if @donor.nil? or @donor.status == false
            @error = 'Donor'
            render 'errors/status'

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Method show has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def show
        @donor = Donor.find_by_id(params[:id])
        if @donor.nil? or @donor.status == false
            @error = 'Donor'
            render 'errors/status'
Severity: Minor
Found in app/controllers/donors_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

Use 2 (not 4) spaces for indentation.
Open

            @tiers = Dedication.tiers

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 DonorsController < ApplicationController

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 4) spaces for indentation.
Open

        @donor = Donor.find_by_id(params[:id])

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 the return of the conditional for variable assignment and comparison.
Open

            if current_user
                @show_invisible = current_user.donor == @donor || current_user.admin?
            else
                @show_invisible = false
            end

Line is too long. [86/80]
Open

            @donor_unpublished_dedications_by_tier = @donor.dedications_by_tier(false)

Line is too long. [85/80]
Open

                @show_invisible = current_user.donor == @donor || current_user.admin?

Use || instead of or.
Open

        if @donor.nil? or @donor.status == false

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

Use 2 (not 4) spaces for indentation.
Open

                @show_invisible = current_user.donor == @donor || current_user.admin?

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 4) spaces for indentation.
Open

    def show

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 4) spaces for indentation.
Open

            @error = 'Donor'

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 4) spaces for indentation.
Open

                @show_invisible = false

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

Line is too long. [83/80]
Open

            @donor_published_dedications_by_tier = @donor.dedications_by_tier(true)

There are no issues that match your filters.

Category
Status