standard 1.25.5 → 1.27.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 +11 -0
- data/Gemfile.lock +6 -6
- data/README.md +12 -4
- data/config/base.yml +13 -16
- data/config/ruby-2.6.yml +3 -0
- data/config/ruby-3.0.yml +1 -1
- data/config/ruby-3.1.yml +7 -0
- data/lib/standard/builds_config.rb +3 -9
- data/lib/standard/formatter.rb +69 -48
- data/lib/standard/loads_yaml_config.rb +1 -1
- data/lib/standard/lsp/standardizer.rb +2 -2
- data/lib/standard/merges_settings.rb +7 -1
- data/lib/standard/rake.rb +8 -1
- data/lib/standard/{parses_cli_option.rb → resolves_yaml_option.rb} +8 -2
- data/lib/standard/runners/help.rb +2 -1
- data/lib/standard/runners/verbose_version.rb +1 -1
- data/lib/standard/version.rb +1 -1
- data/standard.gemspec +4 -1
- metadata +14 -11
- data/lib/standard/detects_fixability.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9da8591aa948bc0d345964c18383dc5213cbca194eca797075c1dbedf2e72e43
|
4
|
+
data.tar.gz: a6baa46440bb2658ef887f1ad678fd2a227d510f06790eb58e96679cca64a0e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed7269d761c076913f7581e231a1baa132eb47a32a8bc6c4f3998075cf66c0bb0706cab4d8c2cd5d6ec7000cb03964f4000ff46ea45ba9e07fce094489c57a95
|
7
|
+
data.tar.gz: 520f2681b77c15012227bf222462acae00c6b36b15fd16371694c8ef831e25a356bf548d8be34a45b271abc4f805c2b3975483d52ef3c06c85db849509388bf5
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.27.0
|
4
|
+
|
5
|
+
* Update rubocop from 1.48.1 to [1.50.2](https://github.com/rubocop/rubocop/releases/tag/v1.50.2)
|
6
|
+
* Enabled [Style/RedundantLineContinuation](https://docs.rubocop.org/rubocop/cops_style.html#styleredundantlinecontinuation)
|
7
|
+
|
8
|
+
## 1.26.0
|
9
|
+
|
10
|
+
* Introduce `--fix-unsafely` and `rake standard:fix_unsafely` for running
|
11
|
+
unsafe corrections. Improve output about fix suggestions, as well
|
12
|
+
[#545](https://github.com/testdouble/standard/pull/545)
|
13
|
+
|
3
14
|
## 1.25.5
|
4
15
|
|
5
16
|
* Temporarily disable registration of `executeCommand` to prevent conflict with
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
standard (1.
|
4
|
+
standard (1.27.0)
|
5
5
|
language_server-protocol (~> 3.17.0.2)
|
6
|
-
rubocop (~> 1.
|
6
|
+
rubocop (~> 1.50.2)
|
7
7
|
rubocop-performance (~> 1.16.0)
|
8
8
|
|
9
9
|
GEM
|
@@ -20,7 +20,7 @@ GEM
|
|
20
20
|
rake (>= 0.9.2.2)
|
21
21
|
method_source (1.0.0)
|
22
22
|
minitest (5.18.0)
|
23
|
-
parallel (1.
|
23
|
+
parallel (1.23.0)
|
24
24
|
parser (3.2.2.0)
|
25
25
|
ast (~> 2.4.1)
|
26
26
|
pry (0.14.2)
|
@@ -28,16 +28,16 @@ GEM
|
|
28
28
|
method_source (~> 1.0)
|
29
29
|
rainbow (3.1.1)
|
30
30
|
rake (13.0.6)
|
31
|
-
regexp_parser (2.
|
31
|
+
regexp_parser (2.8.0)
|
32
32
|
rexml (3.2.5)
|
33
|
-
rubocop (1.
|
33
|
+
rubocop (1.50.2)
|
34
34
|
json (~> 2.3)
|
35
35
|
parallel (~> 1.10)
|
36
36
|
parser (>= 3.2.0.0)
|
37
37
|
rainbow (>= 2.2.2, < 4.0)
|
38
38
|
regexp_parser (>= 1.8, < 3.0)
|
39
39
|
rexml (>= 3.2.5, < 4.0)
|
40
|
-
rubocop-ast (>= 1.
|
40
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
41
41
|
ruby-progressbar (~> 1.7)
|
42
42
|
unicode-display_width (>= 2.4.0, < 3.0)
|
43
43
|
rubocop-ast (1.28.0)
|
data/README.md
CHANGED
@@ -76,8 +76,8 @@ files in the current working directory:
|
|
76
76
|
```bash
|
77
77
|
$ bundle exec standardrb
|
78
78
|
standard: Use Ruby Standard Style (https://github.com/testdouble/standard)
|
79
|
-
standard: Run `standardrb --fix` to
|
80
|
-
/Users/code/cli.rb:31:23: Style/Semicolon: Do not use semicolons to terminate expressions.
|
79
|
+
standard: Run `standardrb --fix` to potentially fix one problem.
|
80
|
+
/Users/jill/code/cli.rb:31:23: Style/Semicolon: Do not use semicolons to terminate expressions.
|
81
81
|
```
|
82
82
|
|
83
83
|
You can optionally pass in a directory (or directories) using a glob pattern.
|
@@ -121,6 +121,7 @@ Here are the tasks bundled with Standard:
|
|
121
121
|
```
|
122
122
|
$ rake standard # equivalent to running `standardrb`
|
123
123
|
$ rake standard:fix # equivalent to running `standardrb --fix`
|
124
|
+
$ rake standard:fix_unsafely # equivalent to running `standardrb --fix-unsafely`
|
124
125
|
```
|
125
126
|
|
126
127
|
You may also pass command line options to Standard's Rake tasks by embedding
|
@@ -146,7 +147,7 @@ Here's an example yaml file with every option set:
|
|
146
147
|
fix: true # default: false
|
147
148
|
parallel: true # default: false
|
148
149
|
format: progress # default: Standard::Formatter
|
149
|
-
ruby_version: 2.3
|
150
|
+
ruby_version: 2.3 # default: RUBY_VERSION
|
150
151
|
default_ignores: false # default: true
|
151
152
|
|
152
153
|
ignore: # default: []
|
@@ -223,8 +224,10 @@ Here are a few examples of Ruby Standard-compliant teams & projects:
|
|
223
224
|
* [Level UP Solutions](https://levups.com)
|
224
225
|
* [Monterail](https://www.monterail.com)
|
225
226
|
* [myRent](https://www.myrent.co.nz)
|
227
|
+
* [OBLSK](https://oblsk.com/)
|
226
228
|
* [Oyster](https://www.oysterhr.com/)
|
227
229
|
* [Planet Argon](https://www.planetargon.com/)
|
230
|
+
* [PLT4M](https://plt4m.com/)
|
228
231
|
* [Podia](https://www.podia.com/)
|
229
232
|
* [Rebase Interactive](https://www.rebaseinteractive.com/)
|
230
233
|
* [Renuo](https://www.renuo.ch/)
|
@@ -268,6 +271,11 @@ Yes! You can use `standardrb --fix` to fix most issues automatically.
|
|
268
271
|
`standardrb --fix` is built into `standardrb` for maximum convenience. Most
|
269
272
|
problems are fixable, but some errors must be fixed manually.
|
270
273
|
|
274
|
+
If you're feeling sinister, you can also use `standardrb --fix-unsafely`, which
|
275
|
+
will also perform fixes, even if they run the risk of altering program behavior.
|
276
|
+
If you read your git diffs closely and have good tests, this is often okay, but
|
277
|
+
YMMV… it's called unsafe for a reason!
|
278
|
+
|
271
279
|
## Can I override the `fix: true` config setting?
|
272
280
|
|
273
281
|
Also yes! You can use `standardrb --no-fix`. Not `fix`ing is the default
|
@@ -369,7 +377,7 @@ of Ruby (by inspecting `RUBY_VERSION` at runtime. But if you want to lock it
|
|
369
377
|
down, you can specify `ruby_version` in `.standard.yml`.
|
370
378
|
|
371
379
|
```
|
372
|
-
ruby_version: 1.8
|
380
|
+
ruby_version: 1.8
|
373
381
|
```
|
374
382
|
|
375
383
|
See
|
data/config/base.yml
CHANGED
@@ -2,8 +2,8 @@ require:
|
|
2
2
|
- rubocop-performance
|
3
3
|
|
4
4
|
AllCops:
|
5
|
-
# Prevent RuboCop from exploding when it finds an older-than-2.
|
6
|
-
TargetRubyVersion: 2.
|
5
|
+
# Prevent RuboCop from exploding when it finds an older-than-2.6 .ruby-version
|
6
|
+
TargetRubyVersion: 2.6
|
7
7
|
Exclude: []
|
8
8
|
|
9
9
|
Bundler/DuplicatedGem:
|
@@ -78,7 +78,6 @@ Layout/AssignmentIndentation:
|
|
78
78
|
Layout/BeginEndAlignment:
|
79
79
|
Enabled: true
|
80
80
|
EnforcedStyleAlignWith: start_of_line
|
81
|
-
AutoCorrect: true
|
82
81
|
Severity: warning
|
83
82
|
|
84
83
|
Layout/BlockAlignment:
|
@@ -110,7 +109,6 @@ Layout/ConditionPosition:
|
|
110
109
|
Layout/DefEndAlignment:
|
111
110
|
Enabled: true
|
112
111
|
EnforcedStyleAlignWith: start_of_line
|
113
|
-
AutoCorrect: true
|
114
112
|
Severity: warning
|
115
113
|
|
116
114
|
Layout/DotPosition:
|
@@ -174,7 +172,6 @@ Layout/EmptyLinesAroundModuleBody:
|
|
174
172
|
|
175
173
|
Layout/EndAlignment:
|
176
174
|
Enabled: true
|
177
|
-
AutoCorrect: true
|
178
175
|
EnforcedStyleAlignWith: variable
|
179
176
|
Severity: warning
|
180
177
|
|
@@ -447,6 +444,8 @@ Lint/AmbiguousRegexpLiteral:
|
|
447
444
|
Lint/AssignmentInCondition:
|
448
445
|
Enabled: true
|
449
446
|
AllowSafeAssignment: true
|
447
|
+
# Intentionally disable autocorrect to force us to intentionally decide
|
448
|
+
# whether assignment is intended as opposed to comparison
|
450
449
|
AutoCorrect: false
|
451
450
|
|
452
451
|
Lint/BigDecimalNew:
|
@@ -500,6 +499,9 @@ Lint/DuplicateHashKey:
|
|
500
499
|
Lint/DuplicateMagicComment:
|
501
500
|
Enabled: true
|
502
501
|
|
502
|
+
Lint/DuplicateMatchPattern:
|
503
|
+
Enabled: false
|
504
|
+
|
503
505
|
Lint/DuplicateMethods:
|
504
506
|
Enabled: true
|
505
507
|
|
@@ -529,7 +531,6 @@ Lint/EmptyConditionalBody:
|
|
529
531
|
|
530
532
|
Lint/EmptyEnsure:
|
531
533
|
Enabled: true
|
532
|
-
AutoCorrect: true
|
533
534
|
|
534
535
|
Lint/EmptyExpression:
|
535
536
|
Enabled: true
|
@@ -695,7 +696,6 @@ Lint/RedundantWithObject:
|
|
695
696
|
|
696
697
|
Lint/RefinementImportMethods:
|
697
698
|
Enabled: true
|
698
|
-
SafeAutoCorrect: false
|
699
699
|
|
700
700
|
Lint/RegexpAsCondition:
|
701
701
|
Enabled: true
|
@@ -1003,7 +1003,6 @@ Performance/FlatMap:
|
|
1003
1003
|
|
1004
1004
|
Performance/InefficientHashSearch:
|
1005
1005
|
Enabled: true
|
1006
|
-
Safe: false
|
1007
1006
|
|
1008
1007
|
Performance/IoReadlines:
|
1009
1008
|
Enabled: false
|
@@ -1019,7 +1018,6 @@ Performance/OpenStruct:
|
|
1019
1018
|
|
1020
1019
|
Performance/RangeInclude:
|
1021
1020
|
Enabled: true
|
1022
|
-
Safe: false
|
1023
1021
|
|
1024
1022
|
Performance/RedundantBlockCall:
|
1025
1023
|
Enabled: false
|
@@ -1096,23 +1094,18 @@ Security/Eval:
|
|
1096
1094
|
|
1097
1095
|
Security/IoMethods:
|
1098
1096
|
Enabled: false
|
1099
|
-
Safe: false
|
1100
1097
|
|
1101
1098
|
Security/JSONLoad:
|
1102
1099
|
Enabled: true
|
1103
|
-
AutoCorrect: false
|
1104
|
-
SafeAutoCorrect: false
|
1105
1100
|
|
1106
1101
|
Security/MarshalLoad:
|
1107
1102
|
Enabled: false
|
1108
1103
|
|
1109
1104
|
Security/Open:
|
1110
1105
|
Enabled: true
|
1111
|
-
Safe: false
|
1112
1106
|
|
1113
1107
|
Security/YAMLLoad:
|
1114
1108
|
Enabled: true
|
1115
|
-
SafeAutoCorrect: false
|
1116
1109
|
|
1117
1110
|
Standard/BlockSingleLineBraces:
|
1118
1111
|
Enabled: true
|
@@ -1240,6 +1233,9 @@ Style/ConstantVisibility:
|
|
1240
1233
|
Style/Copyright:
|
1241
1234
|
Enabled: false
|
1242
1235
|
|
1236
|
+
Style/DataInheritance:
|
1237
|
+
Enabled: false
|
1238
|
+
|
1243
1239
|
Style/DateTime:
|
1244
1240
|
Enabled: false
|
1245
1241
|
|
@@ -1305,7 +1301,6 @@ Style/Encoding:
|
|
1305
1301
|
|
1306
1302
|
Style/EndBlock:
|
1307
1303
|
Enabled: true
|
1308
|
-
AutoCorrect: true
|
1309
1304
|
|
1310
1305
|
Style/EndlessMethod:
|
1311
1306
|
Enabled: false
|
@@ -1443,7 +1438,6 @@ Style/LambdaCall:
|
|
1443
1438
|
|
1444
1439
|
Style/LineEndConcatenation:
|
1445
1440
|
Enabled: true
|
1446
|
-
SafeAutoCorrect: false
|
1447
1441
|
|
1448
1442
|
Style/MagicCommentFormat:
|
1449
1443
|
Enabled: false
|
@@ -1710,6 +1704,9 @@ Style/RedundantInitialize:
|
|
1710
1704
|
Style/RedundantInterpolation:
|
1711
1705
|
Enabled: true
|
1712
1706
|
|
1707
|
+
Style/RedundantLineContinuation:
|
1708
|
+
Enabled: true
|
1709
|
+
|
1713
1710
|
Style/RedundantParentheses:
|
1714
1711
|
Enabled: true
|
1715
1712
|
|
data/config/ruby-2.6.yml
CHANGED
data/config/ruby-3.0.yml
CHANGED
data/config/ruby-3.1.yml
ADDED
@@ -7,15 +7,15 @@ module Standard
|
|
7
7
|
|
8
8
|
class BuildsConfig
|
9
9
|
def initialize
|
10
|
-
@
|
10
|
+
@resolves_yaml_option = ResolvesYamlOption.new
|
11
11
|
@loads_yaml_config = LoadsYamlConfig.new
|
12
12
|
@merges_settings = MergesSettings.new
|
13
13
|
@creates_config_store = CreatesConfigStore.new
|
14
14
|
end
|
15
15
|
|
16
16
|
def call(argv, search_path = Dir.pwd)
|
17
|
-
standard_yaml_path =
|
18
|
-
todo_yaml_path =
|
17
|
+
standard_yaml_path = @resolves_yaml_option.call(argv, search_path, "--config", ".standard.yml")
|
18
|
+
todo_yaml_path = @resolves_yaml_option.call(argv, search_path, "--todo", ".standard_todo.yml")
|
19
19
|
standard_config = @loads_yaml_config.call(standard_yaml_path, todo_yaml_path)
|
20
20
|
|
21
21
|
settings = @merges_settings.call(argv, standard_config)
|
@@ -26,11 +26,5 @@ module Standard
|
|
26
26
|
@creates_config_store.call(standard_config)
|
27
27
|
)
|
28
28
|
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def determine_yaml_file(argv, search_path, option_name, default_file)
|
33
|
-
@parses_cli_option.call(argv, option_name) || FileFinder.new.call(default_file, search_path)
|
34
|
-
end
|
35
29
|
end
|
36
30
|
end
|
data/lib/standard/formatter.rb
CHANGED
@@ -1,47 +1,41 @@
|
|
1
1
|
require "yaml"
|
2
2
|
require "rubocop"
|
3
|
-
require_relative "detects_fixability"
|
4
3
|
|
5
4
|
module Standard
|
6
5
|
class Formatter < RuboCop::Formatter::BaseFormatter
|
7
|
-
STANDARD_GREETING =
|
6
|
+
STANDARD_GREETING = <<~MSG
|
8
7
|
standard: Use Ruby Standard Style (https://github.com/testdouble/standard)
|
9
8
|
MSG
|
10
9
|
|
11
|
-
def self.fixable_error_message(command)
|
12
|
-
<<-MSG.gsub(/^ {8}/, "")
|
13
|
-
standard: Run `#{command}` to automatically fix some problems.
|
14
|
-
MSG
|
15
|
-
end
|
16
|
-
|
17
|
-
def initialize(*args)
|
18
|
-
super
|
19
|
-
@detects_fixability = DetectsFixability.new
|
20
|
-
@header_printed_already = false
|
21
|
-
@fix_suggestion_printed_already = false
|
22
|
-
@offenses_encountered = false
|
23
|
-
end
|
24
|
-
|
25
10
|
def started(_target_files)
|
11
|
+
@header_printed_already = false
|
12
|
+
@total_correction_count = 0
|
13
|
+
@total_correctable_count = 0
|
14
|
+
@total_uncorrected_count = 0
|
26
15
|
print_todo_warning
|
27
16
|
end
|
28
17
|
|
29
18
|
def file_finished(file, offenses)
|
30
|
-
|
31
|
-
|
32
|
-
return unless uncorrected_offenses.any?
|
33
|
-
|
34
|
-
@offenses_encountered = true
|
19
|
+
track_stats(offenses)
|
35
20
|
|
36
|
-
|
37
|
-
|
21
|
+
if (uncorrected_offenses = offenses.reject(&:corrected?)).any?
|
22
|
+
print_header_once
|
38
23
|
|
39
|
-
|
40
|
-
|
24
|
+
uncorrected_offenses.each do |o|
|
25
|
+
output.printf(" %s:%d:%d: %s\n", path_to(file), o.line, o.real_column, o.message.tr("\n", " "))
|
26
|
+
end
|
41
27
|
end
|
42
28
|
end
|
43
29
|
|
30
|
+
def track_stats(offenses)
|
31
|
+
corrected = offenses.count(&:corrected?)
|
32
|
+
@total_correction_count += corrected
|
33
|
+
@total_correctable_count += offenses.count(&:correctable?) - corrected
|
34
|
+
@total_uncorrected_count += offenses.count - corrected
|
35
|
+
end
|
36
|
+
|
44
37
|
def finished(_inspected_files)
|
38
|
+
print_fix_suggestion
|
45
39
|
print_todo_congratulations
|
46
40
|
end
|
47
41
|
|
@@ -55,16 +49,17 @@ module Standard
|
|
55
49
|
@header_printed_already = true
|
56
50
|
end
|
57
51
|
|
58
|
-
def
|
59
|
-
if
|
60
|
-
|
61
|
-
|
52
|
+
def print_fix_suggestion
|
53
|
+
if (fix_mode = potential_fix_mode)
|
54
|
+
run_mode = determine_run_mode
|
55
|
+
|
56
|
+
command = if run_mode == :rake
|
57
|
+
"rake standard:#{fix_mode}"
|
62
58
|
else
|
63
|
-
"standardrb
|
59
|
+
"standardrb --#{fix_mode.to_s.tr("_", "-")}"
|
64
60
|
end
|
65
61
|
|
66
|
-
output.print
|
67
|
-
@fix_suggestion_printed_already = true
|
62
|
+
output.print fixable_error_message(command)
|
68
63
|
end
|
69
64
|
end
|
70
65
|
|
@@ -75,7 +70,7 @@ module Standard
|
|
75
70
|
todo_ignore_files = options[:todo_ignore_files]
|
76
71
|
return unless todo_ignore_files&.any?
|
77
72
|
|
78
|
-
output.print
|
73
|
+
output.print <<~HEADER
|
79
74
|
WARNING: this project is being migrated to standard gradually via `#{todo_file}` and is ignoring these files:
|
80
75
|
HEADER
|
81
76
|
|
@@ -85,29 +80,55 @@ module Standard
|
|
85
80
|
end
|
86
81
|
|
87
82
|
def print_todo_congratulations
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
output.print <<-HEADER.gsub(/^ {8}/, "")
|
97
|
-
Congratulations, you've successfully migrated this project to Standard! Delete `#{todo_file}` in celebration.
|
98
|
-
HEADER
|
83
|
+
if @total_uncorrected_count == 0 &&
|
84
|
+
options[:todo_file] &&
|
85
|
+
options[:todo_ignore_files]&.none?
|
86
|
+
output.print <<~HEADER
|
87
|
+
Congratulations, you've successfully migrated this project to Standard! Delete `#{options[:todo_file]}` in celebration.
|
88
|
+
HEADER
|
89
|
+
end
|
99
90
|
end
|
100
91
|
|
101
92
|
def path_to(file)
|
102
93
|
Pathname.new(file).relative_path_from(Pathname.new(Dir.pwd))
|
103
94
|
end
|
104
95
|
|
105
|
-
def
|
106
|
-
|
96
|
+
def potential_fix_mode
|
97
|
+
return nil unless @total_correctable_count > 0
|
98
|
+
|
99
|
+
if !options[:autocorrect]
|
100
|
+
:fix
|
101
|
+
elsif options[:autocorrect] && options[:safe_autocorrect]
|
102
|
+
:fix_unsafely
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def determine_run_mode
|
107
|
+
if File.split($PROGRAM_NAME).last == "rake"
|
108
|
+
:rake
|
109
|
+
else
|
110
|
+
:cli
|
111
|
+
end
|
107
112
|
end
|
108
113
|
|
109
|
-
def
|
110
|
-
|
114
|
+
def fixable_error_message(command)
|
115
|
+
sales_pitch = if !options[:autocorrect]
|
116
|
+
if @total_correctable_count > 1
|
117
|
+
"fix up to #{@total_correctable_count} problems"
|
118
|
+
else
|
119
|
+
"potentially fix one problem"
|
120
|
+
end
|
121
|
+
elsif options[:autocorrect] && options[:safe_autocorrect]
|
122
|
+
if @total_correctable_count > 1
|
123
|
+
"DANGEROUSLY fix #{@total_correctable_count} problems"
|
124
|
+
else
|
125
|
+
"DANGEROUSLY fix one problem"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
<<~MSG
|
130
|
+
standard: Run `#{command}` to #{sales_pitch}.
|
131
|
+
MSG
|
111
132
|
end
|
112
133
|
end
|
113
134
|
end
|
@@ -49,9 +49,9 @@ module Standard
|
|
49
49
|
}
|
50
50
|
def fork_config(path, text, format:)
|
51
51
|
options = if format
|
52
|
-
{stdin: text, autocorrect: true,
|
52
|
+
{stdin: text, autocorrect: true, safe_autocorrect: true, formatters: []}
|
53
53
|
else
|
54
|
-
{stdin: text, autocorrect: false, formatters: [["json"]], format: "json"}
|
54
|
+
{stdin: text, autocorrect: false, safe_autocorrect: false, formatters: [["json"]], format: "json"}
|
55
55
|
end
|
56
56
|
Standard::Config.new(@config.runner, [path], BASE_OPTIONS.merge(options), @config.rubocop_config_store)
|
57
57
|
end
|
@@ -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", "--verbose-version", "-V", "--help", "-h", "--lsp"].include?(flag)
|
23
|
+
["--generate-todo", "--fix", "--fix-unsafely", "--no-fix", "--version", "-v", "--verbose-version", "-V", "--help", "-h", "--lsp"].include?(flag)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -28,8 +28,13 @@ module Standard
|
|
28
28
|
argv.each_with_object({}) do |arg, cli_flags|
|
29
29
|
if arg == "--fix"
|
30
30
|
cli_flags[:autocorrect] = true
|
31
|
+
cli_flags[:safe_autocorrect] = true
|
32
|
+
elsif arg == "--fix-unsafely"
|
33
|
+
cli_flags[:autocorrect] = true
|
34
|
+
cli_flags[:safe_autocorrect] = false
|
31
35
|
elsif arg == "--no-fix"
|
32
36
|
cli_flags[:autocorrect] = false
|
37
|
+
cli_flags[:safe_autocorrect] = false
|
33
38
|
end
|
34
39
|
end
|
35
40
|
end
|
@@ -53,6 +58,7 @@ module Standard
|
|
53
58
|
def merge(standard_yaml, standard_cli_flags, rubocop_cli_flags)
|
54
59
|
{
|
55
60
|
autocorrect: standard_yaml[:fix],
|
61
|
+
safe_autocorrect: true,
|
56
62
|
formatters: [[standard_yaml[:format] || "Standard::Formatter", nil]],
|
57
63
|
parallel: standard_yaml[:parallel],
|
58
64
|
todo_file: standard_yaml[:todo_file],
|
data/lib/standard/rake.rb
CHANGED
@@ -18,9 +18,16 @@ task :standard do
|
|
18
18
|
fail unless exit_code == 0
|
19
19
|
end
|
20
20
|
|
21
|
-
desc "Lint and automatically
|
21
|
+
desc "Lint and automatically make safe fixes with the Standard Ruby style guide"
|
22
22
|
task :"standard:fix" do
|
23
23
|
require "standard"
|
24
24
|
exit_code = Standard::Cli.new(Standard::RakeSupport.argvify + ["--fix"]).run
|
25
25
|
fail unless exit_code == 0
|
26
26
|
end
|
27
|
+
|
28
|
+
desc "Lint and automatically make fixes (even unsafe ones!) with the Standard Ruby style guide"
|
29
|
+
task :"standard:fix_unsafely" do
|
30
|
+
require "standard"
|
31
|
+
exit_code = Standard::Cli.new(Standard::RakeSupport.argvify + ["--fix-unsafely"]).run
|
32
|
+
fail unless exit_code == 0
|
33
|
+
end
|
@@ -1,8 +1,14 @@
|
|
1
1
|
require "pathname"
|
2
2
|
|
3
3
|
module Standard
|
4
|
-
class
|
5
|
-
def call(argv, option_name)
|
4
|
+
class ResolvesYamlOption
|
5
|
+
def call(argv, search_path, option_name, default_file)
|
6
|
+
search_argv(argv, option_name) || FileFinder.new.call(default_file, search_path)
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def search_argv(argv, option_name)
|
6
12
|
return unless (config_file = argv_value_for(argv, option_name))
|
7
13
|
|
8
14
|
resolved_config = Pathname.new(config_file)
|
@@ -9,7 +9,8 @@ module Standard
|
|
9
9
|
|
10
10
|
Options:
|
11
11
|
|
12
|
-
--fix
|
12
|
+
--fix Apply automatic fixes that we're confident won't break your code
|
13
|
+
--fix-unsafely Apply even more fixes, including some that may change code behavior
|
13
14
|
--no-fix Do not automatically fix failures
|
14
15
|
--format <name> Format output with any RuboCop formatter (e.g. "json")
|
15
16
|
--generate-todo Create a .standard_todo.yml that lists all the files that contain errors
|
data/lib/standard/version.rb
CHANGED
data/standard.gemspec
CHANGED
@@ -11,6 +11,9 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = "Ruby Style Guide, with linter & automatic code fixer"
|
13
13
|
spec.homepage = "https://github.com/testdouble/standard"
|
14
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
15
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
16
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
14
17
|
|
15
18
|
spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
|
16
19
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
@@ -20,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
20
23
|
spec.require_paths = ["lib"]
|
21
24
|
spec.metadata["rubygems_mfa_required"] = "true"
|
22
25
|
|
23
|
-
spec.add_dependency "rubocop", "~> 1.
|
26
|
+
spec.add_dependency "rubocop", "~> 1.50.2"
|
24
27
|
spec.add_dependency "rubocop-performance", "~> 1.16.0"
|
25
28
|
|
26
29
|
# not semver: first three are lsp protocol version, last is patch
|
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.27.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-04-
|
11
|
+
date: 2023-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.50.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.50.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubocop-performance
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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:
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- config/ruby-2.6.yml
|
86
86
|
- config/ruby-2.7.yml
|
87
87
|
- config/ruby-3.0.yml
|
88
|
+
- config/ruby-3.1.yml
|
88
89
|
- docs/NEW_RUBIES.md
|
89
90
|
- docs/RELEASE.md
|
90
91
|
- exe/standardrb
|
@@ -97,7 +98,6 @@ files:
|
|
97
98
|
- lib/standard/creates_config_store/configures_ignored_paths.rb
|
98
99
|
- lib/standard/creates_config_store/merges_user_config_extensions.rb
|
99
100
|
- lib/standard/creates_config_store/sets_target_ruby_version.rb
|
100
|
-
- lib/standard/detects_fixability.rb
|
101
101
|
- lib/standard/file_finder.rb
|
102
102
|
- lib/standard/formatter.rb
|
103
103
|
- lib/standard/loads_runner.rb
|
@@ -108,9 +108,9 @@ files:
|
|
108
108
|
- lib/standard/lsp/server.rb
|
109
109
|
- lib/standard/lsp/standardizer.rb
|
110
110
|
- lib/standard/merges_settings.rb
|
111
|
-
- lib/standard/parses_cli_option.rb
|
112
111
|
- lib/standard/railtie.rb
|
113
112
|
- lib/standard/rake.rb
|
113
|
+
- lib/standard/resolves_yaml_option.rb
|
114
114
|
- lib/standard/rubocop/ext.rb
|
115
115
|
- lib/standard/runners/genignore.rb
|
116
116
|
- lib/standard/runners/help.rb
|
@@ -123,8 +123,11 @@ files:
|
|
123
123
|
homepage: https://github.com/testdouble/standard
|
124
124
|
licenses: []
|
125
125
|
metadata:
|
126
|
+
homepage_uri: https://github.com/testdouble/standard
|
127
|
+
source_code_uri: https://github.com/testdouble/standard
|
128
|
+
changelog_uri: https://github.com/testdouble/standard/blob/main/CHANGELOG.md
|
126
129
|
rubygems_mfa_required: 'true'
|
127
|
-
post_install_message:
|
130
|
+
post_install_message:
|
128
131
|
rdoc_options: []
|
129
132
|
require_paths:
|
130
133
|
- lib
|
@@ -139,8 +142,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
142
|
- !ruby/object:Gem::Version
|
140
143
|
version: '0'
|
141
144
|
requirements: []
|
142
|
-
rubygems_version: 3.
|
143
|
-
signing_key:
|
145
|
+
rubygems_version: 3.1.6
|
146
|
+
signing_key:
|
144
147
|
specification_version: 4
|
145
148
|
summary: Ruby Style Guide, with linter & automatic code fixer
|
146
149
|
test_files: []
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Standard
|
2
|
-
class DetectsFixability
|
3
|
-
def call(offenses)
|
4
|
-
offenses.any? { |offense|
|
5
|
-
cop = cop_instance(offense.cop_name)
|
6
|
-
cop.correctable? && cop.safe_autocorrect?
|
7
|
-
}
|
8
|
-
end
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
def cop_instance(cop_name)
|
13
|
-
RuboCop::Cop.const_get(cop_name.gsub("/", "::")).new
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|