Analyzing cookbooks with RuboCop
We begin with a look at tools working within the cookbooks-as-code model. These tools are considered static analysis test tools, and they examine the code itself to verify syntax, structure, and alignment with desired coding practices. The first tool we'll explore is named RuboCop.
Simply put, by using RuboCop, you will produce better cookbooks. RuboCop is included as part of the ChefDK installation. It is a command-line tool used to test the syntax and style of individual cookbooks. RuboCop uses a set of rules, known as cops, to test specific considerations, such as syntax, style, and metrics for Ruby best practices. These cops deliver results as warnings, deviations from convention, and different levels of errors. The main benefits of using RuboCop are that you identify errors early in the development process and the resulting code conforms to an agreed upon style and formatting practice. So, how do we use RuboCop? Let's take a look now.
Using RuboCop
The...