Skip to content

Commit

Permalink
Merge branch 'master' into francisfuzz/styleguide-syntax-update
Browse files Browse the repository at this point in the history
  • Loading branch information
bensheldon authored Oct 13, 2022
2 parents 4b7844a + 2eddce7 commit 2ab6fce
Show file tree
Hide file tree
Showing 18 changed files with 1,901 additions and 255 deletions.
5 changes: 4 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
inherit_from: ./config/default.yml
inherit_from:
- ./config/default.yml

Naming/FileName:
Enabled: true
Exclude:
- "rubocop-github.gemspec"
- "lib/rubocop-github.rb"
- "lib/rubocop-github-rails.rb"
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# rubocop-github

## Unreleased

- Unset `DisabledByDefault: true` in `config/default.yml`. Prevents confusing behaviour where users of the gem didn't realise that RuboCop's default cops weren't being applied (including potentially custom cops in their projects). We've explicitly set `Enabled: false` for all the cops that were previously default disabled. This has the effect that consumers of this gem won't be surprised by new linting violations when they use this new version in their projects. (https://github.com/github/rubocop-github/pull/119)
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ GEM
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
minitest (5.16.1)
nokogiri (1.13.6-arm64-darwin)
racc (~> 1.4)
nokogiri (1.13.6-x86_64-darwin)
racc (~> 1.4)
parallel (1.22.1)
Expand Down Expand Up @@ -71,6 +73,7 @@ GEM
unicode-display_width (2.2.0)

PLATFORMS
arm64-darwin-21
x86_64-darwin-19
x86_64-darwin-20

Expand Down
40 changes: 26 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,37 @@ This repository provides recommended RuboCop configuration and additional Cops f

## Usage

**Gemfile**
Add `rubocop-github` to your Gemfile, along with its dependencies:

``` ruby
gem "rubocop-github"
gem "rubocop-performance", require: false
gem "rubocop-rails", require: false
```
```ruby
gem "rubocop-github", require: false
gem "rubocop-performance", require: false
gem "rubocop-rails", require: false
```

**.rubocop.yml**
Inherit all of the stylistic rules and cops through an inheritance declaration in your `.rubocop.yml`:

``` yaml
inherit_gem:
rubocop-github:
- config/default.yml
- config/rails.yml
```
```yaml
# .rubocop.yml
inherit_from:
rubocop-github:
- config/default.yml # generic Ruby rules and cops
- config/rails.yml # Rails-specific rules and cops
```

Alternatively, only require the additional custom cops in your `.rubocop.yml` without inheriting/enabling the other stylistic rules:

```yaml
# .rubocop.yml
require:
- rubocop-github # generic Ruby cops only
- rubocop-github-rails # Rails-specific cops only
```

💭 Looking for `config/accessibility.yml` and the `GitHub/Accessibility` configs? They have been moved to [a new gem](https://github.com/github/rubocop-rails-accessibility).

For more granular control over which of RuboCop's rules are enabled for your project, both from this gem and your own configs, consider using the `DisabledByDefault: true` option under `AllCops` in your project's `.rubocop.yml` file. This will disable all cops by default, and you can then explicitly enable the ones you want by setting `Enabled: true`. See [the RuboCop docs](https://docs.rubocop.org/rubocop/configuration.html#enabled) for more information.

### Legacy usage

If you are using a rubocop version < 1.0.0, you can use rubocop-github version
Expand All @@ -37,4 +49,4 @@ bundle exec rake test

## The Cops

All cops are located under [`lib/rubocop/cop/github`](lib/rubocop/cop/github) and [`lib/rubocop/cop/github/accessibility`](lib/rubocop/cop/github/accessibility), and contain examples/documentation.
All cops are located under [`lib/rubocop/cop/github`](lib/rubocop/cop/github).
6 changes: 3 additions & 3 deletions STYLEGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,8 @@ hsh = {
[Keyword arguments](http://magazine.rubyist.net/?Ruby200SpecialEn-kwarg) are recommended but not required when a method's arguments may otherwise be opaque or non-obvious when called. Additionally, prefer them over the old "Hash as pseudo-named args" style from pre-2.0 ruby.
<a name="keyword-arguments"></a><sup>[[link](#keyword-arguments)]</sup>
``` ruby
So instead of this:
``` ruby
def remove_member(user, skip_membership_check=false)
# ...
Expand All @@ -430,7 +429,8 @@ end
remove_member(user, true)
```
Do this, which is much clearer.
Do this, which is much clearer:
``` ruby
def remove_member(user, skip_membership_check: false)
# ...
Expand Down
Loading

0 comments on commit 2ab6fce

Please sign in to comment.