standard 0.0.13

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