Socket
Book a DemoInstallSign in
Socket

slimembedcop

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slimembedcop

1.0.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

SlimEmbedCop

Gem Version CI RubyDoc

RuboCop runner for Ruby code embedded in Slim.

Installation

SlimEmbedCop's installation is pretty standard:

% gem install slimembedcop

If you'd rather install SlimEmbedCop using bundler, add a line for it in your Gemfile (but set the require option to false, as it is a standalone tool):

gem 'slimembedcop', require: false

Usage

Use slimembedcop executable to check offenses and autocorrect them. RuboCop's cop or any custom cop you create can also be used with slimembedcop.

% exe/slimembedcop --help
Usage: slimembedcop [options] [file1, file2, ...]
    -v, --version                    Display version.
    -a, --autocorrect                Autocorrect offenses.
    -c, --config=                    Specify configuration file.
        --[no-]color                 Force color output on or off.
    -d, --debug                      Display debug info.

Example

You have a Slim file like this:

ruby:
  message = "world"
html
  head
    title Slim Samples
  body
    ruby:
      if some_var = true
        do_something
      end
    h1 Hello, #{message}
ruby:
  do_something /pattern/i

When executed, it outputs the following offenses:

% slimembedcop dummy.slim
Inspecting 1 file
W

Offenses:

dummy.slim:2:13: C: [Correctable] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  message = "world"
            ^^^^^^^
dummy.slim:8:19: W: [Correctable] Lint/AssignmentInCondition: Use == if you meant to do a comparison or wrap the expression in parentheses to indicate you meant to assign in a condition.
      if some_var = true
                  ^
dummy.slim:13:16: W: [Correctable] Lint/AmbiguousRegexpLiteral: Ambiguous regexp literal. Parenthesize the method arguments if it's surely a regexp literal, or add a whitespace to the right of the / if it should be a division.
  do_something /pattern/i
               ^

1 file inspected, 3 offenses detected, 3 offenses autocorrectable

Configuration

The behavior of RuboCop can be controlled via the .rubocop.yml configuration file. The behavior of SlimEmbedCop can be controlled by the .slimembedcop.yml configuration file. It makes it possible to enable/disable certain cops (checks) and to alter their behavior if they accept any parameters. The file can be placed in your home directory, XDG config directory, or in some project directory.

The file has the following format:

inherit_from: ../.rubocop.yml

Style/Encoding:
  Enabled: false

Layout/LineLength:
  Max: 99

NOTE: It is basically the same as RuboCop's. Please check Configuration for details.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 29 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.