standard-mkv 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/test.yml +27 -0
  3. data/.gitignore +9 -0
  4. data/.standard.yml +4 -0
  5. data/CHANGELOG.md +304 -0
  6. data/Gemfile +13 -0
  7. data/Gemfile.lock +64 -0
  8. data/LICENSE.txt +25 -0
  9. data/README.md +451 -0
  10. data/Rakefile +12 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/config/base.yml +1205 -0
  14. data/config/ruby-1.8.yml +7 -0
  15. data/config/ruby-1.9.yml +7 -0
  16. data/config/ruby-2.2.yml +5 -0
  17. data/config/ruby-2.3.yml +1 -0
  18. data/config/ruby-2.4.yml +4 -0
  19. data/config/ruby-2.5.yml +7 -0
  20. data/config/ruby-2.7.yml +7 -0
  21. data/docs/RELEASE.md +42 -0
  22. data/exe/standardrb +7 -0
  23. data/lib/standard/builds_config.rb +36 -0
  24. data/lib/standard/cli.rb +17 -0
  25. data/lib/standard/cop/block_single_line_braces.rb +96 -0
  26. data/lib/standard/creates_config_store/assigns_rubocop_yaml.rb +34 -0
  27. data/lib/standard/creates_config_store/configures_ignored_paths.rb +45 -0
  28. data/lib/standard/creates_config_store/sets_target_ruby_version.rb +25 -0
  29. data/lib/standard/creates_config_store.rb +23 -0
  30. data/lib/standard/detects_fixability.rb +16 -0
  31. data/lib/standard/file_finder.rb +13 -0
  32. data/lib/standard/formatter.rb +90 -0
  33. data/lib/standard/loads_runner.rb +9 -0
  34. data/lib/standard/loads_yaml_config.rb +59 -0
  35. data/lib/standard/merges_settings.rb +68 -0
  36. data/lib/standard/parses_cli_option.rb +21 -0
  37. data/lib/standard/railtie.rb +11 -0
  38. data/lib/standard/rake.rb +26 -0
  39. data/lib/standard/rubocop/ext.rb +16 -0
  40. data/lib/standard/runners/genignore.rb +44 -0
  41. data/lib/standard/runners/help.rb +45 -0
  42. data/lib/standard/runners/rubocop.rb +19 -0
  43. data/lib/standard/runners/version.rb +9 -0
  44. data/lib/standard/version.rb +3 -0
  45. data/lib/standard.rb +13 -0
  46. data/standard.gemspec +24 -0
  47. metadata +118 -0
data/README.md ADDED
@@ -0,0 +1,451 @@
1
+ ## Standard - Ruby style guide, linter, and formatter
2
+
3
+ [![Tests](https://github.com/testdouble/standard/workflows/Tests/badge.svg)](https://github.com/testdouble/standard/actions?query=workflow%3ATests)
4
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
5
+ [![Gem Version](https://badge.fury.io/rb/standard.svg)](https://rubygems.org/gems/standard)
6
+
7
+ This gem is a spiritual port of [StandardJS](https://standardjs.com) and aims
8
+ to save you (and others!) time in the same three ways:
9
+
10
+ * **No configuration.** The easiest way to enforce consistent style in your
11
+ project. Just drop it in.
12
+ * **Automatically format code.** Just run `standardrb --fix` and say goodbye to
13
+ messy or inconsistent code.
14
+ * **Catch style issues & programmer errors early.** Save precious code review
15
+ time by eliminating back-and-forth between reviewer & contributor.
16
+
17
+ No decisions to make. It just works. Here's a [⚡ lightning talk ⚡](https://www.youtube.com/watch?v=uLyV5hOqGQ8) about it.
18
+
19
+ Install by adding it to your Gemfile:
20
+
21
+ ```ruby
22
+ gem "standard", group: [:development, :test]
23
+ ```
24
+
25
+ And running `bundle install`.
26
+
27
+ Run Standard from the command line with:
28
+
29
+ ```ruby
30
+ $ bundle exec standardrb
31
+ ```
32
+
33
+ And if you'd like, Standard can autocorrect your code by tacking on a `--fix`
34
+ flag.
35
+
36
+ ## StandardRB — The Rules
37
+
38
+ - **2 spaces** – for indentation
39
+ - **Double quotes for string literals** - because pre-committing to whether
40
+ you'll need interpolation in a string slows people down
41
+ - **1.9 hash syntax** - When all the keys in a hash literal are symbols,
42
+ Standard enforces Ruby 1.9's `{hash: syntax}`
43
+ - **Braces for single-line blocks** - Require `{`/`}` for one-line blocks, but
44
+ allow either braces or `do`/`end` for multiline blocks. Like using `do`/`end`
45
+ for multiline blocks? Prefer `{`/`}` when chaining? A fan of expressing intent
46
+ with Jim Weirich's [semantic
47
+ block](http://www.virtuouscode.com/2011/07/26/the-procedurefunction-block-convention-in-ruby/)
48
+ approach? Standard lets you do you!
49
+ - **Leading dots on multi-line method chains** - chosen for
50
+ [these](https://github.com/testdouble/standard/issues/75) reasons.
51
+ - **Spaces inside blocks, but not hash literals** - In Ruby, the `{` and `}`
52
+ characters do a lot of heavy lifting. To visually distinguish hash literals
53
+ from blocks, Standard enforces that (like arrays), no leading or trailing
54
+ spaces be added to pad hashes
55
+ - **And a good deal more**
56
+
57
+ If you're familiar with [RuboCop](https://github.com/rubocop-hq/rubocop), you
58
+ can look at Standard's current base configuration in
59
+ [config/base.yml](/config/base.yml). In lieu of a separate changelog file,
60
+ significant changes to the configuration will be documented as [GitHub release
61
+ notes](https://github.com/testdouble/standard/releases).
62
+
63
+ ## Usage
64
+
65
+ Once you've installed Standard, you should be able to use the `standardrb`
66
+ program. The simplest use case would be checking the style of all Ruby
67
+ files in the current working directory:
68
+
69
+ ```bash
70
+ $ bundle exec standardrb
71
+ standard: Use Ruby Standard Style (https://github.com/testdouble/standard)
72
+ standard: Run `standardrb --fix` to automatically fix some problems.
73
+ /Users/code/cli.rb:31:23: Style/Semicolon: Do not use semicolons to terminate expressions.
74
+ ```
75
+
76
+ You can optionally pass in a directory (or directories) using the glob pattern. Be
77
+ sure to quote paths containing glob patterns so that they are expanded by
78
+ `standardrb` instead of your shell:
79
+
80
+ ```bash
81
+ $ bundle exec standardrb "lib/**/*.rb" test
82
+ ```
83
+
84
+ **Note:** by default, StandardRB will look for all `*.rb` files (and some other
85
+ files typically associated with Ruby like `*.gemspec` and `Gemfile`)
86
+
87
+ If you have an existing project but aren't ready to fix all the files yet you can
88
+ generate a todo file:
89
+
90
+ ```bash
91
+ $ bundle exec standardrb --generate-todo
92
+ ```
93
+
94
+ This will create a `.standard_todo.yml` that lists all the files that contain errors.
95
+ When you run Standard in the future it will ignore these files as if they lived under the
96
+ `ignore` section in the `.standard.yml` file.
97
+
98
+ As you refactor your existing project you can remove files from the list. You can
99
+ also regenerate the todo file at any time by re-running the above command.
100
+
101
+ ### Using with Rake
102
+
103
+ Standard also ships with Rake tasks. If you're using Rails, these should
104
+ autoload and be available after installing Standard. Otherwise, just require the
105
+ tasks in your `Rakefile`:
106
+
107
+ ```ruby
108
+ require "standard/rake"
109
+ ```
110
+
111
+ Here are the tasks bundled with Standard:
112
+
113
+ ```
114
+ $ rake standard # equivalent to running `standardrb`
115
+ $ rake standard:fix # equivalent to running `standardrb --fix`
116
+ ```
117
+
118
+ You may also pass command line options to Standard's Rake tasks by embedding
119
+ them in a `STANDARDOPTS` environment variable (similar to how the Minitest Rake
120
+ task accepts CLI options in `TESTOPTS`).
121
+
122
+ ```
123
+ # equivalent to `standardrb --format progress`:
124
+ $ rake standard STANDARDOPTS="--format progress"
125
+
126
+ # equivalent to `standardrb lib "app/**/*"`, to lint just certain paths:
127
+ $ rake standard STANDARDOPTS="lib \"app/**/*\""
128
+ ```
129
+
130
+ ## What you might do if you're clever
131
+
132
+ If you want or need to configure Standard, there are a _handful_ of options
133
+ available by creating a `.standard.yml` file in the root of your project.
134
+
135
+ Here's an example yaml file with every option set:
136
+
137
+ ```yaml
138
+ fix: true # default: false
139
+ parallel: true # default: false
140
+ format: progress # default: Standard::Formatter
141
+ ruby_version: 2.3.3 # default: RUBY_VERSION
142
+ default_ignores: false # default: true
143
+
144
+ ignore: # default: []
145
+ - 'db/schema.rb'
146
+ - 'vendor/**/*'
147
+ - 'test/**/*':
148
+ - Layout/AlignHash
149
+ ```
150
+
151
+ Note: If you're running Standard in a context where your `.standard.yml` file
152
+ cannot be found by ascending the current working directory (i.e., against a
153
+ temporary file buffer in your editor), you can specify the config location with
154
+ `--config path/to/.standard.yml`.
155
+
156
+ Similarly, for the `.standard_todo.yml` file, you can specify `--todo path/to/.standard_todo.yml`.
157
+
158
+ ## What you might do if you're REALLY clever
159
+
160
+ Because StandardRB is essentially a wrapper on top of
161
+ [RuboCop](https://github.com/rubocop-hq/rubocop), it will actually forward the
162
+ vast majority of CLI and ENV arguments to RuboCop.
163
+
164
+ You can see a list of
165
+ [RuboCop](https://docs.rubocop.org/rubocop/usage/basic_usage.html#command-line-flags)'s
166
+ CLI flags here.
167
+
168
+ ## Why should I use Ruby Standard Style?
169
+
170
+ (This section will [look
171
+ familiar](https://github.com/standard/standard#why-should-i-use-javascript-standard-style)
172
+ if you've used StandardJS.)
173
+
174
+ The beauty of Ruby Standard Style is that it's simple. No one wants to
175
+ maintain multiple hundred-line style configuration files for every module/project
176
+ they work on. Enough of this madness!
177
+
178
+ This gem saves you (and others!) time in three ways:
179
+
180
+ - **No configuration.** The easiest way to enforce consistent style in your
181
+ project. Just drop it in.
182
+ - **Automatically format code.** Just run `standardrb --fix` and say goodbye to
183
+ messy or inconsistent code.
184
+ - **Catch style issues & programmer errors early.** Save precious code review
185
+ time by eliminating back-and-forth between reviewer & contributor.
186
+
187
+ Adopting Standard style means ranking the importance of code clarity and
188
+ community conventions higher than personal style. This might not make sense for
189
+ 100% of projects and development cultures, however open source can be a hostile
190
+ place for newbies. Setting up clear, automated contributor expectations makes a
191
+ project healthier.
192
+
193
+ ## Who uses Ruby Standard Style?
194
+
195
+ (This section will not [look very
196
+ familiar](https://github.com/standard/standard#who-uses-javascript-standard-style)
197
+ if you've used StandardJS.)
198
+
199
+ * [Test Double](https://testdouble.com/agency)
200
+ * [Collective Idea](https://collectiveidea.com/)
201
+ * [Culture Foundry](https://www.culturefoundry.com/)
202
+ * [Evil Martians](https://evilmartians.com)
203
+ * [Rebase Interactive](https://www.rebaseinteractive.com/)
204
+ * [Hashrocket](https://hashrocket.com)
205
+ * [Brand New Box](https://brandnewbox.com)
206
+ * [Monterail](https://www.monterail.com)
207
+ * [Level UP Solutions](https://levups.com)
208
+ * [Honeybadger](https://www.honeybadger.io)
209
+ * [Amazon Web Services](https://aws.amazon.com/)
210
+ * [Envoy](https://www.envoy.com)
211
+ * [myRent](https://www.myrent.co.nz)
212
+ * [Renuo](https://www.renuo.ch/)
213
+ * [JetThoughts](https://www.jetthoughts.com/)
214
+ * [Oyster](https://www.oysterhr.com/)
215
+ * [Podia](https://www.podia.com/)
216
+ * [RubyCI](https://ruby.ci)
217
+ * [thoughtbot](https://thoughtbot.com/)
218
+ * And that's about it so far!
219
+
220
+ If your team starts using Standard, [send a pull
221
+ request](https://github.com/testdouble/standard/edit/main/README.md) to let us
222
+ know!
223
+
224
+ ## Is there a readme badge?
225
+
226
+ Yes! If you use Standard in your project, you can include one of these
227
+ badges in your readme to let people know that your code is using the StandardRB
228
+ style.
229
+
230
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
231
+
232
+ ```md
233
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
234
+ ```
235
+
236
+ ## I disagree with rule X, can you change it?
237
+
238
+ No. The whole point of Standard is to save you time by avoiding
239
+ [bikeshedding](https://www.freebsd.org/doc/en/books/faq/misc.html#bikeshed-painting)
240
+ about code style. There are lots of debates online about tabs vs. spaces, etc.
241
+ that will never be resolved. These debates just distract from getting stuff
242
+ done. At the end of the day you have to 'just pick something', and that's the
243
+ whole philosophy of Standard -- it's a bunch of sensible 'just pick something'
244
+ opinions. Hopefully, users see the value in that over defending their own
245
+ opinions.
246
+
247
+ Pro tip: Just use Standard and move on. There are actual real problems that
248
+ you could spend your time solving! :P
249
+
250
+ ## Is there an automatic formatter?
251
+
252
+ Yes! You can use `standardrb --fix` to fix most issues automatically.
253
+
254
+ `standardrb --fix` is built into `standardrb` for maximum convenience. Most
255
+ problems are fixable, but some errors must be fixed manually.
256
+
257
+ ## Can I override the `fix: true` config setting?
258
+
259
+ Also yes! You can use `standardrb --no-fix`. Not `fix`ing is the default
260
+ behavior, but this flag will override the `fix: true` setting in your
261
+ [`.standard.yml` config](#what-you-might-do-if-youre-clever).
262
+ This is especially useful for checking your project's compliance with
263
+ `standardrb` in CI environments while keeping the `fix: true` option enabled
264
+ locally.
265
+
266
+ ## How do I ignore files?
267
+
268
+ Sometimes you need to ignore additional folders or specific minified files. To
269
+ do that, add a `.standard.yml` file to the root of your project and specify a
270
+ list of files and globs that should be excluded:
271
+
272
+ ```yaml
273
+ ignore:
274
+ - 'some/file/in/particular.rb'
275
+ - 'a/whole/directory/**/*'
276
+ ```
277
+
278
+ You can see the files Standard ignores by default
279
+ [here](https://github.com/testdouble/standard/blob/main/lib/standard/creates_config_store/configures_ignored_paths.rb#L3-L13)
280
+
281
+ ## How do I hide a certain warning?
282
+
283
+ In rare cases, you'll need to break a rule and hide the warning generated by
284
+ Standard.
285
+
286
+ Ruby Standard Style uses [RuboCop](https://github.com/rubocop-hq/rubocop)
287
+ under-the-hood and you can hide warnings as you normally would if you used
288
+ RuboCop directly.
289
+
290
+ To ignore only certain rules from certain globs (not recommended, but maybe your
291
+ test suite uses a non-standardable DSL, you can specify an array of RuboCop
292
+ rules to ignore for a particular glob:
293
+
294
+ ```yaml
295
+ ignore:
296
+ - 'test/**/*':
297
+ - Layout/EndAlignment
298
+ ```
299
+
300
+ ## How do I disable a warning within my source code?
301
+
302
+ You can also use special comments to disable all or certain rules within your
303
+ source code.
304
+
305
+ Given this source listing `foo.rb`:
306
+
307
+ ```ruby
308
+ baz = 42
309
+ ```
310
+
311
+ Running `standard foo.rb` would fail:
312
+
313
+ ```
314
+ foo.rb:1:1: Lint/UselessAssignment: Useless assignment to variable - `baz`.
315
+ ```
316
+
317
+ If we wanted to make an exception, we could add the following comment:
318
+
319
+ ```ruby
320
+ baz = 42 # standard:disable Lint/UselessAssignment
321
+ ```
322
+
323
+ The comment directives (both `standard:disable` and `rubocop:disable`) will
324
+ suppress the error and Standard would succeed.
325
+
326
+ If, however, you needed to disable standard for multiple lines, you could use
327
+ open and closing directives like this:
328
+
329
+ ```ruby
330
+ # standard:disable Layout/IndentationWidth
331
+ def foo
332
+ 123
333
+ end
334
+ # standard:enable Layout/IndentationWidth
335
+ ```
336
+
337
+ And if you don't know or care which rule is being violated, you can also
338
+ substitute its name for "all". This line actually triggers three different
339
+ violations, so we can suppress them like this:
340
+
341
+ ```ruby
342
+ baz = ['a'].each do end # standard:disable all
343
+ ```
344
+
345
+ ## How do I specify a Ruby version? What is supported?
346
+
347
+ Because Standard wraps RuboCop, they share the same [runtime
348
+ requirements](https://github.com/rubocop-hq/rubocop#compatibility)—currently,
349
+ that's MRI 2.3 and newer. While Standard can't avoid this runtime requirement,
350
+ it does allow you to lint codebases that target Ruby versions older than 2.3 by
351
+ narrowing the ruleset somewhat.
352
+
353
+ Standard will default to telling RuboCop to target the currently running version
354
+ of Ruby (by inspecting `RUBY_VERSION` at runtime. But if you want to lock it
355
+ down, you can specify `ruby_version` in `.standard.yml`.
356
+
357
+ ```
358
+ ruby_version: 1.8.7
359
+ ```
360
+
361
+ See
362
+ [testdouble/suture](https://github.com/testdouble/suture/blob/main/.standard.yml)
363
+ for an example.
364
+
365
+ It's a little confusing to consider, but the targeted Ruby version for linting
366
+ may or may not match the version of the runtime (suppose you're on Ruby 2.5.1,
367
+ but your library supports Ruby 2.3.0). In this case, specify `ruby_version` and
368
+ you should be okay. However, note that if you target a _newer_ Ruby version than
369
+ the runtime, RuboCop may behave in surprising or inconsistent ways.
370
+
371
+ If you are targeting a Ruby older than 2.3 and run into an issue, check out
372
+ Standard's [version-specific RuboCop
373
+ configurations](https://github.com/testdouble/standard/tree/main/config) and
374
+ consider helping out by submitting a pull request if you find a rule that won't
375
+ work for older Rubies.
376
+
377
+ ## How do I change the output?
378
+
379
+ Standard's built-in formatter is intentionally minimal, printing only unfixed
380
+ failures or (when successful) printing nothing at all. If you'd like to use a
381
+ different formatter, you can specify any of RuboCop's built-in formatters or
382
+ write your own.
383
+
384
+ For example, if you'd like to see colorful progress dots, you can either run
385
+ Standard with:
386
+
387
+ ```
388
+ $ bundle exec standardrb --format progress
389
+ Inspecting 15 files
390
+ ...............
391
+
392
+ 15 files inspected, no offenses detected
393
+ ```
394
+
395
+ Or, in your project's `.standard.yml` file, specify:
396
+
397
+ ```yaml
398
+ format: progress
399
+ ```
400
+
401
+ Refer to RuboCop's [documentation on
402
+ formatters](https://rubocop.readthedocs.io/en/latest/formatters/) for more
403
+ information.
404
+
405
+ ## How do I run Standard in my editor?
406
+
407
+ It can be very handy to know about failures while editing to shorten the
408
+ feedback loop. Some editors support asynchronously running linters.
409
+
410
+ - [Atom](https://github.com/testdouble/standard/wiki/IDE:-Atom)
411
+ - [emacs (via flycheck)](https://github.com/julianrubisch/flycheck-standardrb)
412
+ - [RubyMine](https://www.jetbrains.com/help/ruby/rubocop.html#disable_rubocop)
413
+ - [vim (via ALE)](https://github.com/testdouble/standard/wiki/IDE:-vim)
414
+ - [VS Code](https://github.com/testdouble/standard/wiki/IDE:-vscode)
415
+
416
+ ## How do I use Standard with Rubocop extensions?
417
+
418
+ This is not officially supported by Standard. However, Evil Martians wrote up [a regularly updated guide](https://evilmartians.com/chronicles/rubocoping-with-legacy-bring-your-ruby-code-up-to-standard) on how to do so.
419
+
420
+ ## Does Standard work with [Insert other tool name here]?
421
+
422
+ Maybe! Start by searching the repository to see if there's an existing issue open for
423
+ the tool you're interested in. That aside, here are other known integrations aside
424
+ from editor plugins:
425
+
426
+ * [Code Climate](https://github.com/testdouble/standard/wiki/CI:-Code-Climate)
427
+ * [Pronto](https://github.com/julianrubisch/pronto-standardrb)
428
+ * [Spring](https://github.com/lakim/spring-commands-standard)
429
+ * [Guard](https://github.com/JodyVanden/guard-standardrb)
430
+ * [Danger](https://github.com/ashfurrow/danger-rubocop/)
431
+
432
+ ## Contributing
433
+
434
+ Follow the steps below to setup standard locally:
435
+
436
+ ```bash
437
+ $ git clone https://github.com/testdouble/standard
438
+ $ cd standard
439
+ $ gem install bundler # if working with ruby version below 2.6.0
440
+ $ bundle install
441
+ $ bundle exec rake # to run test suite
442
+ ```
443
+
444
+ ## Code of Conduct
445
+
446
+ This project follows Test Double's [code of
447
+ conduct](https://testdouble.com/code-of-conduct) for all community interactions,
448
+ including (but not limited to) one-on-one communications, public posts/comments,
449
+ code reviews, pull requests, and GitHub issues. If violations occur, Test Double
450
+ will take any action they deem appropriate for the infraction, up to and
451
+ including blocking a user from the organization's repositories.
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__)
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