AgileVentures/LocalSupport

View on GitHub
app/controllers/proposed_organisations_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage

Method has too many lines. [18/7] (https://github.com/bbatsov/ruby-style-guide#short-methods)
Open

  def self.build params
    params.require(:proposed_organisation).permit(
      :superadmin_email_to_add,
      :description,
      :address,

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.

Method has too many lines. [9/7] (https://github.com/bbatsov/ruby-style-guide#short-methods)
Open

  def create
    make_user_into_org_admin_of_new_proposed_org
    @proposed_organisation.check_geocode
    if @proposed_organisation.save
      session[:proposed_organisation_id] = @proposed_organisation.id

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.

Line is too long. [91/90] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
Open

      redirect_to @proposed_organisation, notice: 'Organisation is pending admin approval.'

Use a guard clause instead of wrapping the code inside a conditional expression. (https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals)
Open

    unless session[:proposed_organisation_id] || current_user.try(:superadmin)

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

Line is too long. [104/90] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
Open

    usr = User.find params[:proposed_organisation][:user_id] if params[:proposed_organisation][:user_id]

Line is too long. [102/90] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)
Open

    @proposer_email = @proposed_organisation.users.first.email if !@proposed_organisation.users.empty?

Favor unless over if for negative conditions. (https://github.com/bbatsov/ruby-style-guide#unless-for-negatives)
Open

    @proposer_email = @proposed_organisation.users.first.email if !@proposed_organisation.users.empty?

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. (https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals)
Open

    unless current_user.try(:superadmin?)

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

There are no issues that match your filters.

Category
Status