ezCater custom cops and shared RuboCop configuration.
RuboCop is a static code analyzer that can enforce style conventions as well as identify common problems.
Add this line to your application's Gemfile:
group :development do
gem "ezcater_rubocop", require: false
end
Or to your gem's gemspec file:
spec.add_development_dependency "ezcater_rubocop"
And then execute:
$ bundle install
Or install it yourself as:
$ gem install ezcater_rubocop
To use one of the shared RuboCop configurations from this gem, you must define a .rubocop.yml file in your project:
inherit_gem:
ezcater_rubocop: conf/rubocop_rails.yml
Further customization of RuboCop for your local project may be added to this file.
Run rubocop
for an entire project:
$ bundle exec rubocop
See the rubocop
command-line for additional options including auto-generating
configuration for existing offenses and auto-correction.
This gem contains a script, circle_rubocop.rb
, that can be used to run RuboCop in CI.
The behavior of the script is that all files are checked on main or if the rubocop configuration has changed. On non-main branches, only the files added or changed on the branch are checked.
For non-main branches, [rubocop skip]
can be included in the commit message to skip
running rubocop.
This gem is using Semantic Versioning. All version bumps should increment using MAJOR.MINOR.PATCH
based on changes.
When adding a new cop, please enable the cop and release a new major version. This allows us to
constantly roll out improvements without clients having their suite break unknowingly. When a
breaking change is released, users can opt to use --regenerate-todo
to update their TODO file. Do
not add cops with enabled: false
unless you want that cop to always be disabled.
EzcaterFeatureFlag.active?
Rails.configuration
instead of Rails.application.config
.GQLErrors
instead of raising GraphQL::ExecutionError
directly.match_ordered_array
matcher instead of eq
matcher. This matcher comes from the ezcater_matchers gem.mock_ezcater_app
, mock_chrome_browser
& mock_custom_browser
helpers instead of mocking Browser
or EzBrowser
directly.mock_feature_flag
helper instead of mocking FeatureFlag.is_active?
directly.expect(response).to have_http_status :bad_request
, rather than expect(response.code).to eq 400
dig
for deeply nested access.After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
.
To release a new version, update the version number in version.rb
, merge your PR to main
, and then 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.
Bug reports and pull requests are welcome on GitHub at https://github.com/ezcater/ezcater_rubocop.
New cops can be generated via the new_cop
rake task which generates
the cop, the spec, updates imports, and adds configuration. Example:
rake 'new_cop[Ezcater/foo_bar]'
Follow the instructions after the task executes and update code as necessary for consistency.
In addition, you need to:
The version for this gem follows Semantic Versioning:
Bump the MAJOR version for breaking changes. Example: new cop, enabled by default and which cannot be safely autofixed.
Bump the MINOR version for new functionality which will not disrupt projects which depend on this gem. Example: new cop, not enabled by default or which can safely be autofixed.
Bump the PATCH version for backwards compatible bugfixes.
The version does not need to be bumped and the changelog does not need to be updated for chores which do not affect users of this gem. Example: updating CI. Omitting these details helps keep the signal-to-noise ratio high for people upgrading the gem as these types of changes will not affect them.
The gem is available as open source under the terms of the MIT License.