Skip to content
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

False positives for inclusive language #9957

Closed
epologee opened this issue Jul 29, 2021 · 0 comments · Fixed by #9965
Closed

False positives for inclusive language #9957

epologee opened this issue Jul 29, 2021 · 0 comments · Fixed by #9965
Labels

Comments

@epologee
Copy link

epologee commented Jul 29, 2021

RuboCop::Cop::Naming::InclusiveLanguage flags symbols that happen to contain the string "slave" as offences, even when they are contained in composited words. For example "SLAVersion" or "TeslaVehicle" are seen as offences, but "sla_version" or "tesla_vehicle" are not. I think these 'false positives' point to a bug.


Expected behavior

The inclusive language cop should mark "slave", "Slave" and "SLAVE" as offences, but not "SLAVe" or "slaVe" or other casings that are the result of compositing words. I would expect the casing of characters to have an influence on the determination of an offence.

Actual behavior

Symbols containing "SLAVe" or "slaVe" are marked as offences by the inclusive language cop, with the following output:

rubocop -A --debug /Users/xxxx/app/models/concerns/xxxx.rb
For /Users/xxxx: configuration from /Users/xxxx/.rubocop.yml
configuration from /Users/xxxx/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-rails-2.11.3/config/default.yml
configuration from /Users/xxxx/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-rails-2.11.3/config/default.yml
Default configuration from /Users/xxxx/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/rubocop-1.18.4/config/default.yml
Inheriting configuration from /Users/xxxx/.rubocop_todo.yml
.rubocop.yml: Lint/UselessAssignment:Exclude overrides the same parameter in .rubocop_todo.yml
.rubocop.yml: Metrics/CyclomaticComplexity:Max overrides the same parameter in .rubocop_todo.yml
.rubocop.yml: Metrics/PerceivedComplexity:Max overrides the same parameter in .rubocop_todo.yml
Inspecting 1 file
Scanning /Users/xxxx/app/models/concerns/xxxx.rb
Loading cache from /Users/xxxx/.cache/rubocop_cache/f5e32fae37ef606b02bd1b4d287d15320b11827e/32a823ae5c5ceea585bb78727fd983b60ae7a358/7d463336a8c621971967fd1aa6370fda630363bf
C

Offenses:

app/models/concerns/xxxx.rb:52:10: C: Naming/InclusiveLanguage: Consider replacing problematic term 'slaVe' with 'replica', 'secondary', or 'follower'.
class VizslaVet; end
         ^^^^^
app/models/concerns/xxxx.rb:54:9: C: Naming/InclusiveLanguage: Consider replacing problematic term 'slaVe' with 'replica', 'secondary', or 'follower'.
class TeslaVehicle; end
        ^^^^^
app/models/concerns/xxxx.rb:56:7: C: Naming/InclusiveLanguage: Consider replacing problematic term 'SLAVe' with 'replica', 'secondary', or 'follower'.
class SLAVersion; end
      ^^^^^

1 file inspected, 3 offenses detected
Finished in 0.8737279999913881 seconds

Process finished with exit code 1

Steps to reproduce the problem

Put any one of these classes in a file inspected by rubocop with the inclusive language cop enabled:

  • class SLAVersion; end
  • class TeslaVehicle; end
  • class VizslaVet; end

RuboCop version

$ [bundle exec] rubocop -V -A /Users/****.rb
1.18.4 (using Parser 3.0.2.0, rubocop-ast 1.8.0, running on ruby 2.7.3 arm64-darwin20)
  - rubocop-rails 2.11.3

Process finished with exit code 0
@koic koic added the bug label Jul 29, 2021
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Jul 30, 2021
bbatsov pushed a commit that referenced this issue Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants