A Ruby static code analyzer and formatter, based on the community Ruby style guide.
koic and bbatsov [Fix #6305] Fix infinite loop for `Layout/EmptyLinesAroundAccessModif…
…ier`

Fixes #6305.

This is a problem that occurs after #6236.

This PR fixes infinite loop for `Layout/EmptyLinesAroundAccessModifier`
and `Layout/EmptyLinesAroundClassBody` when specifying a superclass
that breaks the line.

```ruby
class AVerryLongClassNameDoYouLikeIt <
  ItEvenInheritsFromALongClassNameSOINeedToAddALineBrake

  protected

  def foobar
  end
end
```

With this PR, `Layout/EmptyLinesAroundAccessModifier` cop makes
aware of the above case that specifying a superclass that
breaks the line. This is the same behavior as writing a class
definition on a single line.

As a result, `Layout/EmptyLinesAroundAccessModifier` and
`Layout/EmptyLinesAroundClassBody` will not conflict with
the handling of empty line under the class definition.

This problem was caused by using the regular expression
in `EmptyLinesAroundAccessModifier#class_def?` method.
This PR will change it to use AST.
Latest commit fce51ea Sep 19, 2018
Permalink
Failed to load latest commit information.
.circleci Documentation checks only need to run once Sep 12, 2018
.github Deprecate duplicated rake tasks Sep 11, 2018
assets Change organization URL to rubocop-hq May 31, 2018
bin Add `bin/setup` script to bin dir Jun 17, 2018
config Disable `Style/DateTime` by default Sep 8, 2018
exe Move bindir from bin direcotry to exe directory May 22, 2018
lib [Fix #6305] Fix infinite loop for `Layout/EmptyLinesAroundAccessModif… Sep 19, 2018
logo [Fix #578] Add a logo Sep 4, 2014
manual Cut 0.59.1 Sep 15, 2018
relnotes Cut 0.59.1 Sep 15, 2018
spec [Fix #6305] Fix infinite loop for `Layout/EmptyLinesAroundAccessModif… Sep 19, 2018
tasks Fix an error when executing default rake task with `SpecRunner` Sep 15, 2018
.editorconfig Add an `.editorconfig` file (#3748) Dec 1, 2016
.gitattributes Change merge driver for CHANGELOG.md to resolve conflict problem Oct 11, 2016
.gitignore Ignore .ruby-version file in git management Jan 17, 2018
.rspec Specify `--require spec_helper` in .rspec Mar 1, 2017
.rubocop.yml [Fix #5973] Add Style/IpAddresses cop Jun 19, 2018
.rubocop_todo.yml Remove unneeded $stderr capturing Sep 11, 2018
.simplecov Generate code coverage report on all spec runs Sep 11, 2018
.travis.yml All Travis tasks are performed also in Circle now Sep 12, 2018
.yardopts Hide void return of methods in YARD documentation Jun 10, 2013
CHANGELOG.md [Fix #6305] Fix infinite loop for `Layout/EmptyLinesAroundAccessModif… Sep 19, 2018
CONTRIBUTING.md Change the URL of "About pull requests" [ci skip] Jun 8, 2018
Gemfile Generate code coverage report on all spec runs Sep 11, 2018
LICENSE.txt Bump license year for 2018 Jan 11, 2018
README.md Cut 0.59.1 Sep 15, 2018
Rakefile Generate code coverage report on all spec runs Sep 11, 2018
appveyor.yml Documentation checks only need to run once Sep 12, 2018
mkdocs.yml Enable the admonition markdown extension Jun 17, 2018
readthedocs.yml Tell Read the Docs to build downloadable docs (#5563) Feb 16, 2018
rubocop.gemspec [Fix #6092] Don't use the broken parser 2.5.1.1 version Jul 10, 2018

README.md

Gem Version CircleCI Status AppVeyor Status Coverage Status Code Climate Inline docs SemVer

Patreon Liberapay OpenCollective OpenCollective

RuboCop Logo

Role models are important.
-- Officer Alex J. Murphy / RoboCop

RuboCop is a Ruby static code analyzer and code formatter. Out of the box it will enforce many of the guidelines outlined in the community Ruby Style Guide.

RuboCop is extremely flexible and most aspects of its behavior can be tweaked via various configuration options.

Apart from reporting problems in your code, RuboCop can also automatically fix some of the problems for you.

Gitter

Please consider supporting financially its ongoing development.

Installation

RuboCop's installation is pretty standard:

$ gem install rubocop

If you'd rather install RuboCop using bundler, don't require it in your Gemfile:

gem 'rubocop', require: false

RuboCop's development is moving at a very rapid pace and there are often backward-incompatible changes between minor releases (since we haven't reached version 1.0 yet). To prevent an unwanted RuboCop update you might want to use a conservative version locking in your Gemfile:

gem 'rubocop', '~> 0.59.1', require: false

Quickstart

Just type rubocop in a Ruby project's folder and watch the magic happen.

$ cd my/cool/ruby/project
$ rubocop

Official manual

You can read a ton more about RuboCop in its official manual.

Compatibility

RuboCop supports the following Ruby implementations:

  • MRI 2.2+
  • JRuby 9.0+

The Rails cops support the following versions:

  • Rails 4.0+

Team

Here's a list of RuboCop's core developers:

Logo

RuboCop's logo was created by Dimiter Petrov. You can find the logo in various formats here.

The logo is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

Contributors

Here's a list of all the people who have contributed to the development of RuboCop.

I'm extremely grateful to each and every one of them!

If you'd like to contribute to RuboCop, please take the time to go through our short contribution guidelines.

Converting more of the Ruby Style Guide into RuboCop cops is our top priority right now. Writing a new cop is a great way to dive into RuboCop!

Of course, bug reports and suggestions for improvements are always welcome. GitHub pull requests are even better! :-)

Funding

While RuboCop is free software and will always be, the project would benefit immensely from some funding. Raising a monthly budget of a couple of thousand dollars would make it possible to pay people to work on certain complex features, fund other development related stuff (e.g. hardware, conference trips) and so on. Raising a monthly budget of over $5000 would open the possibility of someone working full-time on the project which would speed up the pace of development significantly.

We welcome both individual and corporate sponsors! We also offer a wide array of funding channels to account for your preferences (although currently Open Collective is our preferred funding platform).

If you're working in a company that's making significant use of RuboCop we'd appreciate it if you suggest to your company to become a RuboCop sponsor.

You can support the development of RuboCop via Salt, Patreon, Liberapay, and Open Collective.

Open Collective Backers

Support us with a monthly donation and help us continue our activities. [Become a backer]

Open Collective Sponsors

Become a sponsor and get your logo on our README on GitHub with a link to your site. [Become a sponsor]

Changelog

RuboCop's changelog is available here.

Copyright

Copyright (c) 2012-2018 Bozhidar Batsov. See LICENSE.txt for further details.