Git Product home page Git Product logo

salsify_rubocop's Introduction

salsify_rubocop

This gem provides shared configuration for RuboCop for Salsify applications/gems and some experimental cops.

RuboCop is a static code analyzer that can enforce style conventions as well as identify common problems.

Installation

Add this line to your application's Gemfile:

group :development, :test do
  gem 'salsify_rubocop', require: false
end  

Or to your gem's gemspec file:

spec.add_development_dependency 'salsify_rubocop'

If you created your gem using cookiecutter-salsify-gem then this dependency was added automatically.

Then execute:

$ bundle install

It's best to ensure that you're starting from the latest release, so execute:

$ bundle update salsify_rubocop

Configuration

To use one of the shared RuboCop configurations from this gem, you must define a .rubocop.yml file at the top-level directory in your project:

inherit_gem:
  salsify_rubocop: conf/rubocop_rails.yml

Further customization of RuboCop for your local project may also be added to this file.

Available Configurations

  • rubocop_rails: For Rails projects, this inherits from rubocop.
  • rubocop: Assumes RSpec is used and requires rubocop-rspec. This configuration is the default for gems. This inherits from rubocop_without_rspec.
  • rubocop_without_rspec: Configuration without rubocop-rspec. This is intended for gems that we may have forked and taken ownership of without converting tests from a different framework.

Usage

Run rubocop for an entire project:

$ bundle exec rubocop --format fu

See the rubocop command-line for additional options including auto-generating configuration for existing offenses and auto-correction.

Overcommit

Consider using overcommit to automatically run rubocop on changed files before committing.

This is automatically added by cookiecutter-salsify-gem.

CI

Consider running rubocop prior to running tests in CI for your project.

TODO: add more info here.

Versioning

This gem is versioned based on the MAJOR.MINOR version of rubocop. The first release of the salsify_rubocop gem was v0.40.0.

The patch version for this gem does not correspond to the patch version of rubocop. The patch version for this gem will change any time that one of its configurations is modified or its dependency on rubocop is changed to require a different patch version.

This gem also includes a dependency on rubocop-rspec that will be updated to the latest compatible version each time that the MAJOR.MINOR version of rubocop is updated.

Change Process

This configuration is meant to represent the general opinion of Salsify's Ruby community around best practices for writing readable Ruby code. As a result, changes to this configuration should go through a discussion phase in the #rubocop-changes Slack channel to ensure the broader Salsify Ruby community is on board with the change. Non-Salsify developers should file an issue via GitHub with proposed changes.

When enabling a cop we try to keep the following points in mind to avoid overburdening consumers:

  • Does the cop support safe auto-correction? If not, do we expect a large number of offenses needing manual remediation?
  • Does the cop help avoid bugs or is it merely stylistic?
  • For stylistic cops, does the enforced style reflect that of Salsify developers?

Updating RuboCop

Updating to a new minor version of rubocop may add new "pending" cops which are not enabled until the next major version (see: RuboCop Versioning). However, we may wish to eagerly enable or explicitly disable newly introduced cops. Any such decisions around "pending" cops should go through the change process described above.

When updating to a new major version or updating other dependencies that don't follow the same versioning pattern, we should check if there are any newly enabled cops included in the update. Any new cops should go through a review process in #rubocop-changes to ensure we truly want to enable the cop.

Development

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. Run bundle exec salsify_rubocop to use the gem in this directory, ignoring other installed copies of this gem.

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, 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.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/salsify/salsify_rubocop.

License

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

salsify_rubocop's People

Contributors

tjwp avatar ric2b avatar erikkessler1 avatar jturkel avatar timothysu avatar joshbranham avatar ecopoesis avatar ticklemynausea avatar atsheehan avatar edbrown23 avatar kbarrette avatar kphelps avatar askreet avatar hirparap1 avatar skarger avatar will89 avatar

Stargazers

Robin Daugherty avatar Junda Chen avatar Ilya Vassilevsky avatar Spencer Dixon avatar 0x55E avatar

Watchers

João Ferreira Batista avatar David Martinho avatar Matthew Cross avatar  avatar Makala Noble avatar James Cloos avatar Jeremy Redburn avatar Randy Burkes avatar Adam Edgett avatar  avatar Reshma avatar  avatar João Mateus avatar  avatar Romina Vargas avatar Masataka Pocke Kuwabara avatar Carlos Fraga avatar Miguel Cruz avatar  avatar Cláudia Alves avatar Fernando Ferreira Nunes avatar Fernando Garces avatar Pedro H. Pereira avatar  avatar  avatar Greg Merritt avatar Luís Fonsi avatar Bernardo Graça avatar Miguel avatar Carlos Saraiva avatar José Sousa avatar Tristan Warneke avatar  avatar  avatar Marta Teixeira avatar Ricardo Castelao avatar Enrique Vetere (undertalk) avatar

Forkers

harrinry

salsify_rubocop's Issues

False Positive Salsify/StyleDig with Thread.current

Thread doesn't support dig which leads to false positives like Thread.current[:foo][:bar]. Note Thread.current[:foo][:bar][:baz] would likely not be a false positive since it means Thread.current[:foo] has likely returned something diggable.

False Positive Salsify/StyleDig

The following example feels like an odd scenario to raise this rubocop warning.

hash[key1] ||= {}
hash[key1][key2] ||= {}
hash[key1][key2][key3] = 'Some value' # raises Salsify/StyleDig

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.