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

Handle Slim Safety

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for ydah ydah
September 09, 2023

Handle Slim Safety

大阪Ruby会議03 LT 「Handle Slim Safety」のスライド
https://regional.rubykaigi.org/osaka03/ #osrb03

Avatar for ydah

ydah

September 09, 2023
Tweet

More Decks by ydah

Other Decks in Technology

Transcript

  1. ɾName: Yudai Takada ɾGitHub: @ydah ɾX: @ydah_ ɾMember of RuboCop

    RSpec team ɾSoftware Engineer at ANDPAD, Inc. self.inspect
  2. doctype html html head title My Slim Template body ruby:

    message = "Slim!" h1 Welcome to #{ message} p This is a simple example. ͜͏͍͏΍ͭ
  3. doctype html html head title My Slim Template body ruby:

    message = "Slim!" h1 Welcome to #{ message} p This is a simple example. ࠓ೔ͷλʔήοτ ˡ͜͜
  4. ຒΊࠐΈ಺ͷίϝϯτ doctype html html head title My Slim Template body

    h1 Welcome to Slim! javascript: // comment alert("Hello, World!");
  5. ίϯύΠϧޙ <!DOCTYPE html> <html> <head> <title>My Slim Template </ title>

    < / head> : </ html> <script> / / mecha kimitsu joho alert("Hello, World!"); </ script> ݟΒΕͨ͘ͳ͍ίϝϯτ΋ ݟΒΕͯ͠·͏
  6. slim-embedded-minify module Slim class Embedded < Filter class TagEngine <

    Engine prepend Minify::Tag end class JavaScriptEngine < TagEngine prepend Minify::Javascript end ennd
  7. slim-embedded-minify module Slim class Embedded < Filter module Minify module

    Javascript include Tag def on_slim_embedded(engine, body, attrs) mini fi ed_body = minify(body) super(engine, mini fi ed_body, attrs) end ennnnd
  8. 3VCP$PQͰ͸ղੳෆՄ 4MJN͸3VCZͰ͸ͳ͍ͷͰɺ 4ZOUBY&SSPSʹͳΔ ͦΕ͸ͦ͏ spec/f i xtures/dummy.slim:1 : 5 :

    F : Lint/ Syntax: unexpected token tCOLON (Using Ruby 2.7 parser; conf i gure using TargetRubyVersion parameter, under AllCops) ruby: ^
  9. slimembedcop html ruby: if File.exists?("foo.txt") message = "Yay!" else message

    = "Nooo!" end h1 #{ message} ੾Γग़ͯ͠3VCP$PQʹ౉ͯ͠ ղੳͯ͠΋Β͏
  10. slimembedcop ❯ slimembedcop dummy.slim Inspecting 1 f i le W

    Offenses: dummy.slim:3 : 8 : W : [Correctable] Lint/ DeprecatedClassMethods: File.exists? is deprecated in favor of File.exist ?. if File.exists?("foo.txt") ^^^^^^^^^^^^
  11. end