standard icon indicating copy to clipboard operation
standard copied to clipboard

Layout/EndOfLine: EnforcedStyle: lf does not seem to work

Open Youdaman opened this issue 2 years ago • 0 comments

I'm on Windows and I want to override the EnforcedStyle from "native" to "lf", so here's my .standard.yml

plugins:
  - standard-rails

ignore:
  - 'db/migrate/20240401101848_create_delayed_jobs.rb':
    - Layout/ExtraSpacing
    - Rails/ReversibleMigrationMethodDefinition
  # - '**/*':
  #   - Layout/EndOfLine

Layout/EndOfLine:
  EnforcedStyle: lf

When I run standardrb I still errors for the various .rb files in the project complaining:

standard: Use Ruby Standard Style (https://github.com/standardrb/standard)
  Gemfile:1:1: Layout/EndOfLine: Carriage return character missing.
  Rakefile:1:1: Layout/EndOfLine: Carriage return character missing.
  app/channels/application_cable/channel.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  app/channels/application_cable/connection.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  app/controllers/application_controller.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  app/helpers/application_helper.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  app/jobs/application_job.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  app/mailers/application_mailer.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  app/models/application_record.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  app/models/user.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  config.ru:1:1: Layout/EndOfLine: Carriage return character missing.
  config/application.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  config/boot.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  config/environment.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  config/environments/development.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  config/environments/production.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  config/environments/test.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  config/importmap.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  config/initializers/assets.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  config/initializers/content_security_policy.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  config/initializers/filter_parameter_logging.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  config/initializers/inflections.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  config/initializers/pay.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  config/initializers/permissions_policy.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  config/initializers/revise_auth.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  config/puma.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  config/routes.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  db/migrate/20240401030014_create_pay_tables.pay.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  db/migrate/20240401060824_create_users.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  db/migrate/20240401075402_add_name_to_user.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  db/migrate/20240401101848_create_delayed_jobs.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  db/seeds.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  test/application_system_test_case.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  test/channels/application_cable/connection_test.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  test/models/user_test.rb:1:1: Layout/EndOfLine: Carriage return character missing.
  test/test_helper.rb:1:1: Layout/EndOfLine: Carriage return character missing.

If I uncomment that ignore rule things work fine:

   - '**/*':
    - Layout/EndOfLine

But I feel this is a hack and doesn't actually enforce all files to end with LF. I've confirmed the offending files don't contain carriage returns by using the od command, e.g. od -a test/test_helper.rb | grep cr (which returns nothing, i.e. no match) -- and the status bar in VS Code also says "LF" for these files.

Am I doing something wrong with where I have the Layout/EndOfLine in my config? Should it be nested under something?

I'm calling standardrb without having it in my Gemfile because it's installed globally, but that shouldn't make a difference right?

I found a related issue to do with rubocop here but the solution there to ignore the cache doesn't seem to apply to standardrb https://github.com/rubocop/rubocop/issues/4669 -- unless there is some caching issue? If so how do I empty/ignore the cache?

Youdaman avatar Apr 02 '24 02:04 Youdaman