Slide 1

Slide 1 text

Clean code in Ruby Clean code, coding convention, Rubocop and Pronto

Slide 2

Slide 2 text

About me Hoang Quan Born: Hanoi, Vietnam Work: Tokyo, Japan Github: BlazingRockStorm Viblo: Hoàng Đức Quân

Slide 3

Slide 3 text

Agenda Topics Covered Why clean code is necessary? Coding convention Rubocop and setup Pronto and integration with Github actions

Slide 4

Slide 4 text

Why clean code is necessary? Go Back to Agenda Page

Slide 5

Slide 5 text

Clean code is the code that is easy to read, understand, and maintain What is clean code?

Slide 6

Slide 6 text

Readability and maintenance: Clean code prioritizes clarity, which makes reading, understanding, and modifying code easier. Writing readable code reduces the time required to grasp the code's functionality, leading to faster development times. Why clean code is necessary?

Slide 7

Slide 7 text

Team collaboration: Clear and consistent code facilitates communication and cooperation among team members. By adhering to established coding standards and writing readable code, developers easily understand each other's work and collaborate more effectively. Why clean code is necessary?

Slide 8

Slide 8 text

Debugging and issue resolution: Clean code is designed with clarity and simplicity, making it easier to locate and understand specific sections of the codebase. Clear structure, meaningful variable names, and well-defined functions make it easier to identify and resolve issues. Why clean code is necessary?

Slide 9

Slide 9 text

Improved quality and reliability: Clean code prioritizes following established coding standards and writing well-structured code. This reduces the risk of introducing errors, leading to higher-quality and more reliable software down the line. Why clean code is necessary?

Slide 10

Slide 10 text

Why clean code is necessary?

Slide 11

Slide 11 text

Coding convention Go Back to Agenda Page

Slide 12

Slide 12 text

Coding convention Coding conventions are a set of guidelines for a specific programming language that recommend programming style, practices, and methods for each aspect of a program written in that language.

Slide 13

Slide 13 text

Coding convention These conventions usually cover file organization, indentation, comments, declarations, statements, white space, naming conventions, programming practices, programming principles, programming rules of thumb, architectural best practices, etc. These are guidelines for software structural quality.

Slide 14

Slide 14 text

Coding convention Different organizations have different coding conventions and code styles

Slide 15

Slide 15 text

Coding convention with Ruby https://ruby-style- guide.shopify.dev/ https://github.com/cookpad/style guide/blob/master/ruby.en.md

Slide 16

Slide 16 text

Coding convention with Ruby

Slide 17

Slide 17 text

How can we implement coding rules in Ruby?

Slide 18

Slide 18 text

Rubocop and setup Go Back to Agenda Page

Slide 19

Slide 19 text

Rubocop RuboCop is a Ruby code style checker (linter) and formatter based on the community-driven Ruby Style Guide. RuboCop is extremely flexible and most aspects of its behavior can be tweaked via various configuration options. In practice RuboCop supports pretty much every (reasonably popular) coding style that you can think of. Apart from reporting problems in your code, RuboCop can also automatically fix some of the problems for you.

Slide 20

Slide 20 text

Rubocop: Setup

Slide 21

Slide 21 text

Coding convention with Ruby

Slide 22

Slide 22 text

Pronto and integration with CI/CD (Github actions) Go Back to Agenda Page

Slide 23

Slide 23 text

https://github.com/prontolabs/pronto Pronto runs analysis quickly by checking only the relevant changes. Created to be used on GitHub pull requests, but also works locally and integrates with GitLab and Bitbucket. Written in Ruby Pronto

Slide 24

Slide 24 text

https://github.com/BlazingRockStorm/rails- lyrics-site/pull/33 Pronto

Slide 25

Slide 25 text

Pronto

Slide 26

Slide 26 text

— https://youtu.be/smDgS8E_-jI? si=IpGH-9lUoL8QP2RD

Slide 27

Slide 27 text

Thank you!