standard 0.0.9

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5788b3d7faa24fa200cc0160cd28ae97301c024de0586d723886492374297271
4
+ data.tar.gz: 82a6f4144b37fdcbc8387909dc9900dfa178720fa8cc57f57a497ca8c1a970e9
5
+ SHA512:
6
+ metadata.gz: 186cb0e967861e7b4a7d0bd30aab75e0637fcab64d3e21470928e43f23b6bb1faad733ebc22470d9796d2d5549dd3c90282dd02cb957e7a6cdc1801220aecb57
7
+ data.tar.gz: c71a6b7e2c6a5bf9b9c8597c6951f7adb086ba9fadfbe057780ed397891cce4b479ed4b357d4c47fa293ff28e70a0e47cf2b079ee386ddce1f00b16cafa2b0cd
@@ -0,0 +1,31 @@
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: lint
31
+ command: bundle exec ./exe/standard --fix
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.standard.yml ADDED
@@ -0,0 +1,3 @@
1
+ ruby_version: 2.2.0
2
+ ignore:
3
+ - vendor/bundle
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,40 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ standard (0.0.9)
5
+ rubocop (>= 0.60)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.0)
11
+ jaro_winkler (1.5.1)
12
+ minitest (5.11.3)
13
+ parallel (1.12.1)
14
+ parser (2.5.3.0)
15
+ ast (~> 2.4.0)
16
+ powerpack (0.1.2)
17
+ rainbow (3.0.0)
18
+ rake (10.5.0)
19
+ rubocop (0.60.0)
20
+ jaro_winkler (~> 1.5.1)
21
+ parallel (~> 1.10)
22
+ parser (>= 2.5, != 2.5.1.1)
23
+ powerpack (~> 0.1)
24
+ rainbow (>= 2.2.2, < 4.0)
25
+ ruby-progressbar (~> 1.7)
26
+ unicode-display_width (~> 1.4.0)
27
+ ruby-progressbar (1.10.0)
28
+ unicode-display_width (1.4.0)
29
+
30
+ PLATFORMS
31
+ ruby
32
+
33
+ DEPENDENCIES
34
+ bundler (~> 1.17)
35
+ minitest (~> 5.0)
36
+ rake (~> 10.0)
37
+ standard!
38
+
39
+ BUNDLED WITH
40
+ 1.17.1
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,335 @@
1
+ ## Standard - Ruby style guide, linter, and formatter
2
+
3
+ This gem is a spiritual port of [StandardJS](https://standardjs.com) and aims
4
+ to save you (and others!) time in the same three ways:
5
+
6
+ * **No configuration.** The easiest way to enforce consistent style in your
7
+ project. Just drop it in.
8
+ * **Automatically format code.** Just run `standard --fix` and say goodbye to
9
+ messy or inconsistent code.
10
+ * **Catch style issues & programmer errors early.** Save precious code review
11
+ time by eliminating back-and-forth between reviewer & contributor.
12
+
13
+ No decisions to make. It just works.
14
+
15
+ Install by adding it to your Gemfile:
16
+
17
+ ```ruby
18
+ gem "standard", :group => [:development, :test]
19
+ ```
20
+
21
+ And running `bundle install`.
22
+
23
+ Run Standard from the command line with:
24
+
25
+ ```ruby
26
+ $ bundle exec standard
27
+ ```
28
+
29
+ And if you'd like, Standard can autocorrect your code by tacking on a `--fix`
30
+ flag.
31
+
32
+ ## StandardRB — The Rules
33
+
34
+ - **2 spaces** – for indentation
35
+ - **Double quotes for string literals** - because pre-committing to whether
36
+ you'll need interpolation in a string slows people down
37
+ - **1.9 hash syntax** - When all the keys in a hash literal are symbols,
38
+ Standard enforces Ruby 1.9's `{hash: syntax}`
39
+ - **Semantic blocks** - `{`/`}` for functional blocks that return a value, and
40
+ `do`/`end` for procedural blocks that have side effects. More
41
+ [here](http://www.virtuouscode.com/2011/07/26/the-procedurefunction-block-convention-in-ruby/)
42
+ and [here](https://github.com/rubocop-hq/ruby-style-guide/issues/162)
43
+ - **Trailing dots on multi-line method chains** - chosen because it makes
44
+ copying lines into a REPL easier
45
+ - **And a good deal more**
46
+
47
+ If you're familiar with [RuboCop](https://github.com/rubocop-hq/rubocop), you
48
+ can look at Standard's current base configuration in
49
+ [config/base.yml](/config/base.yml).
50
+
51
+ **[NOTE: until StandardRB hits 1.0.0, we consider this configuration to be a
52
+ non-final work in progress and we encourage you to submit your opinions (and
53
+ reasoned arguments) for the addition, removal, or change to a rule by [opening
54
+ an issue](https://github.com/testdouble/standard/issues/new). If you start using
55
+ Standard, don't be shocked if things change a bit!]**
56
+
57
+ ## Usage
58
+
59
+ Once you've installed `standard`, you should be able to use the `standard`
60
+ program. The simplest use case would be checking the style of all Ruby
61
+ files in the current working directory:
62
+
63
+ ```bash
64
+ $ bundle exec standard
65
+ standard: Use Ruby Standard Style (https://github.com/testdouble/standard)
66
+ standard: Run `standard --fix` to automatically fix some problems.
67
+ /Users/code/cli.rb:31:23: Style/Semicolon: Do not use semicolons to terminate expressions.
68
+ ```
69
+
70
+ You can optionally pass in a directory (or directories) using the glob pattern. Be
71
+ sure to quote paths containing glob patterns so that they are expanded by
72
+ `standard` instead of your shell:
73
+
74
+ ```bash
75
+ $ bundle exec standard "lib/**/*.rb" test
76
+ ```
77
+
78
+ **Note:** by default `standard` will look for all `*.rb` files (and some other
79
+ files typically associated with Ruby like `*.gemspec` and `Gemfile`)
80
+
81
+ ### Using with Rake
82
+
83
+ Standard also ships with Rake tasks. If you're using Rails, these should
84
+ autoload and be available after installing Standard. Otherwise, just require the
85
+ tasks in your `Rakefile`:
86
+
87
+ ```ruby
88
+ require "standard/rake"
89
+ ```
90
+
91
+ Here are the tasks bundled with Standard:
92
+
93
+ ```
94
+ $ rake standard # equivalent to running `standard`
95
+ $ rake standard:fix # equivalent to running `standard --fix`
96
+ ```
97
+
98
+ You may also pass command line options to Standard's Rake tasks by embedding
99
+ them in a `STANDARDOPTS` environment variable (similar to how the Minitest Rake
100
+ task accepts CLI options in `TESTOPTS`).
101
+
102
+ ```
103
+ # equivalent to `standard --format progress`:
104
+ $ rake standard STANDARDOPTS="--format progress"
105
+
106
+ # equivalent to `standard lib "app/**/*"`, to lint just certain paths:
107
+ $ rake standard STANDARDOPTS="lib \"app/**/*\""
108
+ ```
109
+
110
+ ## What you might do if you're clever
111
+
112
+ If you want or need to configure Standard, there are a _handful_ of options
113
+ are available creating a `.standard.yml` file in the root of your project.
114
+
115
+ Here's an example yaml file with every option set:
116
+
117
+ ```yaml
118
+ fix: true
119
+ parallel: true
120
+ format: progress
121
+ ruby_version: 2.3.3
122
+
123
+ ignore:
124
+ - 'db/schema.rb'
125
+ - 'vendor/bundle/**/*'
126
+ - 'test/**/*':
127
+ - Layout/AlignHash
128
+ ```
129
+
130
+ ## What you might do if you're REALLY clever
131
+
132
+ Because StandardRB is essentially a wrapper on top of
133
+ [RuboCop](https://github.com/rubocop-hq/rubocop), it will actually forward the
134
+ vast majority of CLI and ENV arguments forward to RuboCop.
135
+
136
+ You can see a list of
137
+ [RuboCop](https://docs.rubocop.org/en/latest/basic_usage/#other-useful-command-line-flags)'s
138
+ CLI flags here.
139
+
140
+ ## Why should I use Ruby Standard Style?
141
+
142
+ (This section will [look
143
+ familiar](https://github.com/standard/standard#why-should-i-use-javascript-standard-style)
144
+ if you've used StandardJS.)
145
+
146
+ The beauty of Ruby Standard Style is that it's simple. No one wants to
147
+ maintain multiple hundred-line style configuration files for every module/project
148
+ they work on. Enough of this madness!
149
+
150
+ This gem saves you (and others!) time in three ways:
151
+
152
+ - **No configuration.** The easiest way to enforce consistent style in your
153
+ project. Just drop it in.
154
+ - **Automatically format code.** Just run `standard --fix` and say goodbye to
155
+ messy or inconsistent code.
156
+ - **Catch style issues & programmer errors early.** Save precious code review
157
+ time by eliminating back-and-forth between reviewer & contributor.
158
+
159
+ Adopting `standard` style means ranking the importance of code clarity and
160
+ community conventions higher than personal style. This might not make sense for
161
+ 100% of projects and development cultures, however open source can be a hostile
162
+ place for newbies. Setting up clear, automated contributor expectations makes a
163
+ project healthier.
164
+
165
+ ## Who uses Ruby Standard Style?
166
+
167
+ (This section will not [look very
168
+ familiar](https://github.com/standard/standard#who-uses-javascript-standard-style)
169
+ if you've used StandardJS.)
170
+
171
+ * [Test Double](https://testdouble.com/agency)
172
+ * And that's about it so far!
173
+
174
+ ## What if I also have StandardJS installed?
175
+
176
+ **[Note: While StandardRB is pre-1.0.0, we are waiting for user feedback before
177
+ deciding whether to mitigate this issue through cleverness or eliminate it by
178
+ changing the bin name. Please comment on [this
179
+ issue](https://github.com/testdouble/standard/issues/3) if you run into a
180
+ real-world problem trying to run either type of Standard.]**
181
+
182
+ Because StandardRB and StandardJS (and perhaps future packages for other
183
+ languages) both ship with binaries named `standard`, having both installed
184
+ globally and then executing them from your PATH will—at the moment—run whichever
185
+ one is found earlier in the PATH.
186
+
187
+ Ambiguity is bad, but we're banking on the majority of JS users to run standard
188
+ from a [package script](https://docs.npmjs.com/misc/scripts) and the majority of
189
+ Ruby developers to run standard from a [Bundler
190
+ binstub](https://bundler.io/v1.10/bundle_binstubs.html) or [Rake
191
+ task](#using-with-rake).
192
+
193
+ For every other case, if you're using both standard programs, note that
194
+ StandardRB ships with a `standardrb` bin, and we have a [pull request
195
+ open](https://github.com/standard/standard/pull/1224) to StandardJS to add a
196
+ `standardjs` alias so that either program can be run without any ambiguity.
197
+
198
+ ## Is there a readme badge?
199
+
200
+ Yes! If you use `standard` in your project, you can include one of these badges
201
+ in your readme to let people know that your code is using the standard style.
202
+
203
+
204
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
205
+
206
+ ```md
207
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
208
+ ```
209
+
210
+ ## I disagree with rule X, can you change it?
211
+
212
+ **[NOTE: until StandardRB hits 1.0.0, the answer is yes! It just requires
213
+ [opening an issue](https://github.com/testdouble/standard/issues/new) and
214
+ convincing [@searls](https://twitter.com/searls) (the BDFNow) to make the
215
+ change.]**
216
+
217
+ No. The whole point of `standard` is to save you time by avoiding
218
+ [bikeshedding](https://www.freebsd.org/doc/en/books/faq/misc.html#bikeshed-painting)
219
+ about code style. There are lots of debates online about tabs vs. spaces, etc.
220
+ that will never be resolved. These debates just distract from getting stuff
221
+ done. At the end of the day you have to 'just pick something', and that's the
222
+ whole philosophy of `standard` -- its a bunch of sensible 'just pick something'
223
+ opinions. Hopefully, users see the value in that over defending their own
224
+ opinions.
225
+
226
+ Pro tip: Just use `standard` and move on. There are actual real problems that
227
+ you could spend your time solving! :P
228
+
229
+ ## Is there an automatic formatter?
230
+
231
+ Yes! You can use `standard --fix` to fix most issues automatically.
232
+
233
+ `standard --fix` is built into `standard` for maximum convenience. Most problems
234
+ are fixable, but some errors (like forgetting to handle errors) must be fixed
235
+ manually.
236
+
237
+ To save you time, `standard` outputs the message "`Run standard --fix to
238
+ automatically fix some problems`" when it detects problems that can be fixed
239
+ automatically.
240
+
241
+ ## How do I ignore files?
242
+
243
+ Sometimes you need to ignore additional folders or specific minified files. To
244
+ do that, add a `.standard.yml` file to the root of your project and specify a
245
+ list of files and globs that should be excluded:
246
+
247
+ ```yaml
248
+ ignore:
249
+ - 'db/schema.rb'
250
+ - 'vendor/bundle/**/*'
251
+ ```
252
+
253
+ ## How do I hide a certain warning?
254
+
255
+ In rare cases, you'll need to break a rule and hide the warning generated by
256
+ `standard`.
257
+
258
+ Ruby Standard Style uses [RuboCop](https://github.com/rubocop-hq/rubocop)
259
+ under-the-hood and you can hide warnings as you normally would if you used
260
+ RuboCop directly.
261
+
262
+ To ignore only certain rules from certain globs (not recommended, but maybe your
263
+ test suite uses a non-standardable DSL, you can specify an array of RuboCop
264
+ rules to ignore for a particular glob:
265
+
266
+ ```yaml
267
+ ignore:
268
+ - 'test/**/*':
269
+ - Style/BlockDelimiters
270
+ ```
271
+
272
+ You can also use special comments to disable all or certain rules within your
273
+ source code. See [RuboCop's
274
+ docs](https://docs.rubocop.org/en/latest/configuration/#disabling-cops-within-source-code)
275
+ for details.
276
+
277
+ ## How do I specify a Ruby version? What is supported?
278
+
279
+ Because Standard wraps RuboCop, they share the same [runtime
280
+ requirements](https://github.com/rubocop-hq/rubocop#compatibility)—currently,
281
+ that's MRI 2.2 and newer. While Standard can't avoid this runtime requirement,
282
+ it does allow you to lint codebases that target Ruby versions older than 2.2 by
283
+ narrowing the ruleset somewhat.
284
+
285
+ Standard will default to telling RuboCop to target the currently running version
286
+ of Ruby (by inspecting `RUBY_VERSION` at runtime. But if you want to lock it
287
+ down, you can specify `ruby_version` in `.standard.yml`.
288
+
289
+ ```
290
+ ruby_version: 1.8.7
291
+ ```
292
+
293
+ See
294
+ [testdouble/suture](https://github.com/testdouble/suture/blob/master/.standard.yml)
295
+ for an example.
296
+
297
+ It's a little confusing to consider, but the targeted Ruby version for linting
298
+ may or may not match the version of the runtime (suppose you're on Ruby 2.5.1,
299
+ but your library supports Ruby 2.2.0). In this case, specify `ruby_version` and
300
+ you should be okay. However, note that if you target a _newer_ Ruby version than
301
+ the runtime, RuboCop may behave in surprising or inconsistent ways.
302
+
303
+ If you are targeting a Ruby older than 2.2 and run into an issue, check out
304
+ Standard's [version-specific RuboCop
305
+ configurations](https://github.com/testdouble/standard/tree/master/config) and
306
+ consider helping out by submitting a pull request if you find a rule that won't
307
+ work for older Rubies.
308
+
309
+ ## How do I change the output?
310
+
311
+ Standard's built-in formatter is intentionally minimal, printing only unfixed
312
+ failures or (when successful) printing nothing at all. If you'd like to use a
313
+ different formatter, you can specify any of RuboCop's built-in formatters or
314
+ write your own.
315
+
316
+ For example, if you'd like to see colorful progress dots, you can either run
317
+ standard with:
318
+
319
+ ```
320
+ $ bundle exec standard --format progress
321
+ Inspecting 15 files
322
+ ...............
323
+
324
+ 15 files inspected, no offenses detected
325
+ ```
326
+
327
+ Or, in your project's `.standard.yml` file, specify:
328
+
329
+ ```yaml
330
+ format: progress
331
+ ```
332
+
333
+ Refer to RuboCop's [documentation on
334
+ formatters](https://rubocop.readthedocs.io/en/latest/formatters/) for more
335
+ information.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
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__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here