<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jayesh Mann</title>
    <description>The latest articles on DEV Community by Jayesh Mann (@jayeshmann).</description>
    <link>https://dev.to/jayeshmann</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F191569%2F9b24cadd-8d7f-4057-a500-d68e25ddc523.png</url>
      <title>DEV Community: Jayesh Mann</title>
      <link>https://dev.to/jayeshmann</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jayeshmann"/>
    <language>en</language>
    <item>
      <title>Pre-Commit hooks guide for Ruby</title>
      <dc:creator>Jayesh Mann</dc:creator>
      <pubDate>Wed, 17 Aug 2022 04:03:30 +0000</pubDate>
      <link>https://dev.to/jayeshmann/pre-commit-hooks-guide-for-ruby-5c3h</link>
      <guid>https://dev.to/jayeshmann/pre-commit-hooks-guide-for-ruby-5c3h</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Note: This guide assumes you are using rubocop for linting and RSpec for testing&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Git hook scripts are useful for identifying simple issues before submission to code review. We run our hooks on every commit to automatically point out issues in code such as missing semicolons, trailing whitespace, and debug statements. By pointing these issues out before code review, this allows a code reviewer to focus on the architecture of a change while not wasting time with trivial style nitpicks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;Using homebrew:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;pre-commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Configuration
&lt;/h2&gt;

&lt;p&gt;create a file named &lt;code&gt;.pre-commit-config.yaml&lt;/code&gt; in your project root.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;repos&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;repo&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://github.com/pre-commit/pre-commit-hooks&lt;/span&gt;
    &lt;span class="na"&gt;rev&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v4.3.0&lt;/span&gt;
    &lt;span class="na"&gt;hooks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;trailing-whitespace&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;end-of-file-fixer&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;repo&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;https://github.com/mattlqx/pre-commit-ruby&lt;/span&gt;
    &lt;span class="na"&gt;rev&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;v1.3.5&lt;/span&gt;
    &lt;span class="na"&gt;hooks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;rubocop&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;rspec&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Updated configuration &amp;amp; discussion thread is maintained on &lt;a href="https://gist.github.com/jayeshmann/a2f562972c70678ee3479bb12c5d1c36"&gt;GitHub.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Install git hooks
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pre-commit &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;now pre-commit will run automatically on git commit&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Run against all files
&lt;/h3&gt;

&lt;p&gt;Pre-Commit will only run on changed files during git commit.&lt;/p&gt;

&lt;p&gt;In case you would like to run it on all the files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pre-commit run &lt;span class="nt"&gt;--all-files&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Feel free to config pre-commit according to your requirements.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pre-commit.com/hooks.html"&gt;Supported hooks&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://pre-commit.com/"&gt;Official Website&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/pre-commit/demo-repo#readme"&gt;Official Demo&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;License: &lt;a href="https://spdx.org/licenses/AGPL-3.0-or-later.html"&gt;AGPL-3.0-or-later&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>inthirtyseconds</category>
    </item>
    <item>
      <title>Rubocop - Linting QuickStart for Ruby</title>
      <dc:creator>Jayesh Mann</dc:creator>
      <pubDate>Wed, 10 Aug 2022 17:42:00 +0000</pubDate>
      <link>https://dev.to/jayeshmann/rubocop-linting-quickstart-for-ruby-46b4</link>
      <guid>https://dev.to/jayeshmann/rubocop-linting-quickstart-for-ruby-46b4</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Knowledge Base: Lint, or a linter, is a static code analysis tool used to flag programming errors, bugs, stylistic errors and suspicious constructs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Make sure you have your ruby environment(check &lt;a href="https://docs.rubocop.org/rubocop/compatibility.html"&gt;compatibility&lt;/a&gt;) working before proceeding.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;Simply run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;% gem &lt;span class="nb"&gt;install &lt;/span&gt;rubocop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Configuration
&lt;/h2&gt;

&lt;p&gt;Create a &lt;code&gt;.rubocop.yml&lt;/code&gt; file in your home(&lt;code&gt;% cd ~&lt;/code&gt;) directory for all ruby projects. Alternatively, you can create it in your project directory.&lt;/p&gt;

&lt;h3&gt;
  
  
  Default Configuration
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/rubocop/rubocop/blob/master/config/default.yml"&gt;Default Configuration&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Recommended Configuration
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/jayeshmann/ebdfb33aa27dabc3bc2f5ff1b5f694dc"&gt;Jayesh's rubocop configuration&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Check
&lt;/h3&gt;

&lt;p&gt;In your project's directory,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;% rubocop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or you can specify a file or a directory of your choosing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;% rubocop lib/file.rb spec/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;If you don't have rubocop on your terminal, try &lt;code&gt;bundle exec rubocop&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Correct
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;% rubocop &lt;span class="nt"&gt;-a&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Knowledge Base: Only safe offenses will be fixed with &lt;code&gt;-a&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Official Links
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://rubocop.org/"&gt;Official Website&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.rubocop.org/"&gt;Official Documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://rubystyle.guide/"&gt;Community Ruby Style Guide&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  All rules
&lt;/h3&gt;

&lt;p&gt;Here is the list of rules with their categories:&lt;br&gt;
&lt;a href="https://docs.rubocop.org/rubocop/cops.html"&gt;https://docs.rubocop.org/rubocop/cops.html&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  More Guides
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://sourcelevel.io/blog/rubocop-how-to-install-and-configure"&gt;RuboCop: How to install and configure&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/stungeye/10423491"&gt;Installing and Running Rubocop&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;License: &lt;a href="https://spdx.org/licenses/AGPL-3.0-or-later.html"&gt;AGPL-3.0-or-later&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>inthirtyseconds</category>
    </item>
  </channel>
</rss>
