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
2023
2024
 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

Configuration

Erbcop will start looking for the configuration file in the following locations:

  1. /path/to/project/.erbcop.yml
  2. /path/to/project/.rubocop.yml

For example, if you want to disable some cops on erbcop, you can add the following file to your project:

# .erbcop.yml
inherit_from:
  - .rubocop.yml

Foo/Bar:
  Enabled: false