rubocop-rspec icon indicating copy to clipboard operation
rubocop-rspec copied to clipboard

Cop Idea: Only xstr in description

Open ydah opened this issue 1 year ago • 4 comments

If only xstr is passed to describe, context or it, the typo of " or ' is suspect in many cases. Also, if only xstr is, it may not be a good description of describe or context or it. What do you think?

# bad
describe `time` do
end

# bad
context `time` do
end

# bad
it `time` do
end

ydah avatar Dec 21 '23 06:12 ydah

Is this an issue from the real code? Why would anyone want to use that?

pirj avatar Dec 21 '23 06:12 pirj

Is this an issue from the real code? Why would anyone want to use that?

Yes, it is. Strictly speaking I saw the it case I encountered. The case of describe and context may not exist in the real world, but it would be nice to have, I think.

ydah avatar Dec 21 '23 11:12 ydah

If those are typos, surely let’s add a cop to fix those

pirj avatar Dec 21 '23 11:12 pirj

I guess someone who uses JavaScript template literals a lot wrote it by mistake. I've encountered this misuse too, but since this project was a Rails app, where Kernel#` is not used very often, I decided to enforce the %x literal.

Style/CommandLiteral:
  EnforcedStyle: percent_x

r7kamura avatar Dec 22 '23 00:12 r7kamura