infusionvlc/ConexionFelina

View on GitHub
app/controllers/cats_controller.rb

Summary

Maintainability
A
15 mins
Test Coverage

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  def cat_params
    params.require(:cat).permit(:name, :bio, :birthday_date, :gender,
                                :sterilized, :abandoned_date, :document, :colony_id, :saved_state,
                                sufferings_attributes: [:id, :illness_id, :cat_id, :diagnosis_date, :notes, :chronic, :status, :_destroy])
Severity: Minor
Found in app/controllers/cats_controller.rb and 1 other location - About 15 mins to fix
app/controllers/cats/build_controller.rb on lines 36..38

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 26.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Align the elements of a hash literal if they span more than one line.
Open

       last_payment_date: Date.today, start_date: Date.today, user: current_user, cat: cat)
Severity: Minor
Found in app/controllers/cats_controller.rb by rubocop

Check that the keys, separators, and values of a multi-line hash literal are aligned according to configuration. The configuration options are:

- key (left align keys)
- separator (align hash rockets and colons, right align keys)
- table (left align keys, hash rockets, and values)

The treatment of hashes passed as the last argument to a method call can also be configured. The options are:

- always_inspect
- always_ignore
- ignore_implicit (without curly braces)
- ignore_explicit (with curly braces)

Example:

# EnforcedHashRocketStyle: key (default)
# EnforcedColonStyle: key (default)

# good
{
  foo: bar,
  ba: baz
}
{
  :foo => bar,
  :ba => baz
}

# bad
{
  foo: bar,
   ba: baz
}
{
  :foo => bar,
   :ba => baz
}

Example:

# EnforcedHashRocketStyle: separator
# EnforcedColonStyle: separator

#good
{
  foo: bar,
   ba: baz
}
{
  :foo => bar,
   :ba => baz
}

#bad
{
  foo: bar,
  ba: baz
}
{
  :foo => bar,
  :ba => baz
}
{
  :foo => bar,
  :ba  => baz
}

Example:

# EnforcedHashRocketStyle: table
# EnforcedColonStyle: table

#good
{
  foo: bar,
  ba:  baz
}
{
  :foo => bar,
  :ba  => baz
}

#bad
{
  foo: bar,
  ba: baz
}
{
  :foo => bar,
   :ba => baz
}

Line is too long. [91/80]
Open

       last_payment_date: Date.today, start_date: Date.today, user: current_user, cat: cat)
Severity: Minor
Found in app/controllers/cats_controller.rb by rubocop

Line is too long. [138/80]
Open

                                sufferings_attributes: [:id, :illness_id, :cat_id, :diagnosis_date, :notes, :chronic, :status, :_destroy])
Severity: Minor
Found in app/controllers/cats_controller.rb by rubocop

Prefer single-quoted strings when you don't need string interpolation or special symbols.
Open

    flash[:alert] = "You are not autorized to perform this action"
Severity: Minor
Found in app/controllers/cats_controller.rb by rubocop

Checks if uses of quotes match the configured preference.

Example: EnforcedStyle: single_quotes (default)

# bad
"No special symbols"
"No string interpolation"
"Just text"

# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"

Example: EnforcedStyle: double_quotes

# bad
'Just some text'
'No special chars or interpolation'

# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"

Line is too long. [98/80]
Open

                                :sterilized, :abandoned_date, :document, :colony_id, :saved_state,
Severity: Minor
Found in app/controllers/cats_controller.rb by rubocop

There are no issues that match your filters.

Category
Status