lundi 10 août 2020

Style/ConditionalAssignment: Use the return of the conditional for variable assignment and comparison

Below is my Ruby on Rails code -

inactive_list = [1,2,3,4,5]
raw_data = []

data = {
  name: "Test",
  full_name: "Test data"
}
if inactive_list.include? <<id of data>>
  data[:active] = false
else
  data[:active] = true
end

raw_data << data

I am getting Rubocop linting error for if...else statement. I tried making several changes but unable to fix linting Rubocop error.

C: Style/ConditionalAssignment: Use the return of the conditional for variable assignment and comparison.

Please help! Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire