standard 1.21.0 → 1.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +2 -2
- data/README.md +47 -13
- data/lib/standard/creates_config_store/merges_user_config_extensions.rb +50 -0
- data/lib/standard/creates_config_store.rb +3 -0
- data/lib/standard/loads_runner.rb +17 -3
- data/lib/standard/loads_yaml_config.rb +2 -1
- data/lib/standard/merges_settings.rb +3 -1
- data/lib/standard/rubocop/ext.rb +9 -0
- data/lib/standard/runners/help.rb +1 -0
- data/lib/standard/runners/verbose_version.rb +14 -0
- data/lib/standard/version.rb +1 -1
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0be084d42bce81134fcc2055df53cd9a3b639814b7e64f91e3c2e05faa4675ce
|
4
|
+
data.tar.gz: f4c0f98c8b6597cbd136e2990f50767892ba2797d9b351ec8e3e277ff7d67910
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e9a9a9912071e338b36f0e4db34a8077c896fa6356d3ffa31a064a5ce7201d31a778895fbf051003640dcd92b837456202487c8b275236457063b451dc5c752
|
7
|
+
data.tar.gz: c4923a5c46669684793406b8dd70ce9b0d8f974fd280f846da920e018613e292ac235137254cb17b8c15ea8eebcf5da0c059602dce83a2b95df99f98760a6626
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.22.0
|
4
|
+
|
5
|
+
* Add `extend_config` option [#506](https://github.com/testdouble/standard/pull/506)
|
6
|
+
|
7
|
+
## 1.21.1
|
8
|
+
|
9
|
+
* Fix standard comment directives [#498](https://github.com/testdouble/standard/pull/498)
|
10
|
+
|
3
11
|
## 1.21.0
|
4
12
|
|
5
13
|
* Update rubocop-performance from 1.15.1 to [1.15.2](https://github.com/rubocop/rubocop-performance/releases/tag/v1.15.2)
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
standard (1.
|
4
|
+
standard (1.22.0)
|
5
5
|
language_server-protocol (~> 3.17.0.2)
|
6
6
|
rubocop (= 1.42.0)
|
7
7
|
rubocop-performance (= 1.15.2)
|
@@ -49,7 +49,7 @@ GEM
|
|
49
49
|
simplecov_json_formatter (~> 0.1)
|
50
50
|
simplecov-html (0.12.3)
|
51
51
|
simplecov_json_formatter (0.1.4)
|
52
|
-
unicode-display_width (2.4.
|
52
|
+
unicode-display_width (2.4.2)
|
53
53
|
|
54
54
|
PLATFORMS
|
55
55
|
ruby
|
data/README.md
CHANGED
@@ -215,9 +215,7 @@ inherit_gem:
|
|
215
215
|
|
216
216
|
## Who uses Ruby Standard Style?
|
217
217
|
|
218
|
-
|
219
|
-
familiar](https://github.com/standard/standard#who-uses-javascript-standard-style)
|
220
|
-
if you've used StandardJS.)
|
218
|
+
Here are a few examples of Ruby Standard-compliant teams & projects:
|
221
219
|
|
222
220
|
* [Test Double](https://testdouble.com/agency)
|
223
221
|
* [Amazon Web Services](https://aws.amazon.com/)
|
@@ -244,9 +242,7 @@ if you've used StandardJS.)
|
|
244
242
|
* [RubyCI](https://ruby.ci)
|
245
243
|
* [thoughtbot](https://thoughtbot.com/)
|
246
244
|
|
247
|
-
|
248
|
-
request](https://github.com/testdouble/standard/edit/main/README.md) to let us
|
249
|
-
know!
|
245
|
+
Does your team use Standard? [Add your name to the list](https://github.com/testdouble/standard/edit/main/README.md)!
|
250
246
|
|
251
247
|
## Is there a readme badge?
|
252
248
|
|
@@ -401,6 +397,51 @@ configurations](https://github.com/testdouble/standard/tree/main/config) and
|
|
401
397
|
consider helping out by submitting a pull request if you find a rule that won't
|
402
398
|
work for older Rubies.
|
403
399
|
|
400
|
+
## How do I use Standard with RuboCop extensions or custom rules?
|
401
|
+
|
402
|
+
If you want to use Standard in conjunction with RuboCop extensions or custom
|
403
|
+
cops, you can specify them in your own [RuboCop configuration
|
404
|
+
YAML](https://docs.rubocop.org/rubocop/configuration.html) files and
|
405
|
+
`.standard.yml` using the "extend_config:` setting:
|
406
|
+
|
407
|
+
```yml
|
408
|
+
# .standard.yml
|
409
|
+
extend_config:
|
410
|
+
- .betterlint.yml
|
411
|
+
```
|
412
|
+
|
413
|
+
Which in turn would refer to a RuboCop configuration file:
|
414
|
+
|
415
|
+
```yml
|
416
|
+
# .betterlint.yml
|
417
|
+
require:
|
418
|
+
- rubocop/cop/betterment.rb
|
419
|
+
|
420
|
+
AllCops:
|
421
|
+
DisabledByDefault: true
|
422
|
+
|
423
|
+
Betterment/UnscopedFind:
|
424
|
+
Enabled: true
|
425
|
+
|
426
|
+
unauthenticated_models:
|
427
|
+
- SystemConfiguration
|
428
|
+
```
|
429
|
+
|
430
|
+
When Standard runs, it will merge your configuration files with Standard's base
|
431
|
+
ruleset. To ensure that this feature does not result in Standard's rules being
|
432
|
+
modified, any configuration of rules includued in `rubocop` or
|
433
|
+
`rubocop-performance` will be ignored. Most settings under `AllCops:` can be
|
434
|
+
configured, unless they'd conflict with a setting used by Standard (like
|
435
|
+
`TargetRubyVersion`) or prevent Standard's own rules from running (like
|
436
|
+
`StyleGuideCopsOnly`). If you specify multiple YAML files under `extend_config`,
|
437
|
+
note that their resulting RuboCop configurations will be merged in order (i.e.
|
438
|
+
last-in-wins).
|
439
|
+
|
440
|
+
If you find that Standard's `extend_config` feature doesn't meet your needs,
|
441
|
+
Evil Martians also maintains [a regularly updated
|
442
|
+
guide](https://evilmartians.com/chronicles/rubocoping-with-legacy-bring-your-ruby-code-up-to-standard)
|
443
|
+
on how to configure RuboCop to load and execute Standard's ruleset.
|
444
|
+
|
404
445
|
## How do I change the output?
|
405
446
|
|
406
447
|
Standard's built-in formatter is intentionally minimal, printing only unfixed
|
@@ -492,13 +533,6 @@ either:
|
|
492
533
|
gem to your build, which will automatically ensure that the comment is
|
493
534
|
prepended for every applicable file in your project
|
494
535
|
|
495
|
-
## How do I use Standard with RuboCop extensions?
|
496
|
-
|
497
|
-
This is not officially supported by Standard. However, Evil Martians wrote up [a
|
498
|
-
regularly updated
|
499
|
-
guide](https://evilmartians.com/chronicles/rubocoping-with-legacy-bring-your-ruby-code-up-to-standard)
|
500
|
-
on how to do so.
|
501
|
-
|
502
536
|
## How often is Standard updated?
|
503
537
|
|
504
538
|
We aim to update Standard once a month, in the first week of the month. In between releases, we'll be considering RuboCop updates, RuboCop Performance updates, and community contributions.
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative "../file_finder"
|
2
|
+
|
3
|
+
class Standard::CreatesConfigStore
|
4
|
+
class MergesUserConfigExtensions
|
5
|
+
DISALLOWED_ALLCOPS_KEYS = [
|
6
|
+
"Include",
|
7
|
+
"Exclude",
|
8
|
+
"StyleGuideCopsOnly",
|
9
|
+
"TargetRubyVersion"
|
10
|
+
].freeze
|
11
|
+
|
12
|
+
def call(options_config, standard_config)
|
13
|
+
return unless standard_config[:extend_config]&.any?
|
14
|
+
|
15
|
+
extended_config = load_and_merge_extended_rubocop_configs(standard_config)
|
16
|
+
merge_standard_and_user_all_cops!(options_config, extended_config)
|
17
|
+
merge_extended_rules_into_standard!(options_config, extended_config)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def load_and_merge_extended_rubocop_configs(standard_config)
|
23
|
+
{
|
24
|
+
"AllCops" => {}
|
25
|
+
}.tap do |config|
|
26
|
+
standard_config[:extend_config].each do |path|
|
27
|
+
extension = RuboCop::ConfigLoader.load_file(Standard::FileFinder.new.call(path, Dir.pwd)).to_h
|
28
|
+
config["AllCops"].merge!(extension["AllCops"]) if extension.key?("AllCops")
|
29
|
+
config.merge!(except(extension, ["AllCops"]))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def merge_standard_and_user_all_cops!(options_config, extended_config)
|
35
|
+
options_config["AllCops"].merge!(
|
36
|
+
except(extended_config["AllCops"], DISALLOWED_ALLCOPS_KEYS)
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
def merge_extended_rules_into_standard!(options_config, extended_config)
|
41
|
+
except(extended_config, options_config.keys).each do |key, value|
|
42
|
+
options_config[key] = value
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def except(hash, keys)
|
47
|
+
hash.reject { |key, _| keys.include?(key) }.to_h
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -3,6 +3,7 @@ require "rubocop"
|
|
3
3
|
require_relative "creates_config_store/assigns_rubocop_yaml"
|
4
4
|
require_relative "creates_config_store/sets_target_ruby_version"
|
5
5
|
require_relative "creates_config_store/configures_ignored_paths"
|
6
|
+
require_relative "creates_config_store/merges_user_config_extensions"
|
6
7
|
|
7
8
|
module Standard
|
8
9
|
class CreatesConfigStore
|
@@ -10,6 +11,7 @@ module Standard
|
|
10
11
|
@assigns_rubocop_yaml = AssignsRubocopYaml.new
|
11
12
|
@sets_target_ruby_version = SetsTargetRubyVersion.new
|
12
13
|
@configures_ignored_paths = ConfiguresIgnoredPaths.new
|
14
|
+
@merges_user_config_extensions = MergesUserConfigExtensions.new
|
13
15
|
end
|
14
16
|
|
15
17
|
def call(standard_config)
|
@@ -17,6 +19,7 @@ module Standard
|
|
17
19
|
options_config = @assigns_rubocop_yaml.call(config_store, standard_config)
|
18
20
|
@sets_target_ruby_version.call(options_config, standard_config)
|
19
21
|
@configures_ignored_paths.call(options_config, standard_config)
|
22
|
+
@merges_user_config_extensions.call(options_config, standard_config)
|
20
23
|
end
|
21
24
|
end
|
22
25
|
end
|
@@ -1,9 +1,23 @@
|
|
1
|
+
require_relative "runners/rubocop"
|
2
|
+
require_relative "runners/version"
|
3
|
+
require_relative "runners/verbose_version"
|
4
|
+
require_relative "runners/lsp"
|
5
|
+
require_relative "runners/genignore"
|
6
|
+
require_relative "runners/help"
|
7
|
+
|
1
8
|
module Standard
|
2
9
|
class LoadsRunner
|
3
|
-
|
10
|
+
RUNNERS = {
|
11
|
+
rubocop: ::Standard::Runners::Rubocop,
|
12
|
+
version: ::Standard::Runners::Version,
|
13
|
+
verbose_version: ::Standard::Runners::VerboseVersion,
|
14
|
+
lsp: ::Standard::Runners::Lsp,
|
15
|
+
genignore: ::Standard::Runners::Genignore,
|
16
|
+
help: ::Standard::Runners::Help
|
17
|
+
}.freeze
|
18
|
+
|
4
19
|
def call(command)
|
5
|
-
|
6
|
-
::Standard::Runners.const_get(command.to_s.capitalize).new
|
20
|
+
RUNNERS[command].new
|
7
21
|
end
|
8
22
|
end
|
9
23
|
end
|
@@ -32,7 +32,8 @@ module Standard
|
|
32
32
|
default_ignores: standard_yaml.key?("default_ignores") ? !!standard_yaml["default_ignores"] : true,
|
33
33
|
config_root: yaml_path ? Pathname.new(yaml_path).dirname.to_s : nil,
|
34
34
|
todo_file: todo_path,
|
35
|
-
todo_ignore_files: (todo_yaml["ignore"]
|
35
|
+
todo_ignore_files: Array(todo_yaml["ignore"]).map { |f| (Hash === f) ? f.keys.first : f },
|
36
|
+
extend_config: Array(standard_yaml["extend_config"])
|
36
37
|
}
|
37
38
|
end
|
38
39
|
|
@@ -20,7 +20,7 @@ module Standard
|
|
20
20
|
|
21
21
|
def separate_argv(argv)
|
22
22
|
argv.partition do |flag|
|
23
|
-
["--generate-todo", "--fix", "--no-fix", "--version", "-v", "--help", "-h", "--lsp"].include?(flag)
|
23
|
+
["--generate-todo", "--fix", "--no-fix", "--version", "-v", "--verbose-version", "-V", "--help", "-h", "--lsp"].include?(flag)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -39,6 +39,8 @@ module Standard
|
|
39
39
|
:help
|
40
40
|
elsif (argv & ["--version", "-v"]).any?
|
41
41
|
:version
|
42
|
+
elsif (argv & ["--verbose-version", "-V"]).any?
|
43
|
+
:verbose_version
|
42
44
|
elsif (argv & ["--generate-todo"]).any?
|
43
45
|
:genignore
|
44
46
|
elsif (argv & ["--lsp"]).any?
|
data/lib/standard/rubocop/ext.rb
CHANGED
@@ -13,4 +13,13 @@ module RuboCop
|
|
13
13
|
.gsub(" ", '\s*')
|
14
14
|
)
|
15
15
|
end
|
16
|
+
|
17
|
+
class CommentConfig
|
18
|
+
alias_method :old_initialize, :initialize
|
19
|
+
|
20
|
+
def initialize(processed_source)
|
21
|
+
old_initialize(processed_source)
|
22
|
+
@no_directives &&= !processed_source.raw_source.include?("standard")
|
23
|
+
end
|
24
|
+
end
|
16
25
|
end
|
@@ -15,6 +15,7 @@ module Standard
|
|
15
15
|
--generate-todo Create a .standard_todo.yml that lists all the files that contain errors
|
16
16
|
--lsp Start a LSP server listening on STDIN
|
17
17
|
-v, --version Print the version of Standard
|
18
|
+
-V, --verbose-version Print the version of Standard and its dependencies.
|
18
19
|
-h, --help Print this message
|
19
20
|
FILE Files to lint [default: ./]
|
20
21
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative "rubocop"
|
2
|
+
|
3
|
+
module Standard
|
4
|
+
module Runners
|
5
|
+
class VerboseVersion
|
6
|
+
def call(config)
|
7
|
+
puts <<-MSG.gsub(/^ {10}/, "")
|
8
|
+
Standard version: #{Standard::VERSION}
|
9
|
+
RuboCop version: #{RuboCop::Version.version(debug: true)}
|
10
|
+
MSG
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/standard/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: standard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Searls
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 3.17.0.2
|
55
|
-
description:
|
55
|
+
description:
|
56
56
|
email:
|
57
57
|
- searls@gmail.com
|
58
58
|
executables:
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- lib/standard/creates_config_store.rb
|
96
96
|
- lib/standard/creates_config_store/assigns_rubocop_yaml.rb
|
97
97
|
- lib/standard/creates_config_store/configures_ignored_paths.rb
|
98
|
+
- lib/standard/creates_config_store/merges_user_config_extensions.rb
|
98
99
|
- lib/standard/creates_config_store/sets_target_ruby_version.rb
|
99
100
|
- lib/standard/detects_fixability.rb
|
100
101
|
- lib/standard/file_finder.rb
|
@@ -112,13 +113,14 @@ files:
|
|
112
113
|
- lib/standard/runners/help.rb
|
113
114
|
- lib/standard/runners/lsp.rb
|
114
115
|
- lib/standard/runners/rubocop.rb
|
116
|
+
- lib/standard/runners/verbose_version.rb
|
115
117
|
- lib/standard/runners/version.rb
|
116
118
|
- lib/standard/version.rb
|
117
119
|
- standard.gemspec
|
118
120
|
homepage: https://github.com/testdouble/standard
|
119
121
|
licenses: []
|
120
122
|
metadata: {}
|
121
|
-
post_install_message:
|
123
|
+
post_install_message:
|
122
124
|
rdoc_options: []
|
123
125
|
require_paths:
|
124
126
|
- lib
|
@@ -133,8 +135,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
135
|
- !ruby/object:Gem::Version
|
134
136
|
version: '0'
|
135
137
|
requirements: []
|
136
|
-
rubygems_version: 3.
|
137
|
-
signing_key:
|
138
|
+
rubygems_version: 3.3.26
|
139
|
+
signing_key:
|
138
140
|
specification_version: 4
|
139
141
|
summary: Ruby Style Guide, with linter & automatic code fixer
|
140
142
|
test_files: []
|