Questions tagged [rubocop]

RuboCop is a Ruby static code analyzer. Out of the box it will enforce many of the guidelines outlined in the community Ruby Style Guide.

RuboCop is a Ruby static code analyzer. Out of the box it will enforce many of the guidelines outlined in the community Ruby Style Guide.

Apart from reporting problems in your code, RuboCop can also automatically fix some of the problems for you.

More info on GitHub.

453 questions
-2
votes
1 answer

How to solve Duplicated key in hash literal

I have an action like @documents = Document.all.includes(:user, user: :skills, user: :profession) When I run rubocop on my controller, I get this result: controllers/documents_controller.rb:4:75: W: Lint/DuplicatedKey: Duplicated key in hash…
Jasjeet Singh
  • 332
  • 1
  • 6
  • 18
-2
votes
2 answers

why if condition is not working

I am testing small code below params[:code] = if false 'N' else 'Y' end it returns N for if param[:code] passed as…
User7354632781
  • 2,174
  • 9
  • 31
  • 54
-3
votes
1 answer

Lint error "Literal '+' appeared as a condition" when using ternary if

I have some code. It should remove a trailing + from a string if present: def remove_prefix(number) number.start_with? '+' ? number[1..-1] : number end But it doesn't work as expected – it just returns false: remove_prefix('123') #=>…
Sergey Blohin
  • 600
  • 1
  • 4
  • 31
1 2 3
30
31