Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
RuboCop is great for keeping code quality high by enforcing community-driven Ruby standards in our codebases. But RuboCop can also be easily customized to enforce standards that are unique to our codebase, automatically checking for the things that are most important to us. In this workshop we'll customize RuboCop to enforce our most important style rule: all comments must be in the form of a haiku! Along the way we'll learn: the basics of linting and RuboCop itself a little about abstract syntax trees how to build powerful custom tooling to enforce almost any standard we can think of!
Date
Summarized using AI?
If this talk's summary was generated by AI, please check this box. A "Summarized using AI" badge will be displayed in the summary tab to indicate that the summary was generated using AI.
Show "Summarized using AI" badge on summary page
Summary
Markdown supported
In this workshop presented at RubyConf 2021 by Scott Moore and Kari Silva, attendees learned how to customize RuboCop, a popular linter for Ruby, to enforce unique coding standards in their projects, particularly focusing on the creative challenge of requiring comments to be written as haikus. The session covered a variety of topics essential for understanding and implementing custom linting beyond RuboCop's default settings. **Key Points Discussed:** - **Introduction to RuboCop:** Attendees were introduced to RuboCop, its purpose in maintaining code quality, and its reliance on an underlying library called Parser to analyze Ruby code through an abstraction known as the Abstract Syntax Tree (AST). - **Custom Linters:** The workshop emphasized the value of creating custom linters tailored to specific coding needs, highlighting how participants could implement rules to enforce best practices unique to their codebases. - **Abstract Syntax Trees:** A brief explanation was provided regarding how RuboCop utilizes Parser to transform source code into tokens and subsequently into an AST, allowing for detailed programmatic analysis. - **Building a Custom Linter:** Participants were guided through developing a simple linter that flagged comments that did not adhere to the haiku format, encompassing essential coding practices such as utilizing callbacks to trigger checks during the linting process. - **Node Pattern Matching:** The latter part of the workshop focused on advanced features, including the 'node pattern matcher,' which simplifies the process of finding and enforcing rules in the AST. Participants explored the implementation of this pattern to selectively apply haiku validations to specific method definitions. - **Case Studies and Examples:** Several hands-on coding examples reinforced the concepts being discussed, including inspecting processed sources, dumping comments, and adding offenses that enforced specific rules such as the number of lines and syllable counts required in haikus. **Conclusion and Takeaways:** - The workshop effectively illustrated how to extend RuboCop's functionality, making it a powerful tool tailored to developers' specific needs. Participants left with a solid understanding of both the theoretical and practical aspects of building custom linters, equipping them with the skills to improve their coding standards and practices. The use of haikus served as a fun and engaging way to practice this vital skill.
Suggest modifications
Cancel