SlideShare a Scribd company logo
1 of 22
Download to read offline
prettier-ruby? 

ruby formatters overview
"Good programmers" are those 

who aleady have learned a set of rules that
ensures good style; (…)

The Elements of Programming Style 1974
Piotr Wasiak
Ruby programming style history
At the beginning there was chaos
We got some ruby styling guides
CodeReview focused sometimes more on style than the
logic
We got linters (PR services, overcommit, text-editor plugins)
Should we now follow e.g. JS world 

with using automatic formatters?

Code formatter
It enforces a consistent style 

by parsing your code and 

re-printing it with its own rules
✴ Rubocop
✴ Rufo
✴ Prettifier
✴ Rubyfmt
RIP
✤ Ruby Script Beautifier (2008)
✤ eden (2011)
✤ ruby-beautify2 (fork: 01. 2018)
Formatters ruby
Parsers
Ripper to STD LIB - written in C so
faster



ruby-parse to CLI do gem parser:

production-ready written in pure
Ruby. It recognises as much or more
code than Ripper, Melbourne,
JRubyParser or ruby_parser, and is
Rubocop
heavy, but very good advanced configuration
parameters to use as formatter:

-a --auto-correct Auto-correct offenses.
--safe-auto-correct Run auto-correct only when it's safe.
-x, --fix-layout
Run only layout cops, with auto-correct on.
(currently 81 cops)
--only-guide-cops
Run only cops for rules that link to a style
guide.
--only [COP1,COP2,...] Run only the given cop(s).
Ruby test
by rubocop
RuFo
Not a simple find and replace one, very fast
Was implemented in a similar fashion to Crystal's
formatter.



Started 2 years ago, but currently is getting less
updates / issues than prettier



There are some problems with chained heredocs, (…)



config options: trailing_commas, parens_in_def
Ruby test
by Rufo
“uglifier” part
Rufo is fast
Less strict than prettier, but it seems that it formats less
Rubyfmt
Fast, integrated with shell (no ruby gem)


Project development started 5 months ago


no config options. 



No max chars/line, removes additional enters



Broke on some files (also especially @ rspec specs)
Fast per file - 175 ms

many files at once is not a case
Ruby test
by Rubyfmt



Rubyfmt problems
user_context&.role&.in? %w(Admin Company)
AddActivityService.new(candidate: candidate, **keywords).call
expect(email.body).to match 'His/her search can be shown'
Prettier-ruby
Fast and opinionated in many languages as plugin to
text editors
Ruby plugin development started 7 months ago


config options:

printWidth, tabWidth, addTrailingCommas,
inlineConditionals, inlineLoops, preferHashLabels,
preferSingleQuotes
Fast per file - 170 ms

many files at once is not a case
Ruby test
by Prettier



*designed by them : )
“uglifier” part
Prettier problems
Speed
command User time
System
time
Total time
rufo ruby.rb 0.14s 0.05s 0.202s
./node_modules/.bin/
prettier
0.38s 0.08s 0.462s
Rubocop -a 1.09s 0.25s 1.349s
command User time
System
time
Total time
rufo **/*.rb 1.16s 0.20s 1.379s
Rubocop -a 3.18s 0.41s 3.635s
Rubocop -a 

—cache false
14.34s 0.64s 15.174s
./node_modules/.bin/
prettier
36.23s 13.51s 51.606s
Format rails api project LOC: 2644 Format 1 file (ruby test)
Rubyfmt - total time 30.s with some
errors during parsing
Formatter triggers
✓ On file save
✓ On code paste
✓ On demand
Sum up: How to live?
Use still linter
Chillout with code style wars
Try prettier formatter on demand/paste 

and report issues on GitHub
Thanks for listening

More Related Content

What's hot

Ruby and Rails short motivation
Ruby and Rails short motivationRuby and Rails short motivation
Ruby and Rails short motivationjistr
 
If programming languages were hot babes
If programming languages were hot babesIf programming languages were hot babes
If programming languages were hot babesGreg Moreno
 
Extending Ruby using C++
Extending Ruby using C++Extending Ruby using C++
Extending Ruby using C++Tristan Penman
 
Metaprogramming in Ruby
Metaprogramming in RubyMetaprogramming in Ruby
Metaprogramming in Rubyjonromero
 
Ruby Introduction
Ruby IntroductionRuby Introduction
Ruby IntroductionPrabu D
 
Ola Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The JvmOla Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The Jvmdeimos
 
Lets get started by Leif Gensert
Lets get started by Leif GensertLets get started by Leif Gensert
Lets get started by Leif GensertRails Girls MUC
 
Ruby an overall approach
Ruby an overall approachRuby an overall approach
Ruby an overall approachFelipe Schmitt
 
Using Aspects for Language Portability (SCAM 2010)
Using Aspects for Language Portability (SCAM 2010)Using Aspects for Language Portability (SCAM 2010)
Using Aspects for Language Portability (SCAM 2010)lennartkats
 
The Spoofax Language Workbench (SPLASH 2010)
The Spoofax Language Workbench (SPLASH 2010)The Spoofax Language Workbench (SPLASH 2010)
The Spoofax Language Workbench (SPLASH 2010)lennartkats
 
Jug dynamic languages_in_jvm
Jug dynamic languages_in_jvmJug dynamic languages_in_jvm
Jug dynamic languages_in_jvmDmitry Buzdin
 
Ruby On Rails Overview
Ruby On Rails OverviewRuby On Rails Overview
Ruby On Rails Overviewjonkinney
 
Language Engineering in the Cloud
Language Engineering in the CloudLanguage Engineering in the Cloud
Language Engineering in the Cloudlennartkats
 
Wed Development on Rails
Wed Development on RailsWed Development on Rails
Wed Development on RailsJames Gray
 
Building scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thriftBuilding scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thriftTalentica Software
 
Coffee scripts with rails
Coffee scripts with railsCoffee scripts with rails
Coffee scripts with railsDevilal Dheer
 
IronRuby: Ruby on the .NET Platform
IronRuby: Ruby on the .NET PlatformIronRuby: Ruby on the .NET Platform
IronRuby: Ruby on the .NET PlatformAndre John Cruz
 

What's hot (19)

Ruby and Rails short motivation
Ruby and Rails short motivationRuby and Rails short motivation
Ruby and Rails short motivation
 
If programming languages were hot babes
If programming languages were hot babesIf programming languages were hot babes
If programming languages were hot babes
 
Extending Ruby using C++
Extending Ruby using C++Extending Ruby using C++
Extending Ruby using C++
 
Metaprogramming in Ruby
Metaprogramming in RubyMetaprogramming in Ruby
Metaprogramming in Ruby
 
Ruby Introduction
Ruby IntroductionRuby Introduction
Ruby Introduction
 
Ola Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The JvmOla Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The Jvm
 
Lets get started by Leif Gensert
Lets get started by Leif GensertLets get started by Leif Gensert
Lets get started by Leif Gensert
 
Intro dotnet
Intro dotnetIntro dotnet
Intro dotnet
 
Ruby an overall approach
Ruby an overall approachRuby an overall approach
Ruby an overall approach
 
FunScript: Why bother?
FunScript: Why bother?FunScript: Why bother?
FunScript: Why bother?
 
Using Aspects for Language Portability (SCAM 2010)
Using Aspects for Language Portability (SCAM 2010)Using Aspects for Language Portability (SCAM 2010)
Using Aspects for Language Portability (SCAM 2010)
 
The Spoofax Language Workbench (SPLASH 2010)
The Spoofax Language Workbench (SPLASH 2010)The Spoofax Language Workbench (SPLASH 2010)
The Spoofax Language Workbench (SPLASH 2010)
 
Jug dynamic languages_in_jvm
Jug dynamic languages_in_jvmJug dynamic languages_in_jvm
Jug dynamic languages_in_jvm
 
Ruby On Rails Overview
Ruby On Rails OverviewRuby On Rails Overview
Ruby On Rails Overview
 
Language Engineering in the Cloud
Language Engineering in the CloudLanguage Engineering in the Cloud
Language Engineering in the Cloud
 
Wed Development on Rails
Wed Development on RailsWed Development on Rails
Wed Development on Rails
 
Building scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thriftBuilding scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thrift
 
Coffee scripts with rails
Coffee scripts with railsCoffee scripts with rails
Coffee scripts with rails
 
IronRuby: Ruby on the .NET Platform
IronRuby: Ruby on the .NET PlatformIronRuby: Ruby on the .NET Platform
IronRuby: Ruby on the .NET Platform
 

Similar to Ruby formatters

Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLBarry Jones
 
IDE, Terminal and SCM to work with Ruby on Rails
IDE, Terminal and SCM to  work with Ruby on RailsIDE, Terminal and SCM to  work with Ruby on Rails
IDE, Terminal and SCM to work with Ruby on RailsHenry Le
 
Rails Vs CakePHP
Rails Vs CakePHPRails Vs CakePHP
Rails Vs CakePHPGautam Rege
 
Highly Surmountable Challenges in Ruby+OMR JIT Compilation
Highly Surmountable Challenges in Ruby+OMR JIT CompilationHighly Surmountable Challenges in Ruby+OMR JIT Compilation
Highly Surmountable Challenges in Ruby+OMR JIT CompilationMatthew Gaudet
 
Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Henry S
 
Ruby on Rails : First Mile
Ruby on Rails : First MileRuby on Rails : First Mile
Ruby on Rails : First MileGourab Mitra
 
Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)Muhammad Haseeb Shahid
 
The story of language development
The story of language developmentThe story of language development
The story of language developmentHiroshi SHIBATA
 
Instruments ruby on rails
Instruments ruby on railsInstruments ruby on rails
Instruments ruby on railspmashchak
 
Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex Espen Brækken
 
Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Charles Nutter
 
Intro to Crystal Programming Language
Intro to Crystal Programming LanguageIntro to Crystal Programming Language
Intro to Crystal Programming LanguageAdler Hsieh
 

Similar to Ruby formatters (20)

Ruby formatters 2019
Ruby formatters 2019Ruby formatters 2019
Ruby formatters 2019
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
 
IDE, Terminal and SCM to work with Ruby on Rails
IDE, Terminal and SCM to  work with Ruby on RailsIDE, Terminal and SCM to  work with Ruby on Rails
IDE, Terminal and SCM to work with Ruby on Rails
 
Rails Vs CakePHP
Rails Vs CakePHPRails Vs CakePHP
Rails Vs CakePHP
 
How DSL works on Ruby
How DSL works on RubyHow DSL works on Ruby
How DSL works on Ruby
 
Highly Surmountable Challenges in Ruby+OMR JIT Compilation
Highly Surmountable Challenges in Ruby+OMR JIT CompilationHighly Surmountable Challenges in Ruby+OMR JIT Compilation
Highly Surmountable Challenges in Ruby+OMR JIT Compilation
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Ruby on Rails 3 Day BC
Ruby on Rails 3 Day BCRuby on Rails 3 Day BC
Ruby on Rails 3 Day BC
 
Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1
 
Ruby on Rails : First Mile
Ruby on Rails : First MileRuby on Rails : First Mile
Ruby on Rails : First Mile
 
Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)Page List & Sample Material (Repaired)
Page List & Sample Material (Repaired)
 
Ruby and Security
Ruby and SecurityRuby and Security
Ruby and Security
 
Cucumber
CucumberCucumber
Cucumber
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
ruby pentest
ruby pentestruby pentest
ruby pentest
 
The story of language development
The story of language developmentThe story of language development
The story of language development
 
Instruments ruby on rails
Instruments ruby on railsInstruments ruby on rails
Instruments ruby on rails
 
Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex Ruby on Rails (RoR) as a back-end processor for Apex
Ruby on Rails (RoR) as a back-end processor for Apex
 
Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016Ruby Performance - The Last Mile - RubyConf India 2016
Ruby Performance - The Last Mile - RubyConf India 2016
 
Intro to Crystal Programming Language
Intro to Crystal Programming LanguageIntro to Crystal Programming Language
Intro to Crystal Programming Language
 

More from Visuality

3 issues that made 30 test workers take 40 minutes
3 issues that made 30 test workers take 40 minutes3 issues that made 30 test workers take 40 minutes
3 issues that made 30 test workers take 40 minutesVisuality
 
Czego nie robić przy pisaniu testów
Czego nie robić przy pisaniu testówCzego nie robić przy pisaniu testów
Czego nie robić przy pisaniu testówVisuality
 
Introduction to Domain-Driven Design in Ruby on Rails
Introduction to Domain-Driven Design in Ruby on RailsIntroduction to Domain-Driven Design in Ruby on Rails
Introduction to Domain-Driven Design in Ruby on RailsVisuality
 
Active Record .includes - do you use it consciously?
Active Record .includes - do you use it consciously?Active Record .includes - do you use it consciously?
Active Record .includes - do you use it consciously?Visuality
 
Introduction to Event Storming
Introduction to Event StormingIntroduction to Event Storming
Introduction to Event StormingVisuality
 
Jak programowanie może pomóc na co dzień?
Jak programowanie może pomóc na co dzień?Jak programowanie może pomóc na co dzień?
Jak programowanie może pomóc na co dzień?Visuality
 
SVG Overview - How To Draw, Use and Animate
SVG Overview - How To Draw, Use and AnimateSVG Overview - How To Draw, Use and Animate
SVG Overview - How To Draw, Use and AnimateVisuality
 
How To Migrate a Rails App From a Dedicated Server Into Cloud Environment? - ...
How To Migrate a Rails App From a Dedicated Server Into Cloud Environment? - ...How To Migrate a Rails App From a Dedicated Server Into Cloud Environment? - ...
How To Migrate a Rails App From a Dedicated Server Into Cloud Environment? - ...Visuality
 
How to use AWS SES with Lambda 
in Ruby on Rails application - Michał Łęcicki
How to use AWS SES with Lambda 
in Ruby on Rails application - Michał ŁęcickiHow to use AWS SES with Lambda 
in Ruby on Rails application - Michał Łęcicki
How to use AWS SES with Lambda 
in Ruby on Rails application - Michał ŁęcickiVisuality
 
What is NOT machine learning - Burak Aybar
What is NOT machine learning - Burak AybarWhat is NOT machine learning - Burak Aybar
What is NOT machine learning - Burak AybarVisuality
 
Do you really need to reload?
Do you really need to reload?Do you really need to reload?
Do you really need to reload?Visuality
 
How to check valid email? Find using regex(p?)
How to check valid email? Find using regex(p?)How to check valid email? Find using regex(p?)
How to check valid email? Find using regex(p?)Visuality
 
Fantastic stresses and where to find them
Fantastic stresses and where to find themFantastic stresses and where to find them
Fantastic stresses and where to find themVisuality
 
Fuzzy search in Ruby
Fuzzy search in RubyFuzzy search in Ruby
Fuzzy search in RubyVisuality
 
Rfc process in visuality
Rfc process in visualityRfc process in visuality
Rfc process in visualityVisuality
 
GraphQL in Ruby on Rails - basics
GraphQL in Ruby on Rails - basicsGraphQL in Ruby on Rails - basics
GraphQL in Ruby on Rails - basicsVisuality
 
Consumer Driven Contracts
Consumer Driven ContractsConsumer Driven Contracts
Consumer Driven ContractsVisuality
 
How do we use CircleCi in Laterallink?
How do we use CircleCi in Laterallink?How do we use CircleCi in Laterallink?
How do we use CircleCi in Laterallink?Visuality
 
React Native - Short introduction
React Native - Short introductionReact Native - Short introduction
React Native - Short introductionVisuality
 
Risk in project management
Risk in project managementRisk in project management
Risk in project managementVisuality
 

More from Visuality (20)

3 issues that made 30 test workers take 40 minutes
3 issues that made 30 test workers take 40 minutes3 issues that made 30 test workers take 40 minutes
3 issues that made 30 test workers take 40 minutes
 
Czego nie robić przy pisaniu testów
Czego nie robić przy pisaniu testówCzego nie robić przy pisaniu testów
Czego nie robić przy pisaniu testów
 
Introduction to Domain-Driven Design in Ruby on Rails
Introduction to Domain-Driven Design in Ruby on RailsIntroduction to Domain-Driven Design in Ruby on Rails
Introduction to Domain-Driven Design in Ruby on Rails
 
Active Record .includes - do you use it consciously?
Active Record .includes - do you use it consciously?Active Record .includes - do you use it consciously?
Active Record .includes - do you use it consciously?
 
Introduction to Event Storming
Introduction to Event StormingIntroduction to Event Storming
Introduction to Event Storming
 
Jak programowanie może pomóc na co dzień?
Jak programowanie może pomóc na co dzień?Jak programowanie może pomóc na co dzień?
Jak programowanie może pomóc na co dzień?
 
SVG Overview - How To Draw, Use and Animate
SVG Overview - How To Draw, Use and AnimateSVG Overview - How To Draw, Use and Animate
SVG Overview - How To Draw, Use and Animate
 
How To Migrate a Rails App From a Dedicated Server Into Cloud Environment? - ...
How To Migrate a Rails App From a Dedicated Server Into Cloud Environment? - ...How To Migrate a Rails App From a Dedicated Server Into Cloud Environment? - ...
How To Migrate a Rails App From a Dedicated Server Into Cloud Environment? - ...
 
How to use AWS SES with Lambda 
in Ruby on Rails application - Michał Łęcicki
How to use AWS SES with Lambda 
in Ruby on Rails application - Michał ŁęcickiHow to use AWS SES with Lambda 
in Ruby on Rails application - Michał Łęcicki
How to use AWS SES with Lambda 
in Ruby on Rails application - Michał Łęcicki
 
What is NOT machine learning - Burak Aybar
What is NOT machine learning - Burak AybarWhat is NOT machine learning - Burak Aybar
What is NOT machine learning - Burak Aybar
 
Do you really need to reload?
Do you really need to reload?Do you really need to reload?
Do you really need to reload?
 
How to check valid email? Find using regex(p?)
How to check valid email? Find using regex(p?)How to check valid email? Find using regex(p?)
How to check valid email? Find using regex(p?)
 
Fantastic stresses and where to find them
Fantastic stresses and where to find themFantastic stresses and where to find them
Fantastic stresses and where to find them
 
Fuzzy search in Ruby
Fuzzy search in RubyFuzzy search in Ruby
Fuzzy search in Ruby
 
Rfc process in visuality
Rfc process in visualityRfc process in visuality
Rfc process in visuality
 
GraphQL in Ruby on Rails - basics
GraphQL in Ruby on Rails - basicsGraphQL in Ruby on Rails - basics
GraphQL in Ruby on Rails - basics
 
Consumer Driven Contracts
Consumer Driven ContractsConsumer Driven Contracts
Consumer Driven Contracts
 
How do we use CircleCi in Laterallink?
How do we use CircleCi in Laterallink?How do we use CircleCi in Laterallink?
How do we use CircleCi in Laterallink?
 
React Native - Short introduction
React Native - Short introductionReact Native - Short introduction
React Native - Short introduction
 
Risk in project management
Risk in project managementRisk in project management
Risk in project management
 

Recently uploaded

Insurance management system project report.pdf
Insurance management system project report.pdfInsurance management system project report.pdf
Insurance management system project report.pdfKamal Acharya
 
Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxMustafa Ahmed
 
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and ToolsMaximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Toolssoginsider
 
Raashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashidFaiyazSheikh
 
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfInstruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfEr.Sonali Nasikkar
 
What is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsWhat is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsVIEW
 
5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...archanaece3
 
Independent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging StationIndependent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging Stationsiddharthteach18
 
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024EMMANUELLEFRANCEHELI
 
analog-vs-digital-communication (concept of analog and digital).pptx
analog-vs-digital-communication (concept of analog and digital).pptxanalog-vs-digital-communication (concept of analog and digital).pptx
analog-vs-digital-communication (concept of analog and digital).pptxKarpagam Institute of Teechnology
 
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdfInvolute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdfJNTUA
 
Diploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdfDiploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdfJNTUA
 
Autodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptxAutodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptxMustafa Ahmed
 
Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..MaherOthman7
 
Artificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfArtificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfKira Dess
 
Artificial Intelligence in due diligence
Artificial Intelligence in due diligenceArtificial Intelligence in due diligence
Artificial Intelligence in due diligencemahaffeycheryld
 
Software Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdfSoftware Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdfssuser5c9d4b1
 
15-Minute City: A Completely New Horizon
15-Minute City: A Completely New Horizon15-Minute City: A Completely New Horizon
15-Minute City: A Completely New HorizonMorshed Ahmed Rahath
 
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxSLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxCHAIRMAN M
 
CLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference ModalCLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference ModalSwarnaSLcse
 

Recently uploaded (20)

Insurance management system project report.pdf
Insurance management system project report.pdfInsurance management system project report.pdf
Insurance management system project report.pdf
 
Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptx
 
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and ToolsMaximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
 
Raashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashid final report on Embedded Systems
Raashid final report on Embedded Systems
 
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfInstruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
 
What is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, FunctionsWhat is Coordinate Measuring Machine? CMM Types, Features, Functions
What is Coordinate Measuring Machine? CMM Types, Features, Functions
 
5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...
 
Independent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging StationIndependent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging Station
 
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
 
analog-vs-digital-communication (concept of analog and digital).pptx
analog-vs-digital-communication (concept of analog and digital).pptxanalog-vs-digital-communication (concept of analog and digital).pptx
analog-vs-digital-communication (concept of analog and digital).pptx
 
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdfInvolute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
Involute of a circle,Square, pentagon,HexagonInvolute_Engineering Drawing.pdf
 
Diploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdfDiploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdf
 
Autodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptxAutodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptx
 
Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..Maher Othman Interior Design Portfolio..
Maher Othman Interior Design Portfolio..
 
Artificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdfArtificial intelligence presentation2-171219131633.pdf
Artificial intelligence presentation2-171219131633.pdf
 
Artificial Intelligence in due diligence
Artificial Intelligence in due diligenceArtificial Intelligence in due diligence
Artificial Intelligence in due diligence
 
Software Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdfSoftware Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdf
 
15-Minute City: A Completely New Horizon
15-Minute City: A Completely New Horizon15-Minute City: A Completely New Horizon
15-Minute City: A Completely New Horizon
 
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxSLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
 
CLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference ModalCLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference Modal
 

Ruby formatters

  • 1. prettier-ruby? 
 ruby formatters overview "Good programmers" are those 
 who aleady have learned a set of rules that ensures good style; (…)
 The Elements of Programming Style 1974 Piotr Wasiak
  • 2. Ruby programming style history At the beginning there was chaos We got some ruby styling guides CodeReview focused sometimes more on style than the logic We got linters (PR services, overcommit, text-editor plugins) Should we now follow e.g. JS world 
 with using automatic formatters?

  • 3. Code formatter It enforces a consistent style 
 by parsing your code and 
 re-printing it with its own rules
  • 4. ✴ Rubocop ✴ Rufo ✴ Prettifier ✴ Rubyfmt RIP ✤ Ruby Script Beautifier (2008) ✤ eden (2011) ✤ ruby-beautify2 (fork: 01. 2018) Formatters ruby
  • 5. Parsers Ripper to STD LIB - written in C so faster
 
 ruby-parse to CLI do gem parser:
 production-ready written in pure Ruby. It recognises as much or more code than Ripper, Melbourne, JRubyParser or ruby_parser, and is
  • 6. Rubocop heavy, but very good advanced configuration parameters to use as formatter:
 -a --auto-correct Auto-correct offenses. --safe-auto-correct Run auto-correct only when it's safe. -x, --fix-layout Run only layout cops, with auto-correct on. (currently 81 cops) --only-guide-cops Run only cops for rules that link to a style guide. --only [COP1,COP2,...] Run only the given cop(s).
  • 8. RuFo Not a simple find and replace one, very fast Was implemented in a similar fashion to Crystal's formatter.
 
 Started 2 years ago, but currently is getting less updates / issues than prettier
 
 There are some problems with chained heredocs, (…)
 
 config options: trailing_commas, parens_in_def
  • 11. Rufo is fast Less strict than prettier, but it seems that it formats less
  • 12. Rubyfmt Fast, integrated with shell (no ruby gem) 
 Project development started 5 months ago 
 no config options. 
 
 No max chars/line, removes additional enters
 
 Broke on some files (also especially @ rspec specs) Fast per file - 175 ms
 many files at once is not a case
  • 14. Rubyfmt problems user_context&.role&.in? %w(Admin Company) AddActivityService.new(candidate: candidate, **keywords).call expect(email.body).to match 'His/her search can be shown'
  • 15. Prettier-ruby Fast and opinionated in many languages as plugin to text editors Ruby plugin development started 7 months ago 
 config options:
 printWidth, tabWidth, addTrailingCommas, inlineConditionals, inlineLoops, preferHashLabels, preferSingleQuotes Fast per file - 170 ms
 many files at once is not a case
  • 19. Speed command User time System time Total time rufo ruby.rb 0.14s 0.05s 0.202s ./node_modules/.bin/ prettier 0.38s 0.08s 0.462s Rubocop -a 1.09s 0.25s 1.349s command User time System time Total time rufo **/*.rb 1.16s 0.20s 1.379s Rubocop -a 3.18s 0.41s 3.635s Rubocop -a 
 —cache false 14.34s 0.64s 15.174s ./node_modules/.bin/ prettier 36.23s 13.51s 51.606s Format rails api project LOC: 2644 Format 1 file (ruby test) Rubyfmt - total time 30.s with some errors during parsing
  • 20. Formatter triggers ✓ On file save ✓ On code paste ✓ On demand
  • 21. Sum up: How to live? Use still linter Chillout with code style wars Try prettier formatter on demand/paste 
 and report issues on GitHub