1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
# RuboCop AST
[](https://badge.fury.io/rb/rubocop-ast)
[](https://github.com/rubocop-hq/rubocop-ast/actions?query=workflow%3ACI)
[](https://codeclimate.com/github/rubocop-hq/rubocop-ast/test_coverage)
[](https://codeclimate.com/github/rubocop-hq/rubocop-ast/maintainability)
Contains the classes needed by [RuboCop](https://github.com/rubocop-hq/rubocop) to deal with Ruby's AST, in particular:
* `RuboCop::AST::Node` ([doc](docs/modules/ROOT/pages/node_types.adoc))
* `RuboCop::AST::NodePattern` ([doc](docs/modules/ROOT/pages/node_pattern.adoc))
This gem may be used independently from the main RuboCop gem. It was extracted from RuboCop in version 0.84 and its only
dependency is the [parser](https://github.com/whitequark/parser) gem, which `rubocop-ast` extends.
## Installation
Just install the `rubocop-ast` gem
```sh
gem install rubocop-ast
```
or if you use bundler put this in your `Gemfile`
```ruby
gem 'rubocop-ast'
```
## Usage
Refer to the documentation of [`RuboCop::AST::Node`](docs/modules/ROOT/pages/node_types.adoc) and [`RuboCop::AST::NodePattern`](docs/modules/ROOT/pages/node_pattern.adoc)
See the [docs site](https://docs.rubocop.org/rubocop-ast) for more details.
### Parser compatibility switches
This gem, by default, uses most [legacy AST output from parser](https://github.com/whitequark/parser/#usage), except for `emit_forward_arg` which is set to `true`.
The main `RuboCop` gem uses these defaults (and is currently only compatible with these), but this gem can be used separately from `RuboCop` and is meant to be compatible with all settings. For example, to have `-> { ... }` emitted
as `LambdaNode` instead of `SendNode`:
```ruby
RuboCop::AST::Builder.emit_lambda = true
```
## Contributing
Checkout the [contribution guidelines](CONTRIBUTING.md).
## License
`rubocop-ast` is MIT licensed. [See the accompanying file](LICENSE.txt) for
the full text.
|