18F/confidential-survey

View on GitHub
app/models/choice.rb

Summary

Maintainability
A
0 mins
Test Coverage

Choice has no descriptive comment
Open

class Choice
Severity: Minor
Found in app/models/choice.rb by reek

Classes and modules are the units of reuse and release. It is therefore considered good practice to annotate every class and module with a brief comment outlining its responsibilities.

Example

Given

class Dummy
  # Do things...
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [1]:Dummy has no descriptive comment (IrresponsibleModule)

Fixing this is simple - just an explaining comment:

# The Dummy class is responsible for ...
class Dummy
  # Do things...
end

Choice#initialize_from_split performs a nil-check
Open

    return unless @label.nil?
Severity: Minor
Found in app/models/choice.rb by reek

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

Choice#initialize performs a nil-check
Open

    if label.nil?
Severity: Minor
Found in app/models/choice.rb by reek

A NilCheck is a type check. Failures of NilCheck violate the "tell, don't ask" principle.

Additionally, type checks often mask bigger problems in your source code like not using OOP and / or polymorphism when you should.

Example

Given

class Klass
  def nil_checker(argument)
    if argument.nil?
      puts "argument isn't nil!"
    end
  end
end

Reek would emit the following warning:

test.rb -- 1 warning:
  [3]:Klass#nil_checker performs a nil-check. (NilCheck)

Do not freeze immutable objects, as freezing them has no effect.
Open

  COMBINATION_LABEL = 'Combination'.freeze
Severity: Minor
Found in app/models/choice.rb by rubocop

This cop check for uses of Object#freeze on immutable objects.

Example:

# bad
CONST = 1.freeze

# good
CONST = 1

Do not freeze immutable objects, as freezing them has no effect.
Open

  COMBINATION_VALUE = 'combination'.freeze
Severity: Minor
Found in app/models/choice.rb by rubocop

This cop check for uses of Object#freeze on immutable objects.

Example:

# bad
CONST = 1.freeze

# good
CONST = 1

Add an empty line after magic comments.
Open

class Choice
Severity: Minor
Found in app/models/choice.rb by rubocop

Checks for a newline after the final magic comment.

Example:

# good
# frozen_string_literal: true

# Some documentation for Person
class Person
  # Some code
end

# bad
# frozen_string_literal: true
# Some documentation for Person
class Person
  # Some code
end

There are no issues that match your filters.

Category
Status