Project

erbcop

0.0
The project is in a healthy, maintained state
RuboCop runner for ERB template.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
 Dependencies

Runtime

 Project Readme

Erbcop

Gem Version test

RuboCop runner for ERB template.

This is the ERB version of Slimcop.

Installation

Add this line to your application's Gemfile:

gem 'erbcop'

And then execute:

bundle install

Or install it yourself as:

gem install erbcop

Usage

Use erbcop executable to check offenses and auto-correct them.

$ erbcop --help
Usage: erbcop [options] [file1, file2, ...]
    -a, --auto-correct               Auto-correct offenses.
    -c, --config=                    Specify configuration file. (default: .erbcop.yml or .rubocop.yml)
        --[no-]color                 Force color output on or off.

Example

$ erbcop 'spec/fixtures/**/*.erb'
Inspecting 1 file
C

Offenses:

spec/fixtures/dummy.erb:1:4: C: [Correctable] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
<% "a" %>
   ^^^
spec/fixtures/dummy.erb:4:9: C: [Correctable] Style/NumericPredicate: Use array.size.positive? instead of array.size > 0.
<% a if array.size > 0 %>
        ^^^^^^^^^^^^^^
spec/fixtures/dummy.erb:4:9: C: [Correctable] Style/ZeroLengthPredicate: Use !empty? instead of size > 0.
<% a if array.size > 0 %>
        ^^^^^^^^^^^^^^
spec/fixtures/dummy.erb:5:4: C: [Correctable] Style/NegatedIf: Favor unless over if for negative conditions.
<% a if !b %>
   ^^^^^^^

1 file inspected, 4 offenses detected, 4 offenses auto-correctable