Skip to content

Update README.md for Enhanced Usability and Clarity #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 54 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,82 @@

# RuboCop Sequel

Code style checking for [Sequel](https://sequel.jeremyevans.net/).
Code style checking for [Sequel ORM](https://sequel.jeremyevans.net/).

## Installation

Using the `rubocop-sequel` gem
You can install the `rubocop-sequel` gem using either of the following methods:

### Via RubyGems

Run this command in your terminal:

```bash
gem install rubocop-sequel
```

or using bundler by adding in your `Gemfile`
### Using Bundler

```
Add this line to your project's Gemfile:

```ruby
gem 'rubocop-sequel'
```

Then, execute:

```bash
bundle install
```

## Usage

### RuboCop configuration file
### Configuring RuboCop

Add to your `.rubocop.yml`.
To integrate RuboCop Sequel into your project, add the following line to your
`.rubocop.yml` configuration file:

```
```yaml
require: rubocop-sequel
```

`rubocop` will now automatically load RuboCop Sequel
cops alongside with the standard cops.
This configuration instructs RuboCop to automatically load the RuboCop Sequel cops
along with the standard set, enhancing your project's code analysis with
Sequel-specific checks.

### Running from the Command Line

### Command line
Invoke RuboCop with the `rubocop-sequel` requirement to analyze your project's files:

```bash
rubocop --require rubocop-sequel
```

### Rake task

```ruby
RuboCop::RakeTask.new do |task|
task.requires << 'rubocop-sequel'
end
```
## Testing with RuboCop Sequel Cops

The rubocop-sequel gem includes several cops that enforce best practices for using
Sequel. These cops are designed to catch common errors and guide developers towards
more efficient and maintainable code patterns. Below are examples of some key cops
and how they improve your Sequel code:

- `Sequel::SaveChanges` - Ensures the use of save_changes instead of save to persist
changes to models.
- `Sequel::JSONColumn` - Advocates the use of the `jsonb` column type over `json` or
`hstore` for performance benefits and additional functionality.
- `Sequel::ConcurrentIndex` - Encourages the creation of indexes with the
`NOT VALID` option to avoid locking tables.
- `Sequel::PartialConstraint` - Advises on the correct use of partial indexes by
specifying the `where' argument.
- `Sequel::NotValidConstraint` - Suggests adding constraints with the
`not_valid: true` option for safer migrations.
- `Sequel::MigrationName` - Helps to name migration files descriptively in order to
avoid the use of default or generic names.

By incorporating these and other Sequel-specific cops into your RuboCop checks, you
can significantly improve the quality and reliability of your database interactions.

## Contribution

Contributions to the `rubocop-sequel` project are welcome! Whether it's adding new
cops, improving existing ones, or fixing bugs, your help is appreciated in making
this gem more useful for the Ruby and Sequel communities.