codeforamerica/ohana-api

View on GitHub
app/validators/regex_validator.rb

Summary

Maintainability
A
35 mins
Test Coverage
A
100%

RegexValidator#regex_validate_each has 5 parameters
Open

  def regex_validate_each(regex, err_msg, record, attribute, value)
Severity: Minor
Found in app/validators/regex_validator.rb by reek

A Long Parameter List occurs when a method has a lot of parameters.

Example

Given

class Dummy
  def long_list(foo,bar,baz,fling,flung)
    puts foo,bar,baz,fling,flung
  end
end

Reek would report the following warning:

test.rb -- 1 warning:
  [2]:Dummy#long_list has 5 parameters (LongParameterList)

A common solution to this problem would be the introduction of parameter objects.

RegexValidator#regex_validate_each is controlled by argument 'regex'
Open

    return if value&.match?(regex)
Severity: Minor
Found in app/validators/regex_validator.rb by reek

Control Parameter is a special case of Control Couple

Example

A simple example would be the "quoted" parameter in the following method:

def write(quoted)
  if quoted
    write_quoted @value
  else
    write_unquoted @value
  end
end

Fixing those problems is out of the scope of this document but an easy solution could be to remove the "write" method alltogether and to move the calls to "writequoted" / "writeunquoted" in the initial caller of "write".

RegexValidator#regex_validate_each is controlled by argument 'value'
Open

    return if value&.match?(regex)
Severity: Minor
Found in app/validators/regex_validator.rb by reek

Control Parameter is a special case of Control Couple

Example

A simple example would be the "quoted" parameter in the following method:

def write(quoted)
  if quoted
    write_quoted @value
  else
    write_unquoted @value
  end
end

Fixing those problems is out of the scope of this document but an easy solution could be to remove the "write" method alltogether and to move the calls to "writequoted" / "writeunquoted" in the initial caller of "write".

Method regex_validate_each has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def regex_validate_each(regex, err_msg, record, attribute, value)
Severity: Minor
Found in app/validators/regex_validator.rb - About 35 mins to fix

    There are no issues that match your filters.

    Category
    Status