developer tip

RuboCop : 줄이 너무 깁니다. <— 무시하는 방법

optionbox 2020. 10. 26. 07:55
반응형

RuboCop : 줄이 너무 깁니다. <— 무시하는 방법


방금 RuboCop을 rails 프로젝트에 추가하고 Sublime 패키지를 설치하여 편집기에서 RuboCop 제안을 확인했습니다. 최대 줄 길이를 80 자에서 변경하는 방법을 알아 내거나 규칙을 완전히 무시하는 중입니다.

현재 사용 중 :


코드에서 다음과 같이 여러 줄을 비활성화 할 수 있습니다.

# rubocop:disable LineLength
puts "This line is lonnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnng"
# rubocop:enable LineLength

또는 다음을 .rubocop.yml파일에 추가하여 최대 길이를 늘리십시오.

Metrics/LineLength:
  Max: 100

프로젝트의 루트에 .rubocop.yml파일을 만들면 (파일 .이름 의 이니셜 을 확인하십시오) 다음과 같은 여러 옵션이 있습니다.

Metrics/LineLength:
  # This will disable the rule completely, regardless what other options you put
  Enabled: false
  # Change the default 80 chars limit value
  Max: 120
  # If you want the rule only apply to a specific folder/file
  Include:
    - 'app/**/*'
  # If you want the rule not to apply to a specific folder/file
  Exclude:
    - 'db/schema.rb'

참고 URL : https://stackoverflow.com/questions/37228624/rubocop-line-is-too-long-how-to-ignore

반응형