Thanks to visit codestin.com
Credit goes to github.com

Skip to content

egracens/rubocop-kanso

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RuboCop Kanso (簡素)

RuboCop extension for writing clean, minimal Ruby code. Kanso (簡素) is a Japanese principle meaning simplicity through elimination of clutter.

Installation

Add this line to your application's Gemfile:

gem 'rubocop-kanso', require: false

And then execute:

bundle install

Or install it yourself as:

gem install rubocop-kanso

Usage

Add the following to your .rubocop.yml:

plugins:
  - rubocop-kanso

# Optional: Configure the cops
Kanso/NoRailsHelperRequire:
  Enabled: true

Kanso/NoRSpecDescribe:
  Enabled: true

Cops

Kanso/NoRailsHelperRequire

This cop disallows requiring rails_helper in spec files. Instead, configure your .rspec file in the project root with the following lines:

--require rails_helper

Bad:

require "rails_helper"

Good:

Configure .rspec file:

--require rails_helper

And remove the require statement from your spec files.

Auto-correction: ✅ Supported (removes the require statement)

Kanso/NoRSpecDescribe

This cop enforces using describe instead of RSpec.describe for consistency.

Bad:

RSpec.describe MyClass do
  # spec content
end

Good:

describe MyClass do
  # spec content
end

Auto-correction: ✅ Supported

Development

After checking out the repo, run bundle install to install dependencies. Then, run bundle exec rspec to run the tests.

Testing

Run the test suite with:

bundle exec rspec

Building the Gem

To build the gem:

gem build rubocop-kanso.gemspec

Publishing

To release a new version:

  1. Update the version number in lib/rubocop/kanso/version.rb
  2. Run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org

Or manually:

gem build rubocop-kanso.gemspec
gem push rubocop-kanso-1.x.x.gem

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/egracens/rubocop-kanso.

License

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

About

The collection of custom rubocop rules

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages