次㮠RuboCop (> 0.59) ã®ãªãªã¼ã¹ã§ãRuboCop 1.0 ã«åãã --safe
ãªãã·ã§ã³ã¨ --safe-auto-correct
ãªãã·ã§ã³ãå°å
¥ãããã
% rubocop --help | grep safe --safe Run only safe cops. --safe-auto-correct Run auto-correct only when it's safe.
ããã㯠RuboCop 1.0 ã«åãããªãã·ã§ã³ã§ãããç¾ç¶ã¯ä»¥ä¸ã®ãããªæ¯ãèããããã
--safe
ãªãã·ã§ã³
rubocop --safe
ã¨ãªãã·ã§ã³ä»ãã§å®è¡ããã¨ä»¥ä¸ã®ããã« RuboCop ã® config/default.yml ãªãã¢ããªã±ã¼ã·ã§ã³ã® .rubocop.yml ãªãã㧠Safe: false
ã¨ãªã Cop ã¯é©ç¨å¯¾è±¡å¤ã¨ãªã (å³å¯ã«ãã㨠Enable ã true ã㤠Safe ã true ã® Cop ã対象ã«ãªã) ã
Performance/InefficientHashSearch:
Description: 'Use `key?` or `value?` instead of `keys.include?` or `values.include?`'
Reference: 'https://github.com/JuanitoFatas/fast-ruby#hashkey-instead-of-hashkeysinclude-code'
Enabled: true
VersionAdded: 0.56
+ Safe: false
YAML ã« Safe: false
ã®æå®ããªããã°ããã©ã«ã㧠Safe: true
ã¨ãã¦æ±ãããã
ãªãã--safe
ãªãã·ã§ã³ãªãã§ã® rubocop
ã³ãã³ãå®è¡ã¯ããã¾ã§ã©ããåºæ¬çã« Enable :false
ã§ãªããã®ã対象ã
ç¾ç¶ã§å½é½æ§ãåé¿ãã¥ããã±ã¼ã¹ãããå ´åã« Safe: false
ã¨ãªã£ã¦ããããã§ãããã¾ã§ Enabled: false
ã 㨠Cop ãæã¤ã¹ã¿ã¤ã«ã¸ã®é³æ¥½æ§ã®éããç¡å¹ã«ãããã®ãã Cop ã®ä¸å
·åãåé¿ãããã®ãªã®ããããããé¿ãã¥ããå½é½æ§ãåé¿ãããã®ãä¸æçãªã©æ··å¨ããæ ¹æ ãåé¡ãããå½¢ã«ãªã£ããããã¨æã (ãªãæ°ã㪠Cop ã¯ä¸å
·åãæã£ã¦ããå¯è½æ§ãèæ
®ãã¦ç¡å¹ã«ãããã¨ããæå³ã®ã¡ã¿ãã¼ã¿ã¯ rubocop-hq/rubocop#5979 ã§æ¤è¨ããã¦ããã¨ãã) ã
--safe-auto-correct
ãªãã·ã§ã³
rubocop --safe-auto-correct
ã¨ãªãã·ã§ã³ä»ãã§å®è¡ããã¨ä»¥ä¸ã®ãã㪠SafeAutoCorrect: false
ã¨ãªã£ã¦ãã Cop ã対象å¤ã« auto-correct ããã
Style/InfiniteLoop:
Description: 'Use Kernel#loop for infinite loops.'
StyleGuide: '#infinite-loop'
Enabled: true
VersionAdded: 0.26
+ SafeAutoCorrect: false
YAML ã« SafeAutoCorrect: false
ã®æå®ããªããã°ããã©ã«ã㧠SafeAutoCorrect: true
ã¨ãã¦æ±ãããã
ãªãã--safe-auto-correct
ãªãã·ã§ã³ã¯ --auto-correct
ãªãã·ã§ã³ã®ããå®å
¨ãªãªãã·ã§ã³ã¨ãããã¨ã§ãAutoCorrect: false
ã¯ãããã auto-correct 対象å¤ã¨ãªã£ã¦ããããã§ãAutoCorrect: false
ã®æå®ããªã (ããã©ã«ã㧠AutoCorrect: true
æ±ã) å ´åã§ã SafeAutoCorrect: false
ã®ãã®ã¯å®å
¨ã¨ã¿ãªããªãã¨ãã£ããªãã·ã§ã³ã¨ãªãã
ç¾ç¶ã 㨠RuboCop ã® config/default.yml 㧠AutoCorrect: false
ã® Cop ã«å ãã¦ãSecurity/YAMLLoad
cop 㨠Style/InfiniteLoop
cop ãªãã³ã« Style/SpecialGlobalVars
cop ã¨ãã£ããauto-correct ã§ç ´å£çå¤æ´ããã¦ãã¾ãã¬ãã¼ããæãããã¦ããåé¿ãé£ããã㪠Cop ã対象ã«ãªã£ã¦ãããããã
ãããã®ãªãã·ã§ã³è¿½å ã«é¢ãã PR ã¯ä»¥ä¸ãªã®ã§ãå®è£ ã«èå³ãããã°ãã¡ããèªã¾ãããã
ã¾ã config/default.yml ã«ã¯ãCop ãå°å ¥ããããã¼ã¸ã§ã³ãå¤æ´ããããã¼ã¸ã§ã³ãåé¤ããããã¼ã¸ã§ã³ã¨ãã£ãã¡ã¿ãã¼ã¿ãåãè¾¼ã¾ãã¦ããããããããããæ¯ãèãã«é¢ä¸ãã¦ãããã¨ã«ãªãã¨æãããã®ãããã®ã¡ã³ããã³ã¹ã«ã¤ãã¦ä¸æçãªç¹ãããã®ã§ããã¨ã§éçºè åãã«ãæããã«ãã¦ããããã¨æãã