Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Mastering config/default.yml for RuboCop

Mastering config/default.yml for RuboCop

銀座Rails#9

Koichi ITO

May 30, 2019
Tweet

More Decks by Koichi ITO

Other Decks in Programming

Transcript

  1. -BZPVU%FQBSUNFOU "MJHO"SSBZ ܯ࡯ॺͷϝλϑΝʔ "MJHO)BTI &MTF"MJHONFOU &NQUZ-JOFT &OE"MJHONFOU &YUSB4QBDJOH *OEFOU"SSBZ -JOU%FQBSUNFOU

    %VQMJDBUF.FUIPET %VQMJDBUFE,FZ &MTF"MJHONFOU 4DSJQU1FSNJTTJPO 6OJpFE*OUFHFS 6OSFBDIBCMF$PEF 6OMFTT"TTJHONFOU .FUSJDT%FQBSUNFOU "CD4J[F #MPDL-FOHUI #MPDL/FTUJOH $MBTT-FOHUI -JOF-FOHUI .FUIPE-FOHUI 1BSBNFUFS-JTUT ʜ
  2. SVCPDPQBVUPDPSSFDU % rubocop -a # -a is a alias for

    --auto-correct Inspecting 1 file C Offenses: example.rb:1:1: C: [Corrected] Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true. def badName ^ example.rb:2:3: C: [Corrected] Style/IfUnlessModifier: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||. if something ^^ example.rb:3:5: C: Naming/MethodName: Use snake_case for method names. def badName ^^^^^^^ 1 file inspected, 3 offenses detected, 2 offenses corrected
  3. HJUEJ⒎ % git diff diff --git a/example.rb b/example.rb index 82446de..f57e73e

    100644 --- a/example.rb +++ b/example.rb @@ -1,5 +1,5 @@ +# frozen_string_literal: true + def badName - if something - test - end + test if something end