Skip to content

Rails/EnumSyntax not working for files placed in lib folder #1474

@Splines

Description

@Splines

The cop Rails/EnumSyntax works for a file placed in the app/ folder, but not for one in the lib/ folder.

Expected behavior

Given this configuration

# .rubocop.yml
plugins:
  - rubocop-rails

Rails/EnumSyntax:
  Enabled: true
  Severity: error

I expect that the following code yields an offense

# lib/enum_lib.rb
class EnumerableInLib # rubocop:disable Style/Documentation,Style/FrozenStringLiteralComment
  enum status: { active: 0, archived: 1 }
end

The auto-corrected code should read:

# lib/enum_lib.rb
class EnumerableInLib # rubocop:disable Style/Documentation,Style/FrozenStringLiteralComment
  enum :status, { active: 0, archived: 1 }
end

Actual behavior

If the Ruby file is placed inside the app/ folder, the violation is detected, however not if placed in the lib/ folder.

Steps to reproduce the problem

See my reproduction and its Readme.

RuboCop version

1.75.4 (using Parser 3.3.8.0, Prism 1.4.0, rubocop-ast 1.44.1, analyzing as Ruby 3.3, running on ruby 3.3.8) [x86_64-linux]
  - rubocop-rails 2.31.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions