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

Skip to content

Cuseum/rubocop-cuseum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RuboCop Cuseum

Custom RuboCop cops for enforcing Cuseum service class conventions.

Installation

Add this line to your application's Gemfile:

gem 'rubocop-cuseum', github: 'cuseum/rubocop-cuseum'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install rubocop-cuseum

Usage

Put this into your .rubocop.yml:

require:
  - rubocop-cuseum

Cops

Cuseum/SinglePublicMethodService

Ensures that service classes have at most one public method.

# good - zero public methods
class UserService < BaseService
  private

  def process_user
    # ...
  end
end

# good - one public method
class UserService < BaseService
  def call
    # ...
  end

  private

  def process_user
    # ...
  end
end

# bad - multiple public methods
class UserService < BaseService
  def call
    # ...
  end

  def execute  # ← should be private
    # ...
  end
end

Cuseum/InheritFromBaseService

Ensures that service classes inherit from BaseService directly or indirectly.

# good - direct inheritance
class UserService < BaseService
  def call
    # ...
  end
end

# good - indirect inheritance through ApplicationService
class UserService < ApplicationService
  def call
    # ...
  end
end

# bad - no inheritance from BaseService
class UserService
  def call
    # ...
  end
end

Cuseum/PublicMethodNamedCall

Ensures that any public method in service classes is named "call".

# good - public method named "call"
class UserService < BaseService
  def call
    # ...
  end

  private

  def process_user
    # ...
  end
end

# bad - public method with wrong name
class UserService < BaseService
  def execute  # ← should be "call"
    # ...
  end
end

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests.

Contributing

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

License

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

About

Cuseum-specific cops for RuboCop

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages