standard 0.0.31
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of standard might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/.circleci/config.yml +35 -0
- data/.gitignore +8 -0
- data/.standard.yml +4 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +58 -0
- data/LICENSE.txt +24 -0
- data/README.md +351 -0
- data/Rakefile +12 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/base.yml +1053 -0
- data/config/ruby-1.8.yml +8 -0
- data/config/ruby-1.9.yml +4 -0
- data/config/ruby-2.2.yml +8 -0
- data/exe/standardrb +7 -0
- data/lib/standard/builds_config.rb +26 -0
- data/lib/standard/cli.rb +23 -0
- data/lib/standard/cop/semantic_blocks.rb +162 -0
- data/lib/standard/creates_config_store/assigns_rubocop_yaml.rb +26 -0
- data/lib/standard/creates_config_store/configures_ignored_paths.rb +45 -0
- data/lib/standard/creates_config_store/sets_target_ruby_version.rb +25 -0
- data/lib/standard/creates_config_store.rb +23 -0
- data/lib/standard/detects_fixability.rb +20 -0
- data/lib/standard/file_finder.rb +13 -0
- data/lib/standard/formatter.rb +79 -0
- data/lib/standard/loads_runner.rb +9 -0
- data/lib/standard/loads_yaml_config.rb +60 -0
- data/lib/standard/merges_settings.rb +64 -0
- data/lib/standard/parses_cli_option.rb +21 -0
- data/lib/standard/railtie.rb +11 -0
- data/lib/standard/rake.rb +26 -0
- data/lib/standard/rubocop/ext.rb +7 -0
- data/lib/standard/runners/help.rb +44 -0
- data/lib/standard/runners/rubocop.rb +36 -0
- data/lib/standard/runners/version.rb +9 -0
- data/lib/standard/version.rb +3 -0
- data/lib/standard.rb +13 -0
- data/standard.gemspec +29 -0
- metadata +179 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3322ef40bfacdfb8809489a06622b4caf65ede63427bcd7c9cdee46b9da6254a
|
4
|
+
data.tar.gz: 0aa9f53432d038f168a26b9ff161d5cc3bb9318cde9c8696c8eb5ecd9d667046
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5a4185412bbc079c7c7635fb4641e2aae953b726ceffae79a1d694322e374e5c8c8d664aa42e1d4e536a6ccaba711c138f723fdbe5251ce84e1a04f764585734
|
7
|
+
data.tar.gz: ab6df22ce52ba06017824b5c70839f1a29ca8eddd2d549e05018b814d9826f31eff225ecc58118f4c9e3bcf5933f18aadcd6ac5b46007a4e0ce185fba6d04468
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Ruby CircleCI 2.0 configuration file
|
2
|
+
#
|
3
|
+
# Check https://circleci.com/docs/2.0/language-ruby/ for more details
|
4
|
+
#
|
5
|
+
version: 2
|
6
|
+
jobs:
|
7
|
+
build:
|
8
|
+
docker:
|
9
|
+
- image: circleci/ruby:2.4.1-node-browsers
|
10
|
+
working_directory: ~/repo
|
11
|
+
|
12
|
+
steps:
|
13
|
+
- checkout
|
14
|
+
- restore_cache:
|
15
|
+
keys:
|
16
|
+
- v1-dependencies-{{ checksum "Gemfile.lock" }}
|
17
|
+
- v1-dependencies-
|
18
|
+
|
19
|
+
- run:
|
20
|
+
name: install dependencies
|
21
|
+
command: |
|
22
|
+
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
23
|
+
|
24
|
+
- save_cache:
|
25
|
+
paths:
|
26
|
+
- ./vendor/bundle
|
27
|
+
key: v1-dependencies-{{ checksum "Gemfile.lock" }}
|
28
|
+
|
29
|
+
- run:
|
30
|
+
name: test
|
31
|
+
command: bundle exec rake test
|
32
|
+
|
33
|
+
- run:
|
34
|
+
name: lint
|
35
|
+
command: bundle exec rake standard:fix
|
data/.gitignore
ADDED
data/.standard.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
standard (0.0.31)
|
5
|
+
rubocop (>= 0.63)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ast (2.4.0)
|
11
|
+
coderay (1.1.2)
|
12
|
+
docile (1.3.1)
|
13
|
+
gimme (0.5.0)
|
14
|
+
jaro_winkler (1.5.2)
|
15
|
+
json (2.1.0)
|
16
|
+
method_source (0.9.2)
|
17
|
+
minitest (5.11.3)
|
18
|
+
parallel (1.13.0)
|
19
|
+
parser (2.6.0.0)
|
20
|
+
ast (~> 2.4.0)
|
21
|
+
powerpack (0.1.2)
|
22
|
+
pry (0.12.2)
|
23
|
+
coderay (~> 1.1.0)
|
24
|
+
method_source (~> 0.9.0)
|
25
|
+
psych (3.1.0)
|
26
|
+
rainbow (3.0.0)
|
27
|
+
rake (12.3.2)
|
28
|
+
rubocop (0.65.0)
|
29
|
+
jaro_winkler (~> 1.5.1)
|
30
|
+
parallel (~> 1.10)
|
31
|
+
parser (>= 2.5, != 2.5.1.1)
|
32
|
+
powerpack (~> 0.1)
|
33
|
+
psych (>= 3.1.0)
|
34
|
+
rainbow (>= 2.2.2, < 4.0)
|
35
|
+
ruby-progressbar (~> 1.7)
|
36
|
+
unicode-display_width (~> 1.4.0)
|
37
|
+
ruby-progressbar (1.10.0)
|
38
|
+
simplecov (0.16.1)
|
39
|
+
docile (~> 1.1)
|
40
|
+
json (>= 1.8, < 3)
|
41
|
+
simplecov-html (~> 0.10.0)
|
42
|
+
simplecov-html (0.10.2)
|
43
|
+
unicode-display_width (1.4.1)
|
44
|
+
|
45
|
+
PLATFORMS
|
46
|
+
ruby
|
47
|
+
|
48
|
+
DEPENDENCIES
|
49
|
+
bundler (~> 1.17)
|
50
|
+
gimme
|
51
|
+
minitest (~> 5.0)
|
52
|
+
pry
|
53
|
+
rake (~> 12.0)
|
54
|
+
simplecov
|
55
|
+
standard!
|
56
|
+
|
57
|
+
BUNDLED WITH
|
58
|
+
1.17.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Copyright (c) 2018 Test Double, LLC
|
2
|
+
|
3
|
+
Portions of these files Copyright (c) 2012-18 Bozhidar Batsov:
|
4
|
+
- config/base.yml
|
5
|
+
- lib/standard/cop/semantic_blocks.rb
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
8
|
+
a copy of this software and associated documentation files (the
|
9
|
+
"Software"), to deal in the Software without restriction, including
|
10
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
11
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
12
|
+
permit persons to whom the Software is furnished to do so, subject to
|
13
|
+
the following conditions:
|
14
|
+
|
15
|
+
The above copyright notice and this permission notice shall be
|
16
|
+
included in all copies or substantial portions of the Software.
|
17
|
+
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
20
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
22
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
23
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
24
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,351 @@
|
|
1
|
+
## Standard - Ruby style guide, linter, and formatter
|
2
|
+
|
3
|
+
[![CircleCI](https://circleci.com/gh/testdouble/standard.svg?style=svg)](https://circleci.com/gh/testdouble/standard)
|
4
|
+
[![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
|
5
|
+
|
6
|
+
This gem is a spiritual port of [StandardJS](https://standardjs.com) and aims
|
7
|
+
to save you (and others!) time in the same three ways:
|
8
|
+
|
9
|
+
* **No configuration.** The easiest way to enforce consistent style in your
|
10
|
+
project. Just drop it in.
|
11
|
+
* **Automatically format code.** Just run `standardrb --fix` and say goodbye to
|
12
|
+
messy or inconsistent code.
|
13
|
+
* **Catch style issues & programmer errors early.** Save precious code review
|
14
|
+
time by eliminating back-and-forth between reviewer & contributor.
|
15
|
+
|
16
|
+
No decisions to make. It just works. Here's a [⚡ lightning talk ⚡](https://www.youtube.com/watch?v=uLyV5hOqGQ8) about it.
|
17
|
+
|
18
|
+
Install by adding it to your Gemfile:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
gem "standard", group: [:development, :test]
|
22
|
+
```
|
23
|
+
|
24
|
+
And running `bundle install`.
|
25
|
+
|
26
|
+
Run Standard from the command line with:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
$ bundle exec standardrb
|
30
|
+
```
|
31
|
+
|
32
|
+
And if you'd like, Standard can autocorrect your code by tacking on a `--fix`
|
33
|
+
flag.
|
34
|
+
|
35
|
+
## StandardRB — The Rules
|
36
|
+
|
37
|
+
- **2 spaces** – for indentation
|
38
|
+
- **Double quotes for string literals** - because pre-committing to whether
|
39
|
+
you'll need interpolation in a string slows people down
|
40
|
+
- **1.9 hash syntax** - When all the keys in a hash literal are symbols,
|
41
|
+
Standard enforces Ruby 1.9's `{hash: syntax}`
|
42
|
+
- **Semantic blocks** - `{`/`}` for functional blocks that return a value, and
|
43
|
+
`do`/`end` for procedural blocks that have side effects. More
|
44
|
+
[here](http://www.virtuouscode.com/2011/07/26/the-procedurefunction-block-convention-in-ruby/)
|
45
|
+
and [here](https://github.com/rubocop-hq/ruby-style-guide/issues/162)
|
46
|
+
- **Leading dots on multi-line method chains** - chosen for
|
47
|
+
[these](https://github.com/testdouble/standard/issues/75) reasons.
|
48
|
+
- **And a good deal more**
|
49
|
+
|
50
|
+
If you're familiar with [RuboCop](https://github.com/rubocop-hq/rubocop), you
|
51
|
+
can look at Standard's current base configuration in
|
52
|
+
[config/base.yml](/config/base.yml).
|
53
|
+
|
54
|
+
**[NOTE: until StandardRB hits 1.0.0, we consider this configuration to be a
|
55
|
+
non-final work in progress and we encourage you to submit your opinions (and
|
56
|
+
reasoned arguments) for the addition, removal, or change to a rule by [opening
|
57
|
+
an issue](https://github.com/testdouble/standard/issues/new). If you start using
|
58
|
+
Standard, don't be shocked if things change a bit!]**
|
59
|
+
|
60
|
+
## Usage
|
61
|
+
|
62
|
+
Once you've installed Standard, you should be able to use the `standardrb`
|
63
|
+
program. The simplest use case would be checking the style of all Ruby
|
64
|
+
files in the current working directory:
|
65
|
+
|
66
|
+
```bash
|
67
|
+
$ bundle exec standardrb
|
68
|
+
standard: Use Ruby Standard Style (https://github.com/testdouble/standard)
|
69
|
+
standard: Run `standardrb --fix` to automatically fix some problems.
|
70
|
+
/Users/code/cli.rb:31:23: Style/Semicolon: Do not use semicolons to terminate expressions.
|
71
|
+
```
|
72
|
+
|
73
|
+
You can optionally pass in a directory (or directories) using the glob pattern. Be
|
74
|
+
sure to quote paths containing glob patterns so that they are expanded by
|
75
|
+
`standardrb` instead of your shell:
|
76
|
+
|
77
|
+
```bash
|
78
|
+
$ bundle exec standardrb "lib/**/*.rb" test
|
79
|
+
```
|
80
|
+
|
81
|
+
**Note:** by default, StandardRB will look for all `*.rb` files (and some other
|
82
|
+
files typically associated with Ruby like `*.gemspec` and `Gemfile`)
|
83
|
+
|
84
|
+
### Using with Rake
|
85
|
+
|
86
|
+
Standard also ships with Rake tasks. If you're using Rails, these should
|
87
|
+
autoload and be available after installing Standard. Otherwise, just require the
|
88
|
+
tasks in your `Rakefile`:
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
require "standard/rake"
|
92
|
+
```
|
93
|
+
|
94
|
+
Here are the tasks bundled with Standard:
|
95
|
+
|
96
|
+
```
|
97
|
+
$ rake standard # equivalent to running `standardrb`
|
98
|
+
$ rake standard:fix # equivalent to running `standardrb --fix`
|
99
|
+
```
|
100
|
+
|
101
|
+
You may also pass command line options to Standard's Rake tasks by embedding
|
102
|
+
them in a `STANDARDOPTS` environment variable (similar to how the Minitest Rake
|
103
|
+
task accepts CLI options in `TESTOPTS`).
|
104
|
+
|
105
|
+
```
|
106
|
+
# equivalent to `standardrb --format progress`:
|
107
|
+
$ rake standard STANDARDOPTS="--format progress"
|
108
|
+
|
109
|
+
# equivalent to `standardrb lib "app/**/*"`, to lint just certain paths:
|
110
|
+
$ rake standard STANDARDOPTS="lib \"app/**/*\""
|
111
|
+
```
|
112
|
+
|
113
|
+
## What you might do if you're clever
|
114
|
+
|
115
|
+
If you want or need to configure Standard, there are a _handful_ of options
|
116
|
+
are available creating a `.standard.yml` file in the root of your project.
|
117
|
+
|
118
|
+
Here's an example yaml file with every option set:
|
119
|
+
|
120
|
+
```yaml
|
121
|
+
fix: true # default: false
|
122
|
+
parallel: true # default: false
|
123
|
+
format: progress # default: Standard::Formatter
|
124
|
+
ruby_version: 2.3.3 # default: RUBY_VERSION
|
125
|
+
default_ignores: false # default: true
|
126
|
+
|
127
|
+
ignore: # default: []
|
128
|
+
- 'db/schema.rb'
|
129
|
+
- 'vendor/**/*'
|
130
|
+
- 'test/**/*':
|
131
|
+
- Layout/AlignHash
|
132
|
+
```
|
133
|
+
|
134
|
+
Note: If you're running Standard in a context where your `.standard.yml` file
|
135
|
+
cannot be found by ascending the current working directory (i.e. against a
|
136
|
+
temporary file buffer in your editor), you can specify the config location with
|
137
|
+
`--config path/to/.standard.yml`.
|
138
|
+
|
139
|
+
## What you might do if you're REALLY clever
|
140
|
+
|
141
|
+
Because StandardRB is essentially a wrapper on top of
|
142
|
+
[RuboCop](https://github.com/rubocop-hq/rubocop), it will actually forward the
|
143
|
+
vast majority of CLI and ENV arguments forward to RuboCop.
|
144
|
+
|
145
|
+
You can see a list of
|
146
|
+
[RuboCop](https://docs.rubocop.org/en/latest/basic_usage/#other-useful-command-line-flags)'s
|
147
|
+
CLI flags here.
|
148
|
+
|
149
|
+
## Why should I use Ruby Standard Style?
|
150
|
+
|
151
|
+
(This section will [look
|
152
|
+
familiar](https://github.com/standard/standard#why-should-i-use-javascript-standard-style)
|
153
|
+
if you've used StandardJS.)
|
154
|
+
|
155
|
+
The beauty of Ruby Standard Style is that it's simple. No one wants to
|
156
|
+
maintain multiple hundred-line style configuration files for every module/project
|
157
|
+
they work on. Enough of this madness!
|
158
|
+
|
159
|
+
This gem saves you (and others!) time in three ways:
|
160
|
+
|
161
|
+
- **No configuration.** The easiest way to enforce consistent style in your
|
162
|
+
project. Just drop it in.
|
163
|
+
- **Automatically format code.** Just run `standardrb --fix` and say goodbye to
|
164
|
+
messy or inconsistent code.
|
165
|
+
- **Catch style issues & programmer errors early.** Save precious code review
|
166
|
+
time by eliminating back-and-forth between reviewer & contributor.
|
167
|
+
|
168
|
+
Adopting Standard style means ranking the importance of code clarity and
|
169
|
+
community conventions higher than personal style. This might not make sense for
|
170
|
+
100% of projects and development cultures, however open source can be a hostile
|
171
|
+
place for newbies. Setting up clear, automated contributor expectations makes a
|
172
|
+
project healthier.
|
173
|
+
|
174
|
+
## Who uses Ruby Standard Style?
|
175
|
+
|
176
|
+
(This section will not [look very
|
177
|
+
familiar](https://github.com/standard/standard#who-uses-javascript-standard-style)
|
178
|
+
if you've used StandardJS.)
|
179
|
+
|
180
|
+
* [Test Double](https://testdouble.com/agency)
|
181
|
+
* [Collective Idea](https://collectiveidea.com/)
|
182
|
+
* And that's about it so far!
|
183
|
+
|
184
|
+
If your team starts using Standard, [send a pull
|
185
|
+
request](https://github.com/testdouble/standard/edit/master/README.md) to let us
|
186
|
+
know!
|
187
|
+
|
188
|
+
## Is there a readme badge?
|
189
|
+
|
190
|
+
Yes! If you use Standard in your project, you can include one of these
|
191
|
+
badges in your readme to let people know that your code is using the StandardRB
|
192
|
+
style.
|
193
|
+
|
194
|
+
[![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
|
195
|
+
|
196
|
+
```md
|
197
|
+
[![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
|
198
|
+
```
|
199
|
+
|
200
|
+
## I disagree with rule X, can you change it?
|
201
|
+
|
202
|
+
**[NOTE: until StandardRB hits 1.0.0, the answer is yes! It just requires
|
203
|
+
[opening an issue](https://github.com/testdouble/standard/issues/new) and
|
204
|
+
convincing [@searls](https://twitter.com/searls) (the BDFNow) to make the
|
205
|
+
change.]**
|
206
|
+
|
207
|
+
No. The whole point of Standard is to save you time by avoiding
|
208
|
+
[bikeshedding](https://www.freebsd.org/doc/en/books/faq/misc.html#bikeshed-painting)
|
209
|
+
about code style. There are lots of debates online about tabs vs. spaces, etc.
|
210
|
+
that will never be resolved. These debates just distract from getting stuff
|
211
|
+
done. At the end of the day you have to 'just pick something', and that's the
|
212
|
+
whole philosophy of Standard -- its a bunch of sensible 'just pick something'
|
213
|
+
opinions. Hopefully, users see the value in that over defending their own
|
214
|
+
opinions.
|
215
|
+
|
216
|
+
Pro tip: Just use Standard and move on. There are actual real problems that
|
217
|
+
you could spend your time solving! :P
|
218
|
+
|
219
|
+
## Is there an automatic formatter?
|
220
|
+
|
221
|
+
Yes! You can use `standardrb --fix` to fix most issues automatically.
|
222
|
+
|
223
|
+
`standardrb --fix` is built into `standardrb` for maximum convenience. Most
|
224
|
+
problems are fixable, but some errors must be fixed manually.
|
225
|
+
|
226
|
+
## Can I override the `fix: true` config setting?
|
227
|
+
|
228
|
+
Also yes! You can use `standardrb --no-fix`. Not `fix`ing is the default behavior, but this flag will override the `fix: true` setting in your [`.standard.yml` config](#what-you-might-do-if-youre-clever). This is especially useful for checking your projects compliance with `standardrb` in CI environments while keeping the `fix: true` option enabled locally.
|
229
|
+
|
230
|
+
## How do I ignore files?
|
231
|
+
|
232
|
+
Sometimes you need to ignore additional folders or specific minified files. To
|
233
|
+
do that, add a `.standard.yml` file to the root of your project and specify a
|
234
|
+
list of files and globs that should be excluded:
|
235
|
+
|
236
|
+
```yaml
|
237
|
+
ignore:
|
238
|
+
- 'some/file/in/particular.rb'
|
239
|
+
- 'a/whole/directory/**/*'
|
240
|
+
```
|
241
|
+
|
242
|
+
You can see the files Standard ignores by default
|
243
|
+
[here](https://github.com/testdouble/standard/blob/master/lib/standard/creates_config_store/configures_ignored_paths.rb#L3-L13)
|
244
|
+
|
245
|
+
## How do I hide a certain warning?
|
246
|
+
|
247
|
+
In rare cases, you'll need to break a rule and hide the warning generated by
|
248
|
+
Standard.
|
249
|
+
|
250
|
+
Ruby Standard Style uses [RuboCop](https://github.com/rubocop-hq/rubocop)
|
251
|
+
under-the-hood and you can hide warnings as you normally would if you used
|
252
|
+
RuboCop directly.
|
253
|
+
|
254
|
+
To ignore only certain rules from certain globs (not recommended, but maybe your
|
255
|
+
test suite uses a non-standardable DSL, you can specify an array of RuboCop
|
256
|
+
rules to ignore for a particular glob:
|
257
|
+
|
258
|
+
```yaml
|
259
|
+
ignore:
|
260
|
+
- 'test/**/*':
|
261
|
+
- Style/BlockDelimiters
|
262
|
+
```
|
263
|
+
|
264
|
+
You can also use special comments to disable all or certain rules within your
|
265
|
+
source code. See [RuboCop's
|
266
|
+
docs](https://docs.rubocop.org/en/latest/configuration/#disabling-cops-within-source-code)
|
267
|
+
for details.
|
268
|
+
|
269
|
+
## How do I specify a Ruby version? What is supported?
|
270
|
+
|
271
|
+
Because Standard wraps RuboCop, they share the same [runtime
|
272
|
+
requirements](https://github.com/rubocop-hq/rubocop#compatibility)—currently,
|
273
|
+
that's MRI 2.2 and newer. While Standard can't avoid this runtime requirement,
|
274
|
+
it does allow you to lint codebases that target Ruby versions older than 2.2 by
|
275
|
+
narrowing the ruleset somewhat.
|
276
|
+
|
277
|
+
Standard will default to telling RuboCop to target the currently running version
|
278
|
+
of Ruby (by inspecting `RUBY_VERSION` at runtime. But if you want to lock it
|
279
|
+
down, you can specify `ruby_version` in `.standard.yml`.
|
280
|
+
|
281
|
+
```
|
282
|
+
ruby_version: 1.8.7
|
283
|
+
```
|
284
|
+
|
285
|
+
See
|
286
|
+
[testdouble/suture](https://github.com/testdouble/suture/blob/master/.standard.yml)
|
287
|
+
for an example.
|
288
|
+
|
289
|
+
It's a little confusing to consider, but the targeted Ruby version for linting
|
290
|
+
may or may not match the version of the runtime (suppose you're on Ruby 2.5.1,
|
291
|
+
but your library supports Ruby 2.2.0). In this case, specify `ruby_version` and
|
292
|
+
you should be okay. However, note that if you target a _newer_ Ruby version than
|
293
|
+
the runtime, RuboCop may behave in surprising or inconsistent ways.
|
294
|
+
|
295
|
+
If you are targeting a Ruby older than 2.2 and run into an issue, check out
|
296
|
+
Standard's [version-specific RuboCop
|
297
|
+
configurations](https://github.com/testdouble/standard/tree/master/config) and
|
298
|
+
consider helping out by submitting a pull request if you find a rule that won't
|
299
|
+
work for older Rubies.
|
300
|
+
|
301
|
+
## How do I change the output?
|
302
|
+
|
303
|
+
Standard's built-in formatter is intentionally minimal, printing only unfixed
|
304
|
+
failures or (when successful) printing nothing at all. If you'd like to use a
|
305
|
+
different formatter, you can specify any of RuboCop's built-in formatters or
|
306
|
+
write your own.
|
307
|
+
|
308
|
+
For example, if you'd like to see colorful progress dots, you can either run
|
309
|
+
Standard with:
|
310
|
+
|
311
|
+
```
|
312
|
+
$ bundle exec standardrb --format progress
|
313
|
+
Inspecting 15 files
|
314
|
+
...............
|
315
|
+
|
316
|
+
15 files inspected, no offenses detected
|
317
|
+
```
|
318
|
+
|
319
|
+
Or, in your project's `.standard.yml` file, specify:
|
320
|
+
|
321
|
+
```yaml
|
322
|
+
format: progress
|
323
|
+
```
|
324
|
+
|
325
|
+
Refer to RuboCop's [documentation on
|
326
|
+
formatters](https://rubocop.readthedocs.io/en/latest/formatters/) for more
|
327
|
+
information.
|
328
|
+
|
329
|
+
## How do I run standard in my editor?
|
330
|
+
|
331
|
+
It can be very handy to know about failures while editing to shorten the
|
332
|
+
feedback loop. Some editors support asynchronously running linters.
|
333
|
+
|
334
|
+
### Vim
|
335
|
+
|
336
|
+
Install [ale](https://github.com/w0rp/ale). And add these lines to your `.vimrc`
|
337
|
+
file.
|
338
|
+
|
339
|
+
```vimscript
|
340
|
+
let g:ale_linters = {'ruby': ['standardrb']}
|
341
|
+
let g:ale_fixers = {'ruby': ['standardrb']}
|
342
|
+
```
|
343
|
+
|
344
|
+
This sets Standard as your only linter and fixer for Ruby files and so
|
345
|
+
prevents conflicts with RuboCop. For automatic fixing on save, add
|
346
|
+
this to your `.vimrc`:
|
347
|
+
|
348
|
+
```
|
349
|
+
let g:ale_fix_on_save = 1
|
350
|
+
```
|
351
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
require_relative "lib/standard/rake"
|
4
|
+
|
5
|
+
Rake::TestTask.new(:test) do |t|
|
6
|
+
t.warning = false
|
7
|
+
t.libs << "test"
|
8
|
+
t.libs << "lib"
|
9
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
10
|
+
end
|
11
|
+
|
12
|
+
task default: [:test, "standard:fix"]
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "standard"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|