houston/houston-core

View on GitHub
app/models/persistent_trigger.rb

Summary

Maintainability
A
0 mins
Test Coverage

Indent access modifiers like private.
Open

private
Severity: Minor
Found in app/models/persistent_trigger.rb by rubocop

Modifiers should be indented as deep as method definitions, or as deep as the class/module keyword, depending on configuration.

Example: EnforcedStyle: indent (default)

# bad
class Plumbus
private
  def smooth; end
end

# good
class Plumbus
  private
  def smooth; end
end

Example: EnforcedStyle: outdent

# bad
class Plumbus
  private
  def smooth; end
end

# good
class Plumbus
private
  def smooth; end
end

Extra blank line detected.
Open


private
Severity: Minor
Found in app/models/persistent_trigger.rb by rubocop

This cops checks for two or more consecutive blank lines.

Example:

# bad - It has two empty lines.
some_method
# one empty line
# two empty lines
some_method

# good
some_method
# one empty line
some_method

Missing top-level class documentation comment.
Open

class PersistentTrigger < ActiveRecord::Base
Severity: Minor
Found in app/models/persistent_trigger.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

Prefer single-quoted strings inside interpolations.
Open

  validates :type, inclusion: { in: TYPES, message: "{value} is not valid Trigger type; use #{TYPES.map(&:inspect).to_sentence(two_words_connector: " or ", last_word_connector: ", or ")}" }
Severity: Minor
Found in app/models/persistent_trigger.rb by rubocop

This cop checks that quotes inside the string interpolation match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
result = "Tests #{success ? "PASS" : "FAIL"}"

# good
result = "Tests #{success ? 'PASS' : 'FAIL'}"

Example: EnforcedStyle: double_quotes

# bad
result = "Tests #{success ? 'PASS' : 'FAIL'}"

# good
result = "Tests #{success ? "PASS" : "FAIL"}"

Use %i or %I for an array of symbols.
Open

  TYPES = [:on, :every].freeze
Severity: Minor
Found in app/models/persistent_trigger.rb by rubocop

This cop can check for array literals made up of symbols that are not using the %i() syntax.

Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.

Configuration option: MinSize If set, arrays with fewer elements than this value will not trigger the cop. For example, a MinSize of3` will not enforce a style on an array of 2 or fewer elements.

Example: EnforcedStyle: percent (default)

# good
%i[foo bar baz]

# bad
[:foo, :bar, :baz]

Example: EnforcedStyle: brackets

# good
[:foo, :bar, :baz]

# bad
%i[foo bar baz]

Extra blank line detected.
Open


  TYPES.each do |type|
Severity: Minor
Found in app/models/persistent_trigger.rb by rubocop

This cops checks for two or more consecutive blank lines.

Example:

# bad - It has two empty lines.
some_method
# one empty line
# two empty lines
some_method

# good
some_method
# one empty line
some_method

Line is too long. [189/80]
Open

  validates :type, inclusion: { in: TYPES, message: "{value} is not valid Trigger type; use #{TYPES.map(&:inspect).to_sentence(two_words_connector: " or ", last_word_connector: ", or ")}" }
Severity: Minor
Found in app/models/persistent_trigger.rb by rubocop

Extra blank line detected.
Open


  def type
Severity: Minor
Found in app/models/persistent_trigger.rb by rubocop

This cops checks for two or more consecutive blank lines.

Example:

# bad - It has two empty lines.
some_method
# one empty line
# two empty lines
some_method

# good
some_method
# one empty line
some_method

Line is too long. [108/80]
Open

    @registered_trigger ||= Houston.config.triggers.detect { |trigger| trigger.persistent_trigger_id == id }
Severity: Minor
Found in app/models/persistent_trigger.rb by rubocop

Extra blank line detected.
Open


  def register!
Severity: Minor
Found in app/models/persistent_trigger.rb by rubocop

This cops checks for two or more consecutive blank lines.

Example:

# bad - It has two empty lines.
some_method
# one empty line
# two empty lines
some_method

# good
some_method
# one empty line
some_method

Use empty lines between method definitions.
Open

  def register!
Severity: Minor
Found in app/models/persistent_trigger.rb by rubocop

This cop checks whether method definitions are separated by one empty line.

NumberOfEmptyLines can be and integer (e.g. 1 by default) or an array (e.g. [1, 2]) to specificy a minimum and a maximum of empty lines.

AllowAdjacentOneLineDefs can be used to configure is adjacent one line methods definitions are an offense

Example:

# bad
def a
end
def b
end

Example:

# good
def a
end

def b
end

Extra blank line detected.
Open


  def self.load_all
Severity: Minor
Found in app/models/persistent_trigger.rb by rubocop

This cops checks for two or more consecutive blank lines.

Example:

# bad - It has two empty lines.
some_method
# one empty line
# two empty lines
some_method

# good
some_method
# one empty line
some_method

Use empty lines between method definitions.
Open

  def type
Severity: Minor
Found in app/models/persistent_trigger.rb by rubocop

This cop checks whether method definitions are separated by one empty line.

NumberOfEmptyLines can be and integer (e.g. 1 by default) or an array (e.g. [1, 2]) to specificy a minimum and a maximum of empty lines.

AllowAdjacentOneLineDefs can be used to configure is adjacent one line methods definitions are an offense

Example:

# bad
def a
end
def b
end

Example:

# good
def a
end

def b
end

Prefer single-quoted strings inside interpolations.
Open

  validates :type, inclusion: { in: TYPES, message: "{value} is not valid Trigger type; use #{TYPES.map(&:inspect).to_sentence(two_words_connector: " or ", last_word_connector: ", or ")}" }
Severity: Minor
Found in app/models/persistent_trigger.rb by rubocop

This cop checks that quotes inside the string interpolation match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
result = "Tests #{success ? "PASS" : "FAIL"}"

# good
result = "Tests #{success ? 'PASS' : 'FAIL'}"

Example: EnforcedStyle: double_quotes

# bad
result = "Tests #{success ? 'PASS' : 'FAIL'}"

# good
result = "Tests #{success ? "PASS" : "FAIL"}"

Line is too long. [133/80]
Open

    @registered_trigger = Houston.config.triggers.create(type, value, action, params.merge(trigger: self), persistent_trigger_id: id)
Severity: Minor
Found in app/models/persistent_trigger.rb by rubocop

Extra empty line detected at class body end.
Open


end
Severity: Minor
Found in app/models/persistent_trigger.rb by rubocop

This cops checks if empty lines around the bodies of classes match the configuration.

Example: EnforcedStyle: empty_lines

# good

class Foo

  def bar
    # ...
  end

end

Example: EnforcedStyle: emptylinesexcept_namespace

# good

class Foo
  class Bar

    # ...

  end
end

Example: EnforcedStyle: emptylinesspecial

# good
class Foo

  def bar; end

end

Example: EnforcedStyle: noemptylines (default)

# good

class Foo
  def bar
    # ...
  end
end

There are no issues that match your filters.

Category
Status