Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

525
Vistas
Rubocop, how to Disable/Enable cops on blocks of code

I will like to disable a cop for a specific block or method.

I know it is possible to disable a cop for the whole project using .rubocop.yml but I just want to deactivate the cop temporarily for a specific portion of the code

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

I answer my question because it is always very difficult for me to find the reference to this solution:

# rubocop:disable Metrics/MethodLength
def my_code
  ..
end
# rubocop:enable Metrics/MethodLength

Same for multiple cops:

# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
def my_code
  ..
end
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength

Documentation: https://docs.rubocop.org/rubocop/configuration.html#disabling-cops-within-source-code

over 4 years ago · Santiago Trujillo Denunciar

0

If you want to disable the cop for a particular line, you can just use something like this

 before_action :authenticate_user!, except: [:index, :show] # rubocop:disable Style/SymbolArray

No need to enable it again. If there is a block of code and you want to enable or disable the cop, then as suggested above, you can follow that approach.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda