-
-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: RSpec/ContextWording supports Japanese #745
Comments
I remember we decided to The logic of composition of WDYT of failing the cop when both |
I think the point about composing The other issue in composition is you need to be able to make any/all prefixes valid options. If, in japanese or another language, you only care about the suffix, then you can't whitelist all prefixes using the existing configuration since it could be any character / word. Re: Splitting, another option that might be worth considering is specifying a delimiter ( Regex might be overkill, but it seems like it might be simpler than the Suffixes/Prefixes/Split combinations. |
Problem
RSpec/ContextWording does not work well to check Japanese.
It has two problems.
First, usually we use a suffix to specify "when". For example,
when a user exists
is translated toユーザーが存在する時
.時
meanswhen
.But the cop only supports prefix, so we cannot configure it for Japanese.
Second, Japanese does not separate words with space. For example,
ユーザー が 存在する 時
is not appropriate as Japanese.But the cop split the sentence with space.
https://github.com/rubocop-hq/rubocop-rspec/blob/0442757fb4af570994b37b3e0ca35baeec635eb0/lib/rubocop/cop/rspec/context_wording.rb#L45
So If the cop supports suffix, it does not enough.
Solution Ideas
I have two ides.
First, adding
Suffixes
andSplit
options to the cop.For example:
The cop splits context sentence only if
Split
option is enabled. If it is disabled, the cop just checks withstart_with
orend_wtih
method.Second, adding
Patterns
option to the cop.For example
I like the first idea. The second idea is more powerful, but I think we do not need regexp in most cases.
The original idea is issued in rubocop-hq/rubocop-jp by @kyohah. rubocop/rubocop-jp#49
Thank you!
The text was updated successfully, but these errors were encountered: