standard 1.33.0 → 1.40.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.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +6 -2
- data/.github/workflows/update.yml +2 -2
- data/.standard.yml +1 -1
- data/CHANGELOG.md +54 -5
- data/Gemfile +2 -1
- data/Gemfile.lock +27 -16
- data/README.md +44 -24
- data/config/base.yml +13 -1
- data/config/default.yml +1 -2
- data/config/ruby-3.2.yml +1 -1
- data/config/ruby-3.3.yml +4 -0
- data/lib/ruby_lsp/standard/addon.rb +58 -0
- data/lib/ruby_lsp/standard/wraps_built_in_lsp_standardizer.rb +36 -0
- data/lib/standard/base/plugin.rb +2 -0
- data/lib/standard/lsp/diagnostic.rb +174 -0
- data/lib/standard/lsp/logger.rb +3 -2
- data/lib/standard/lsp/routes.rb +10 -46
- data/lib/standard/lsp/server.rb +2 -1
- data/lib/standard/lsp/standardizer.rb +19 -54
- data/lib/standard/lsp/stdin_rubocop_runner.rb +63 -0
- data/lib/standard/plugin/merges_plugins_into_rubocop_config.rb +1 -1
- data/lib/standard/version.rb +1 -1
- data/standard.gemspec +3 -3
- metadata +13 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11a5e687261fb830d043558db4065c4533725a5997b1b70b3ba2b7656410fc2b
|
4
|
+
data.tar.gz: 1a38f3258931be3002752d726bcae77caf6e6dedb92b7e758cf65052b6db0464
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 399225a5d25d05fbef38bc7008801a680c48fc89c139820010ddd0ceffdc39008a1ec405dfe0ad414a43032d1c2227a0fb487618ce0f67bffe28cffa3afe35f5
|
7
|
+
data.tar.gz: feedd6180c2d564c3e0126e7f6f83731f8b029421030b7263f810e531b26943d5deec44247a8a6b136d3881b38c853762838e79742899ce091b1bf787201d893
|
data/.github/workflows/test.yml
CHANGED
@@ -16,12 +16,16 @@ jobs:
|
|
16
16
|
strategy:
|
17
17
|
matrix:
|
18
18
|
os: [ubuntu-latest]
|
19
|
-
ruby-version:
|
19
|
+
ruby-version:
|
20
|
+
- '3.0'
|
21
|
+
- '3.1'
|
22
|
+
- '3.2'
|
23
|
+
- '3.3'
|
20
24
|
|
21
25
|
runs-on: ${{ matrix.os }}
|
22
26
|
|
23
27
|
steps:
|
24
|
-
- uses: actions/checkout@
|
28
|
+
- uses: actions/checkout@v4
|
25
29
|
- name: Set up Ruby ${{ matrix.ruby-version }}
|
26
30
|
uses: ruby/setup-ruby@v1
|
27
31
|
with:
|
@@ -14,7 +14,7 @@ jobs:
|
|
14
14
|
runs-on: ubuntu-latest
|
15
15
|
|
16
16
|
steps:
|
17
|
-
- uses: actions/checkout@
|
17
|
+
- uses: actions/checkout@v4
|
18
18
|
- name: Set up Ruby
|
19
19
|
uses: ruby/setup-ruby@v1
|
20
20
|
with:
|
@@ -45,7 +45,7 @@ jobs:
|
|
45
45
|
id: date
|
46
46
|
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
|
47
47
|
- name: Create Pull Request
|
48
|
-
uses: peter-evans/create-pull-request@
|
48
|
+
uses: peter-evans/create-pull-request@v6
|
49
49
|
with:
|
50
50
|
reviewers: camilopayan
|
51
51
|
commit-message: '[ ${{ steps.date.outputs.date }} ] - Update dependencies'
|
data/.standard.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,56 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## Unreleased
|
4
|
+
|
5
|
+
## 1.40.0
|
6
|
+
|
7
|
+
* Updates rubocop to [1.65.1](https://github.com/rubocop/rubocop/releases/tag/v1.65.1)
|
8
|
+
|
9
|
+
## 1.39.2
|
10
|
+
|
11
|
+
* Ensure a URI scheme on file paths from the built-in LSP [#642](https://github.com/standardrb/standard/pull/642).
|
12
|
+
|
13
|
+
## 1.39.1
|
14
|
+
|
15
|
+
* Fix LSP when `format` is set [#638](https://github.com/standardrb/standard/issues/638)
|
16
|
+
* Fix LSP when todo is present (I think) [vscode-standard-ruby#26](https://github.com/standardrb/vscode-standard-ruby/issues/26)
|
17
|
+
|
18
|
+
## 1.39.0
|
19
|
+
|
20
|
+
* Add support for LSP Code Actions / Quick Fix under Ruby LSP [#636](https://github.com/standardrb/standard/pull/636)
|
21
|
+
|
22
|
+
## 1.38.0
|
23
|
+
|
24
|
+
* Update minimum Ruby version to 3.0
|
25
|
+
* @koic backported a line column bug in our LSP
|
26
|
+
[#635](https://github.com/standardrb/standard/pull/635)
|
27
|
+
* Implement a basic [Ruby LSP
|
28
|
+
add-on](https://github.com/Shopify/ruby-lsp/blob/main/ADDONS.md), which means
|
29
|
+
users would no longer need to install [our custom VS Code
|
30
|
+
extension](https://marketplace.visualstudio.com/items?itemName=testdouble.vscode-standard-ruby)
|
31
|
+
[#630](https://github.com/standardrb/standard/pull/630)
|
32
|
+
|
33
|
+
## 1.37.0
|
34
|
+
|
35
|
+
* Updates rubocop to [1.64.1](https://github.com/rubocop/rubocop/releases/tag/v1.64.1)
|
36
|
+
|
37
|
+
## 1.36.0
|
38
|
+
|
39
|
+
* Updates rubocop to [1.63.5](https://github.com/rubocop/rubocop/releases/tag/v1.63.5)
|
40
|
+
* Updates standard-performance to [1.4.0](https://github.com/standardrb/standard-performance/releases/tag/v1.4.0)
|
41
|
+
|
42
|
+
## 1.35.1
|
43
|
+
|
44
|
+
* Corrects rubocop constraint to the patch version, not minor version.
|
45
|
+
|
46
|
+
## 1.35.0
|
47
|
+
|
48
|
+
* Updates rubocop to [1.62](https://github.com/rubocop/rubocop/releases/tag/v1.62.1)
|
49
|
+
|
50
|
+
## 1.34.0
|
51
|
+
|
52
|
+
* Updates rubocop to [1.60.2](https://github.com/rubocop/rubocop/releases/tag/v1.60.2)
|
53
|
+
|
3
54
|
## 1.33.0
|
4
55
|
|
5
56
|
* Updates rubocop to [1.59.0](https://github.com/rubocop/rubocop/releases/tag/v1.59.0)
|
@@ -59,9 +110,9 @@ plugin that mirrors a rubocop extension
|
|
59
110
|
## 1.28.3
|
60
111
|
|
61
112
|
* Older ruby support fixes from [@pboling](https://github.com/pboling):
|
62
|
-
|
63
|
-
|
64
|
-
|
113
|
+
* [#559](https://github.com/standardrb/standard/issues/559)
|
114
|
+
* [#561](https://github.com/standardrb/standard/issues/560)
|
115
|
+
* [#561](https://github.com/standardrb/standard/issues/561)
|
65
116
|
|
66
117
|
## 1.28.2
|
67
118
|
|
@@ -546,7 +597,6 @@ mutations to RuboCop's default configuration)
|
|
546
597
|
* [Performance/DeletePrefix](https://github.com/rubocop-hq/rubocop-performance/pull/105)
|
547
598
|
* [Performance/DeleteSuffix](https://github.com/rubocop-hq/rubocop-performance/pull/105)
|
548
599
|
|
549
|
-
|
550
600
|
## 0.4.6
|
551
601
|
|
552
602
|
* Disable `Naming/BinaryOperatorParameterName` because (when non-ascii method
|
@@ -578,7 +628,6 @@ mutations to RuboCop's default configuration)
|
|
578
628
|
safe
|
579
629
|
* Allow comments in empty `when` blocks
|
580
630
|
|
581
|
-
|
582
631
|
## 0.4.1
|
583
632
|
|
584
633
|
* add given/given! as `{}` friendly blocks [#172](https://github.com/testdouble/standard/pull/172)
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,52 +1,61 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
standard (1.
|
4
|
+
standard (1.40.0)
|
5
5
|
language_server-protocol (~> 3.17.0.2)
|
6
6
|
lint_roller (~> 1.0)
|
7
|
-
rubocop (~> 1.
|
7
|
+
rubocop (~> 1.65.0)
|
8
8
|
standard-custom (~> 1.0.0)
|
9
|
-
standard-performance (~> 1.
|
9
|
+
standard-performance (~> 1.4)
|
10
10
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
14
|
ast (2.4.2)
|
15
15
|
docile (1.4.0)
|
16
|
-
gimme (0.5.0)
|
17
16
|
json (2.6.3)
|
18
17
|
language_server-protocol (3.17.0.3)
|
19
18
|
lint_roller (1.1.0)
|
19
|
+
logger (1.6.0)
|
20
20
|
m (1.6.2)
|
21
21
|
method_source (>= 0.6.7)
|
22
22
|
rake (>= 0.9.2.2)
|
23
23
|
method_source (1.0.0)
|
24
24
|
minitest (5.20.0)
|
25
|
+
mutex_m (0.2.0)
|
25
26
|
parallel (1.23.0)
|
26
|
-
parser (3.
|
27
|
+
parser (3.3.0.5)
|
27
28
|
ast (~> 2.4.1)
|
28
29
|
racc
|
30
|
+
prism (0.30.0)
|
29
31
|
racc (1.7.1)
|
30
32
|
rainbow (3.1.1)
|
31
33
|
rake (13.0.6)
|
34
|
+
rbs (3.5.2)
|
35
|
+
logger
|
32
36
|
regexp_parser (2.8.2)
|
33
37
|
rexml (3.2.6)
|
34
|
-
rubocop (1.
|
38
|
+
rubocop (1.65.1)
|
35
39
|
json (~> 2.3)
|
36
40
|
language_server-protocol (>= 3.17.0)
|
37
41
|
parallel (~> 1.10)
|
38
|
-
parser (>= 3.
|
42
|
+
parser (>= 3.3.0.2)
|
39
43
|
rainbow (>= 2.2.2, < 4.0)
|
40
|
-
regexp_parser (>=
|
44
|
+
regexp_parser (>= 2.4, < 3.0)
|
41
45
|
rexml (>= 3.2.5, < 4.0)
|
42
|
-
rubocop-ast (>= 1.
|
46
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
43
47
|
ruby-progressbar (~> 1.7)
|
44
48
|
unicode-display_width (>= 2.4.0, < 3.0)
|
45
|
-
rubocop-ast (1.
|
46
|
-
parser (>= 3.
|
47
|
-
rubocop-performance (1.
|
49
|
+
rubocop-ast (1.31.2)
|
50
|
+
parser (>= 3.3.0.4)
|
51
|
+
rubocop-performance (1.21.0)
|
48
52
|
rubocop (>= 1.48.1, < 2.0)
|
49
|
-
rubocop-ast (>= 1.
|
53
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
54
|
+
ruby-lsp (0.17.7)
|
55
|
+
language_server-protocol (~> 3.17.0)
|
56
|
+
prism (>= 0.29.0, < 0.31)
|
57
|
+
rbs (>= 3, < 4)
|
58
|
+
sorbet-runtime (>= 0.5.10782)
|
50
59
|
ruby-progressbar (1.13.0)
|
51
60
|
simplecov (0.22.0)
|
52
61
|
docile (~> 1.1)
|
@@ -54,12 +63,13 @@ GEM
|
|
54
63
|
simplecov_json_formatter (~> 0.1)
|
55
64
|
simplecov-html (0.12.3)
|
56
65
|
simplecov_json_formatter (0.1.4)
|
66
|
+
sorbet-runtime (0.5.11481)
|
57
67
|
standard-custom (1.0.2)
|
58
68
|
lint_roller (~> 1.0)
|
59
69
|
rubocop (~> 1.50)
|
60
|
-
standard-performance (1.
|
70
|
+
standard-performance (1.4.0)
|
61
71
|
lint_roller (~> 1.1)
|
62
|
-
rubocop-performance (~> 1.
|
72
|
+
rubocop-performance (~> 1.21.0)
|
63
73
|
unicode-display_width (2.5.0)
|
64
74
|
|
65
75
|
PLATFORMS
|
@@ -68,10 +78,11 @@ PLATFORMS
|
|
68
78
|
|
69
79
|
DEPENDENCIES
|
70
80
|
bundler
|
71
|
-
gimme
|
72
81
|
m
|
73
82
|
minitest (~> 5.0)
|
83
|
+
mutex_m
|
74
84
|
rake (~> 13.0)
|
85
|
+
ruby-lsp
|
75
86
|
simplecov
|
76
87
|
standard!
|
77
88
|
|
data/README.md
CHANGED
@@ -11,7 +11,8 @@ configuration** to all of RuboCop's built-in rules as well as those included in
|
|
11
11
|
[rubocop-performance](https://github.com/rubocop/rubocop-performance). It also
|
12
12
|
supports plugins built with
|
13
13
|
[lint_roller](https://github.com/standardrb/lint_roller), like
|
14
|
-
[standard-rails](https://github.com/standardrb/standard-rails)
|
14
|
+
[standard-rails](https://github.com/standardrb/standard-rails) and
|
15
|
+
[standard-sorbet](https://github.com/standardrb/standard-sorbet).
|
15
16
|
|
16
17
|
Standard Ruby was created and is maintained by the team at [Test
|
17
18
|
Double](https://testdouble.com), because we appreciate the importance of
|
@@ -35,7 +36,7 @@ good idea. People also agree it's easier to work in codebases that exhibit a
|
|
35
36
|
consistent style and format. So, what's the problem? **No two developers will
|
36
37
|
ever agree on what all the rules and format should be.**
|
37
38
|
|
38
|
-
This has resulted in innumerable teams arguing how to configure their linters
|
39
|
+
This has resulted in innumerable teams arguing about how to configure their linters
|
39
40
|
and formatters over literal decades. Some teams routinely divert time and energy
|
40
41
|
from whatever they're building to reach consensus on where commas should go.
|
41
42
|
Other teams have an overzealous tech lead who sets up everything _his favorite
|
@@ -76,17 +77,18 @@ is in using one at all and not in the particulars of how it's configured.
|
|
76
77
|
### Install
|
77
78
|
|
78
79
|
Getting started is as easy as `gem install standard` or throwing it in your
|
79
|
-
project's Gemfile
|
80
|
+
project's Gemfile and running `bundle install`:
|
80
81
|
|
81
82
|
```ruby
|
82
|
-
gem "standard"
|
83
|
+
gem "standard"
|
83
84
|
```
|
84
85
|
|
85
|
-
### Running Standard
|
86
|
+
### Running Standard Ruby
|
86
87
|
|
87
|
-
Once installed, you can
|
88
|
+
Once installed, you can run Standard from the command line via its built-in
|
89
|
+
executable or as a Rake task.
|
88
90
|
|
89
|
-
|
91
|
+
Standard Ruby's binary is named `standardrb` to distinguish it from
|
90
92
|
[StandardJS](https://github.com/standard/standard):
|
91
93
|
|
92
94
|
```
|
@@ -137,8 +139,8 @@ $ rake standard:fix_unsafely
|
|
137
139
|
|
138
140
|
So long as your code is checked into source control, there's no mortal harm in
|
139
141
|
running with unsafe fixes enabled. If the changes look good to you and your
|
140
|
-
tests pass, then it's probably
|
141
|
-
by hand.
|
142
|
+
tests pass, then it's probably no more error prone than manually editing
|
143
|
+
every change by hand.
|
142
144
|
|
143
145
|
## Integrating Standard into your workflow
|
144
146
|
|
@@ -151,11 +153,12 @@ continuous integration systems.
|
|
151
153
|
|
152
154
|
We've added a number of editing guides for getting started:
|
153
155
|
|
154
|
-
- [VS Code](https://github.com/standardrb/vscode
|
156
|
+
- [VS Code](https://github.com/standardrb/standard/wiki/IDE:-vscode)
|
155
157
|
- [vim](https://github.com/standardrb/standard/wiki/IDE:-vim)
|
156
158
|
- [neovim](https://github.com/standardrb/standard/wiki/IDE:-neovim)
|
157
159
|
- [RubyMine](https://www.jetbrains.com/help/ruby/rubocop.html#disable_rubocop)
|
158
160
|
- [emacs](https://www.flycheck.org/en/latest/languages.html#syntax-checker-ruby-standard)
|
161
|
+
- [Helix](https://github.com/helix-editor/helix/wiki/External-formatter-configuration#standardrb)
|
159
162
|
- [Atom](https://github.com/standardrb/standard/wiki/IDE:-Atom)
|
160
163
|
|
161
164
|
If you'd like to help by creating a guide, please draft one [in an
|
@@ -164,26 +167,39 @@ added!
|
|
164
167
|
|
165
168
|
#### Language Server Protocol support
|
166
169
|
|
167
|
-
If you don't see your preferred editor above, Standard Ruby also
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
170
|
+
If you don't see your preferred editor above, Standard Ruby also offers robust
|
171
|
+
[language server](https://microsoft.github.io/language-server-protocol/) support,
|
172
|
+
in two ways, both included with the `standard` gem:
|
173
|
+
|
174
|
+
1. A [Ruby LSP](https://github.com/Shopify/ruby-lsp) add-on, which (if
|
175
|
+
the `standard` gem is in your `Gemfile`) will be loaded automatically
|
176
|
+
2. A language server executable, which can be run from the command line
|
177
|
+
with `standardrb --lsp`
|
178
|
+
|
179
|
+
| Capability | Ruby LSP Add-on | Internal Server |
|
180
|
+
| ------------- | ------------- | ------------- |
|
181
|
+
| Diagnostics (Linting) | ✅ ([Pull](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_pullDiagnostics)) | ✅ ([Push](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_publishDiagnostics)) |
|
182
|
+
| [Formatting](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_formatting) | ✅ | ✅ |
|
183
|
+
| [Code Actions](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_codeAction) | ✅ | ❌ |
|
184
|
+
| Everything else | ❌ | ❌ |
|
185
|
+
|
186
|
+
Due to the advantages of Pull diagnostics and its inclusion of Code Actions
|
187
|
+
("Quick Fixes" in VS Code parlance), we recommend using Standard's [Ruby LSP
|
188
|
+
add-on](https://github.com/standardrb/standard/wiki/IDE:-vscode#using-ruby-lsp)
|
189
|
+
where possible.
|
190
|
+
|
191
|
+
Regardless of which language server you use, many editors have added LSP
|
192
|
+
support, with each bringing their own approach to configuration. Many LSP
|
193
|
+
features should "just work", but when in doubt, please consult our [editor
|
194
|
+
guides above](#editor-support) as well as your editor's own documentation on how
|
195
|
+
to configure LSP formatters and linters.
|
180
196
|
|
181
197
|
### CI support
|
182
198
|
|
183
199
|
Various continuous integration and quality-checking tools have been made to
|
184
200
|
support Standard Ruby, as well.
|
185
201
|
|
186
|
-
* [
|
202
|
+
* [GitHub Actions](https://github.com/standardrb/standard-ruby-action)
|
187
203
|
* [Code Climate](https://github.com/standardrb/standard/wiki/CI:-Code-Climate)
|
188
204
|
* [Pronto](https://github.com/julianrubisch/pronto-standardrb)
|
189
205
|
* [Danger](https://github.com/ashfurrow/danger-rubocop/)
|
@@ -465,6 +481,7 @@ inherit_gem:
|
|
465
481
|
Here are a few examples of Ruby Standard-compliant teams & projects:
|
466
482
|
|
467
483
|
* [Test Double](https://testdouble.com/agency)
|
484
|
+
* [AdBarker](https://adbarker.com)
|
468
485
|
* [AlchemyCMS](https://alchemy-cms.com)
|
469
486
|
* [Amazon Web Services](https://aws.amazon.com/)
|
470
487
|
* [Arrows](https://arrows.to/)
|
@@ -475,6 +492,7 @@ Here are a few examples of Ruby Standard-compliant teams & projects:
|
|
475
492
|
* [Brave Software](https://github.com/brave-intl/publishers)
|
476
493
|
* [Collective Idea](https://collectiveidea.com/)
|
477
494
|
* [Culture Foundry](https://www.culturefoundry.com/)
|
495
|
+
* [Datadog](https://www.datadoghq.com/)
|
478
496
|
* [Donut](https://www.donut.com/)
|
479
497
|
* [Elevate Labs](https://elevatelabs.com)
|
480
498
|
* [Envoy](https://www.envoy.com)
|
@@ -498,7 +516,9 @@ Here are a few examples of Ruby Standard-compliant teams & projects:
|
|
498
516
|
* [Spinal](https://spinalcms.com/)
|
499
517
|
* [Teamtailor](https://www.teamtailor.com/)
|
500
518
|
* [thoughtbot](https://thoughtbot.com/)
|
519
|
+
* [Topkey](https://topkey.io)
|
501
520
|
* [University of Wisconsin-Eau Claire](https://www.uwec.edu/)
|
521
|
+
* [Cartwheel](https://www.cartwheel.org)
|
502
522
|
|
503
523
|
Does your team use Standard? [Add your name to the list](https://github.com/standardrb/standard/edit/main/README.md)!
|
504
524
|
|
data/config/base.yml
CHANGED
@@ -27,6 +27,9 @@ Bundler/InsecureProtocolSource:
|
|
27
27
|
Bundler/OrderedGems:
|
28
28
|
Enabled: false
|
29
29
|
|
30
|
+
Gemspec/AddRuntimeDependency:
|
31
|
+
Enabled: false
|
32
|
+
|
30
33
|
Gemspec/DependencyVersion:
|
31
34
|
Enabled: false
|
32
35
|
|
@@ -1303,6 +1306,9 @@ Style/MagicCommentFormat:
|
|
1303
1306
|
Style/MapCompactWithConditionalBlock:
|
1304
1307
|
Enabled: true
|
1305
1308
|
|
1309
|
+
Style/MapIntoArray:
|
1310
|
+
Enabled: false
|
1311
|
+
|
1306
1312
|
Style/MapToHash:
|
1307
1313
|
Enabled: false
|
1308
1314
|
|
@@ -1566,7 +1572,7 @@ Style/RedundantHeredocDelimiterQuotes:
|
|
1566
1572
|
Enabled: true
|
1567
1573
|
|
1568
1574
|
Style/RedundantInitialize:
|
1569
|
-
Enabled:
|
1575
|
+
Enabled: false
|
1570
1576
|
|
1571
1577
|
Style/RedundantInterpolation:
|
1572
1578
|
Enabled: true
|
@@ -1659,6 +1665,9 @@ Style/Semicolon:
|
|
1659
1665
|
Style/Send:
|
1660
1666
|
Enabled: false
|
1661
1667
|
|
1668
|
+
Style/SendWithLiteralMethodName:
|
1669
|
+
Enabled: false
|
1670
|
+
|
1662
1671
|
Style/SignalException:
|
1663
1672
|
Enabled: false
|
1664
1673
|
|
@@ -1721,6 +1730,9 @@ Style/Strip:
|
|
1721
1730
|
Style/StructInheritance:
|
1722
1731
|
Enabled: false
|
1723
1732
|
|
1733
|
+
Style/SuperArguments:
|
1734
|
+
Enabled: true
|
1735
|
+
|
1724
1736
|
Style/SuperWithArgsParentheses:
|
1725
1737
|
Enabled: true
|
1726
1738
|
|
data/config/default.yml
CHANGED
data/config/ruby-3.2.yml
CHANGED
data/config/ruby-3.3.yml
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require "standard"
|
2
|
+
require_relative "wraps_built_in_lsp_standardizer"
|
3
|
+
|
4
|
+
module RubyLsp
|
5
|
+
module Standard
|
6
|
+
class Addon < ::RubyLsp::Addon
|
7
|
+
def name
|
8
|
+
"Standard Ruby"
|
9
|
+
end
|
10
|
+
|
11
|
+
def activate(global_state, message_queue)
|
12
|
+
@logger = ::Standard::Lsp::Logger.new(prefix: "[Standard Ruby]")
|
13
|
+
@logger.puts "Activating Standard Ruby LSP addon v#{::Standard::VERSION}"
|
14
|
+
RuboCop::LSP.enable
|
15
|
+
@wraps_built_in_lsp_standardizer = WrapsBuiltinLspStandardizer.new
|
16
|
+
global_state.register_formatter("standard", @wraps_built_in_lsp_standardizer)
|
17
|
+
register_additional_file_watchers(global_state, message_queue)
|
18
|
+
@logger.puts "Initialized Standard Ruby LSP addon #{::Standard::VERSION}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def deactivate
|
22
|
+
@wraps_built_in_lsp_standardizer = nil
|
23
|
+
end
|
24
|
+
|
25
|
+
def register_additional_file_watchers(global_state, message_queue)
|
26
|
+
return unless global_state.supports_watching_files
|
27
|
+
|
28
|
+
message_queue << Request.new(
|
29
|
+
id: "standard-file-watcher",
|
30
|
+
method: "client/registerCapability",
|
31
|
+
params: Interface::RegistrationParams.new(
|
32
|
+
registrations: [
|
33
|
+
Interface::Registration.new(
|
34
|
+
id: "workspace/didChangeWatchedFilesStandard",
|
35
|
+
method: "workspace/didChangeWatchedFiles",
|
36
|
+
register_options: Interface::DidChangeWatchedFilesRegistrationOptions.new(
|
37
|
+
watchers: [
|
38
|
+
Interface::FileSystemWatcher.new(
|
39
|
+
glob_pattern: "**/.standard{,_todo}.yml",
|
40
|
+
kind: Constant::WatchKind::CREATE | Constant::WatchKind::CHANGE | Constant::WatchKind::DELETE
|
41
|
+
)
|
42
|
+
]
|
43
|
+
)
|
44
|
+
)
|
45
|
+
]
|
46
|
+
)
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
def workspace_did_change_watched_files(changes)
|
51
|
+
if changes.any? { |change| change[:uri].end_with?(".standard.yml") }
|
52
|
+
@wraps_built_in_lsp_standardizer.init!
|
53
|
+
@logger.puts "Re-initialized Standard Ruby LSP addon #{::Standard::VERSION} due to .standard.yml file change"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module RubyLsp
|
2
|
+
module Standard
|
3
|
+
class WrapsBuiltinLspStandardizer
|
4
|
+
include RubyLsp::Requests::Support::Formatter
|
5
|
+
def initialize
|
6
|
+
init!
|
7
|
+
end
|
8
|
+
|
9
|
+
def init!
|
10
|
+
@standardizer = ::Standard::Lsp::Standardizer.new(
|
11
|
+
::Standard::BuildsConfig.new.call([])
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
def run_formatting(uri, document)
|
16
|
+
@standardizer.format(uri_to_path(uri), document.source)
|
17
|
+
end
|
18
|
+
|
19
|
+
def run_diagnostic(uri, document)
|
20
|
+
@standardizer.offenses(uri_to_path(uri), document.source, document.encoding)
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# duplicated from: lib/standard/lsp/routes.rb
|
26
|
+
# modified to incorporate Ruby LSP's to_standardized_path method
|
27
|
+
def uri_to_path(uri)
|
28
|
+
if uri.respond_to?(:to_standardized_path) && !(standardized_path = uri.to_standardized_path).nil?
|
29
|
+
standardized_path
|
30
|
+
else
|
31
|
+
uri.to_s.sub(%r{^file://}, "")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/standard/base/plugin.rb
CHANGED
@@ -0,0 +1,174 @@
|
|
1
|
+
module Standard
|
2
|
+
module Lsp
|
3
|
+
class Diagnostic
|
4
|
+
Constant = LanguageServer::Protocol::Constant
|
5
|
+
Interface = LanguageServer::Protocol::Interface
|
6
|
+
|
7
|
+
RUBOCOP_TO_LSP_SEVERITY = {
|
8
|
+
info: Constant::DiagnosticSeverity::HINT,
|
9
|
+
refactor: Constant::DiagnosticSeverity::INFORMATION,
|
10
|
+
convention: Constant::DiagnosticSeverity::INFORMATION,
|
11
|
+
warning: Constant::DiagnosticSeverity::WARNING,
|
12
|
+
error: Constant::DiagnosticSeverity::ERROR,
|
13
|
+
fatal: Constant::DiagnosticSeverity::ERROR
|
14
|
+
}.freeze
|
15
|
+
|
16
|
+
def initialize(document_encoding, offense, uri, cop_class)
|
17
|
+
@document_encoding = document_encoding
|
18
|
+
@offense = offense
|
19
|
+
@uri = uri
|
20
|
+
@cop_class = cop_class
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_lsp_code_actions
|
24
|
+
code_actions = []
|
25
|
+
|
26
|
+
code_actions << autocorrect_action if correctable?
|
27
|
+
code_actions << disable_line_action
|
28
|
+
|
29
|
+
code_actions
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_lsp_diagnostic(config)
|
33
|
+
highlighted = @offense.highlighted_area
|
34
|
+
Interface::Diagnostic.new(
|
35
|
+
message: message,
|
36
|
+
source: "Standard Ruby",
|
37
|
+
code: @offense.cop_name,
|
38
|
+
code_description: code_description(config),
|
39
|
+
severity: severity,
|
40
|
+
range: Interface::Range.new(
|
41
|
+
start: Interface::Position.new(
|
42
|
+
line: @offense.line - 1,
|
43
|
+
character: highlighted.begin_pos
|
44
|
+
),
|
45
|
+
end: Interface::Position.new(
|
46
|
+
line: @offense.line - 1,
|
47
|
+
character: highlighted.end_pos
|
48
|
+
)
|
49
|
+
),
|
50
|
+
data: {
|
51
|
+
correctable: correctable?,
|
52
|
+
code_actions: to_lsp_code_actions
|
53
|
+
}
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def message
|
60
|
+
message = @offense.message
|
61
|
+
message += "\n\nThis offense is not auto-correctable.\n" unless correctable?
|
62
|
+
message
|
63
|
+
end
|
64
|
+
|
65
|
+
def severity
|
66
|
+
RUBOCOP_TO_LSP_SEVERITY[@offense.severity.name]
|
67
|
+
end
|
68
|
+
|
69
|
+
def code_description(config)
|
70
|
+
return unless @cop_class
|
71
|
+
|
72
|
+
if (doc_url = @cop_class.documentation_url(config))
|
73
|
+
Interface::CodeDescription.new(href: doc_url)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def autocorrect_action
|
78
|
+
Interface::CodeAction.new(
|
79
|
+
title: "Autocorrect #{@offense.cop_name}",
|
80
|
+
kind: Constant::CodeActionKind::QUICK_FIX,
|
81
|
+
edit: Interface::WorkspaceEdit.new(
|
82
|
+
document_changes: [
|
83
|
+
Interface::TextDocumentEdit.new(
|
84
|
+
text_document: Interface::OptionalVersionedTextDocumentIdentifier.new(
|
85
|
+
uri: ensure_uri_scheme(@uri.to_s).to_s,
|
86
|
+
version: nil
|
87
|
+
),
|
88
|
+
edits: correctable? ? offense_replacements : []
|
89
|
+
)
|
90
|
+
]
|
91
|
+
),
|
92
|
+
is_preferred: true
|
93
|
+
)
|
94
|
+
end
|
95
|
+
|
96
|
+
def offense_replacements
|
97
|
+
@offense.corrector.as_replacements.map do |range, replacement|
|
98
|
+
Interface::TextEdit.new(
|
99
|
+
range: Interface::Range.new(
|
100
|
+
start: Interface::Position.new(line: range.line - 1, character: range.column),
|
101
|
+
end: Interface::Position.new(line: range.last_line - 1, character: range.last_column)
|
102
|
+
),
|
103
|
+
new_text: replacement
|
104
|
+
)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def disable_line_action
|
109
|
+
Interface::CodeAction.new(
|
110
|
+
title: "Disable #{@offense.cop_name} for this line",
|
111
|
+
kind: Constant::CodeActionKind::QUICK_FIX,
|
112
|
+
edit: Interface::WorkspaceEdit.new(
|
113
|
+
document_changes: [
|
114
|
+
Interface::TextDocumentEdit.new(
|
115
|
+
text_document: Interface::OptionalVersionedTextDocumentIdentifier.new(
|
116
|
+
uri: ensure_uri_scheme(@uri.to_s).to_s,
|
117
|
+
version: nil
|
118
|
+
),
|
119
|
+
edits: line_disable_comment
|
120
|
+
)
|
121
|
+
]
|
122
|
+
)
|
123
|
+
)
|
124
|
+
end
|
125
|
+
|
126
|
+
def line_disable_comment
|
127
|
+
new_text = if @offense.source_line.include?(" # standard:disable ")
|
128
|
+
",#{@offense.cop_name}"
|
129
|
+
else
|
130
|
+
" # standard:disable #{@offense.cop_name}"
|
131
|
+
end
|
132
|
+
|
133
|
+
eol = Interface::Position.new(
|
134
|
+
line: @offense.line - 1,
|
135
|
+
character: length_of_line(@offense.source_line)
|
136
|
+
)
|
137
|
+
|
138
|
+
# TODO: fails for multiline strings - may be preferable to use block
|
139
|
+
# comments to disable some offenses
|
140
|
+
inline_comment = Interface::TextEdit.new(
|
141
|
+
range: Interface::Range.new(start: eol, end: eol),
|
142
|
+
new_text: new_text
|
143
|
+
)
|
144
|
+
|
145
|
+
[inline_comment]
|
146
|
+
end
|
147
|
+
|
148
|
+
def length_of_line(line)
|
149
|
+
if @document_encoding == Encoding::UTF_16LE
|
150
|
+
line_length = 0
|
151
|
+
line.codepoints.each do |codepoint|
|
152
|
+
line_length += 1
|
153
|
+
if codepoint > RubyLsp::Document::Scanner::SURROGATE_PAIR_START
|
154
|
+
line_length += 1
|
155
|
+
end
|
156
|
+
end
|
157
|
+
line_length
|
158
|
+
else
|
159
|
+
line.length
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def correctable?
|
164
|
+
!@offense.corrector.nil?
|
165
|
+
end
|
166
|
+
|
167
|
+
def ensure_uri_scheme(uri)
|
168
|
+
uri = URI.parse(uri)
|
169
|
+
uri.scheme = "file" if uri.scheme.nil?
|
170
|
+
uri
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
data/lib/standard/lsp/logger.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
module Standard
|
2
2
|
module Lsp
|
3
3
|
class Logger
|
4
|
-
def initialize
|
4
|
+
def initialize(prefix: "[server]")
|
5
|
+
@prefix = prefix
|
5
6
|
@puts_onces = []
|
6
7
|
end
|
7
8
|
|
8
9
|
def puts(message)
|
9
|
-
warn
|
10
|
+
warn [@prefix, message].compact.join(" ")
|
10
11
|
end
|
11
12
|
|
12
13
|
def puts_once(message)
|
data/lib/standard/lsp/routes.rb
CHANGED
@@ -13,7 +13,7 @@ module Standard
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.handle(name, &block)
|
16
|
-
define_method("handle_#{name}", &block)
|
16
|
+
define_method(:"handle_#{name}", &block)
|
17
17
|
end
|
18
18
|
|
19
19
|
def for(name)
|
@@ -27,10 +27,6 @@ module Standard
|
|
27
27
|
@writer.write(id: request[:id], result: Proto::Interface::InitializeResult.new(
|
28
28
|
capabilities: Proto::Interface::ServerCapabilities.new(
|
29
29
|
document_formatting_provider: true,
|
30
|
-
diagnostic_provider: LanguageServer::Protocol::Interface::DiagnosticOptions.new(
|
31
|
-
inter_file_dependencies: false,
|
32
|
-
workspace_diagnostics: false
|
33
|
-
),
|
34
30
|
text_document_sync: Proto::Interface::TextDocumentSyncOptions.new(
|
35
31
|
change: Proto::Constant::TextDocumentSyncKind::FULL,
|
36
32
|
open_close: true
|
@@ -51,12 +47,6 @@ module Standard
|
|
51
47
|
end
|
52
48
|
end
|
53
49
|
|
54
|
-
handle "textDocument/diagnostic" do |request|
|
55
|
-
doc = request[:params][:textDocument]
|
56
|
-
result = diagnostic(doc[:uri], doc[:text])
|
57
|
-
@writer.write(result)
|
58
|
-
end
|
59
|
-
|
60
50
|
handle "textDocument/didChange" do |request|
|
61
51
|
params = request[:params]
|
62
52
|
result = diagnostic(params[:textDocument][:uri], params[:contentChanges][0][:text])
|
@@ -82,8 +72,15 @@ module Standard
|
|
82
72
|
@logger.puts "Ignoring workspace/didChangeConfiguration"
|
83
73
|
end
|
84
74
|
|
75
|
+
CONFIGURATION_FILE_PATTERNS = [
|
76
|
+
".standard.yml",
|
77
|
+
".standard_todo.yml"
|
78
|
+
].freeze
|
79
|
+
|
85
80
|
handle "workspace/didChangeWatchedFiles" do |request|
|
86
|
-
if request[:params][:changes].any? { |change|
|
81
|
+
if request[:params][:changes].any? { |change|
|
82
|
+
CONFIGURATION_FILE_PATTERNS.any? { |path| change[:uri].end_with?(path) }
|
83
|
+
}
|
87
84
|
@logger.puts "Configuration file changed; restart required"
|
88
85
|
@kills_server.call
|
89
86
|
end
|
@@ -164,45 +161,12 @@ module Standard
|
|
164
161
|
|
165
162
|
def diagnostic(file_uri, text)
|
166
163
|
@text_cache[file_uri] = text
|
167
|
-
offenses = @standardizer.offenses(uri_to_path(file_uri), text)
|
168
|
-
|
169
|
-
lsp_diagnostics = offenses.map { |o|
|
170
|
-
code = o[:cop_name]
|
171
|
-
|
172
|
-
msg = o[:message].delete_prefix(code)
|
173
|
-
loc = o[:location]
|
174
|
-
|
175
|
-
severity = case o[:severity]
|
176
|
-
when "error", "fatal"
|
177
|
-
SEV::ERROR
|
178
|
-
when "warning"
|
179
|
-
SEV::WARNING
|
180
|
-
when "convention"
|
181
|
-
SEV::INFORMATION
|
182
|
-
when "refactor", "info"
|
183
|
-
SEV::HINT
|
184
|
-
else # the above cases fully cover what RuboCop sends at this time
|
185
|
-
logger.puts "Unknown severity: #{severity.inspect}"
|
186
|
-
SEV::HINT
|
187
|
-
end
|
188
|
-
|
189
|
-
{
|
190
|
-
code: code,
|
191
|
-
message: msg,
|
192
|
-
range: {
|
193
|
-
start: {character: loc[:start_column] - 1, line: loc[:start_line] - 1},
|
194
|
-
end: {character: loc[:last_column] - 1, line: loc[:last_line] - 1}
|
195
|
-
},
|
196
|
-
severity: severity,
|
197
|
-
source: "standard"
|
198
|
-
}
|
199
|
-
}
|
200
164
|
|
201
165
|
{
|
202
166
|
method: "textDocument/publishDiagnostics",
|
203
167
|
params: {
|
204
168
|
uri: file_uri,
|
205
|
-
diagnostics:
|
169
|
+
diagnostics: @standardizer.offenses(uri_to_path(file_uri), text)
|
206
170
|
}
|
207
171
|
}
|
208
172
|
end
|
data/lib/standard/lsp/server.rb
CHANGED
@@ -13,11 +13,12 @@ module Standard
|
|
13
13
|
@writer = Proto::Transport::Io::Writer.new($stdout)
|
14
14
|
@reader = Proto::Transport::Io::Reader.new($stdin)
|
15
15
|
@logger = Logger.new
|
16
|
-
@standardizer = Standard::Lsp::Standardizer.new(config
|
16
|
+
@standardizer = Standard::Lsp::Standardizer.new(config)
|
17
17
|
@routes = Routes.new(@writer, @logger, @standardizer)
|
18
18
|
end
|
19
19
|
|
20
20
|
def start
|
21
|
+
RuboCop::LSP.enable
|
21
22
|
@reader.read do |request|
|
22
23
|
if !request.key?(:method)
|
23
24
|
@routes.handle_method_missing(request)
|
@@ -1,68 +1,33 @@
|
|
1
|
-
require_relative "
|
1
|
+
require_relative "stdin_rubocop_runner"
|
2
|
+
require_relative "diagnostic"
|
2
3
|
|
3
4
|
module Standard
|
4
5
|
module Lsp
|
5
6
|
class Standardizer
|
6
|
-
def initialize(config
|
7
|
-
@
|
8
|
-
@
|
9
|
-
|
7
|
+
def initialize(config)
|
8
|
+
@diagnostic_runner = ::Standard::Lsp::StdinRubocopRunner.new(config)
|
9
|
+
@format_runner = ::Standard::Lsp::StdinRubocopRunner.new(config.dup.tap { |c|
|
10
|
+
c.rubocop_options[:autocorrect] = true
|
11
|
+
})
|
12
|
+
@cop_registry = RuboCop::Cop::Registry.global.to_h
|
10
13
|
end
|
11
14
|
|
12
|
-
# This abuses the --stdin option of rubocop and reads the formatted text
|
13
|
-
# from the options[:stdin] that rubocop mutates. This depends on
|
14
|
-
# parallel: false as well as the fact that rubocop doesn't otherwise dup
|
15
|
-
# or reassign that options object. Risky business!
|
16
|
-
#
|
17
|
-
# Reassigning options[:stdin] is done here:
|
18
|
-
# https://github.com/rubocop/rubocop/blob/master/lib/rubocop/cop/team.rb#L131
|
19
|
-
# Printing options[:stdin]
|
20
|
-
# https://github.com/rubocop/rubocop/blob/master/lib/rubocop/cli/command/execute_runner.rb#L95
|
21
|
-
# Setting `parallel: true` would break this here:
|
22
|
-
# https://github.com/rubocop/rubocop/blob/master/lib/rubocop/runner.rb#L72
|
23
15
|
def format(path, text)
|
24
|
-
|
25
|
-
|
26
|
-
ad_hoc_config.rubocop_options[:stdin]
|
16
|
+
@format_runner.run(path, text)
|
17
|
+
@format_runner.formatted_source
|
27
18
|
end
|
28
19
|
|
29
|
-
def offenses(path, text)
|
30
|
-
|
31
|
-
capture_rubocop_stdout(fork_config(path, text, format: false)),
|
32
|
-
symbolize_names: true
|
33
|
-
)
|
34
|
-
if results[:files].empty?
|
35
|
-
@logger.puts_once "Ignoring file, per configuration: #{path}"
|
36
|
-
[]
|
37
|
-
else
|
38
|
-
results.dig(:files, 0, :offenses)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
20
|
+
def offenses(path, text, document_encoding = nil)
|
21
|
+
@diagnostic_runner.run(path, text)
|
43
22
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
options = if format
|
52
|
-
{stdin: text, autocorrect: true, safe_autocorrect: true, formatters: []}
|
53
|
-
else
|
54
|
-
{stdin: text, autocorrect: false, safe_autocorrect: false, formatters: [["json"]], format: "json"}
|
23
|
+
@diagnostic_runner.offenses.map do |offense|
|
24
|
+
Diagnostic.new(
|
25
|
+
document_encoding,
|
26
|
+
offense,
|
27
|
+
path,
|
28
|
+
@cop_registry[offense.cop_name]&.first
|
29
|
+
).to_lsp_diagnostic(@diagnostic_runner.config_for_working_directory)
|
55
30
|
end
|
56
|
-
Standard::Config.new(@config.runner, [path], BASE_OPTIONS.merge(options), @config.rubocop_config_store)
|
57
|
-
end
|
58
|
-
|
59
|
-
def capture_rubocop_stdout(config)
|
60
|
-
redir = StringIO.new
|
61
|
-
$stdout = redir
|
62
|
-
@rubocop_runner.call(config)
|
63
|
-
redir.string
|
64
|
-
ensure
|
65
|
-
$stdout = STDOUT
|
66
31
|
end
|
67
32
|
end
|
68
33
|
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Standard
|
2
|
+
module Lsp
|
3
|
+
# Originally lifted from:
|
4
|
+
# https://github.com/Shopify/ruby-lsp/blob/8d4c17efce4e8ecc8e7c557ab2981db6b22c0b6d/lib/ruby_lsp/requests/support/rubocop_runner.rb#L20
|
5
|
+
class StdinRubocopRunner < ::RuboCop::Runner
|
6
|
+
class ConfigurationError < StandardError; end
|
7
|
+
|
8
|
+
attr_reader :offenses
|
9
|
+
|
10
|
+
attr_reader :config_for_working_directory
|
11
|
+
|
12
|
+
DEFAULT_RUBOCOP_OPTIONS = {
|
13
|
+
stderr: true,
|
14
|
+
force_exclusion: true,
|
15
|
+
formatters: ["RuboCop::Formatter::BaseFormatter"],
|
16
|
+
raise_cop_error: true,
|
17
|
+
todo_file: nil,
|
18
|
+
todo_ignore_files: []
|
19
|
+
}.freeze
|
20
|
+
|
21
|
+
def initialize(config)
|
22
|
+
@options = {}
|
23
|
+
@offenses = []
|
24
|
+
@errors = []
|
25
|
+
@warnings = []
|
26
|
+
|
27
|
+
@config_for_working_directory = config.rubocop_config_store.for_pwd
|
28
|
+
|
29
|
+
super(
|
30
|
+
config.rubocop_options.merge(DEFAULT_RUBOCOP_OPTIONS),
|
31
|
+
config.rubocop_config_store
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
def run(path, contents)
|
36
|
+
@errors = []
|
37
|
+
@warnings = []
|
38
|
+
@offenses = []
|
39
|
+
@options[:stdin] = contents
|
40
|
+
|
41
|
+
super([path])
|
42
|
+
|
43
|
+
raise Interrupt if aborting?
|
44
|
+
rescue ::RuboCop::Runner::InfiniteCorrectionLoop => error
|
45
|
+
raise RubyLsp::Requests::Formatting::Erro, error.message
|
46
|
+
rescue ::RuboCop::ValidationError => error
|
47
|
+
raise ConfigurationError, error.message
|
48
|
+
rescue => error
|
49
|
+
raise ::RubyLsp::Requests::Support::InternalRuboCopError, error
|
50
|
+
end
|
51
|
+
|
52
|
+
def formatted_source
|
53
|
+
@options[:stdin]
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def file_finished(_file, offenses)
|
59
|
+
@offenses = offenses
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/standard/version.rb
CHANGED
data/standard.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.version = Standard::VERSION
|
8
8
|
spec.authors = ["Justin Searls"]
|
9
9
|
spec.email = ["searls@gmail.com"]
|
10
|
-
spec.required_ruby_version = ">=
|
10
|
+
spec.required_ruby_version = ">= 3.0.0"
|
11
11
|
|
12
12
|
spec.summary = "Ruby Style Guide, with linter & automatic code fixer"
|
13
13
|
spec.homepage = "https://github.com/standardrb/standard"
|
@@ -23,11 +23,11 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
spec.metadata["rubygems_mfa_required"] = "true"
|
25
25
|
|
26
|
-
spec.add_dependency "rubocop", "~> 1.
|
26
|
+
spec.add_dependency "rubocop", "~> 1.65.0"
|
27
27
|
|
28
28
|
spec.add_dependency "lint_roller", "~> 1.0"
|
29
29
|
spec.add_dependency "standard-custom", "~> 1.0.0"
|
30
|
-
spec.add_dependency "standard-performance", "~> 1.
|
30
|
+
spec.add_dependency "standard-performance", "~> 1.4"
|
31
31
|
|
32
32
|
# not semver: first three are lsp protocol version, last is patch
|
33
33
|
spec.add_dependency "language_server-protocol", "~> 3.17.0.2"
|
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.40.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Searls
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-08-13 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.65.0
|
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.65.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: lint_roller
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '1.
|
61
|
+
version: '1.4'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '1.
|
68
|
+
version: '1.4'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: language_server-protocol
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -117,11 +117,14 @@ files:
|
|
117
117
|
- config/ruby-3.0.yml
|
118
118
|
- config/ruby-3.1.yml
|
119
119
|
- config/ruby-3.2.yml
|
120
|
+
- config/ruby-3.3.yml
|
120
121
|
- docs/ARCHITECTURE.md
|
121
122
|
- docs/NEW_RUBIES.md
|
122
123
|
- docs/RELEASE.md
|
123
124
|
- docs/UPGRADING.md
|
124
125
|
- exe/standardrb
|
126
|
+
- lib/ruby_lsp/standard/addon.rb
|
127
|
+
- lib/ruby_lsp/standard/wraps_built_in_lsp_standardizer.rb
|
125
128
|
- lib/standard.rb
|
126
129
|
- lib/standard/base.rb
|
127
130
|
- lib/standard/base/plugin.rb
|
@@ -136,11 +139,13 @@ files:
|
|
136
139
|
- lib/standard/formatter.rb
|
137
140
|
- lib/standard/loads_runner.rb
|
138
141
|
- lib/standard/loads_yaml_config.rb
|
142
|
+
- lib/standard/lsp/diagnostic.rb
|
139
143
|
- lib/standard/lsp/kills_server.rb
|
140
144
|
- lib/standard/lsp/logger.rb
|
141
145
|
- lib/standard/lsp/routes.rb
|
142
146
|
- lib/standard/lsp/server.rb
|
143
147
|
- lib/standard/lsp/standardizer.rb
|
148
|
+
- lib/standard/lsp/stdin_rubocop_runner.rb
|
144
149
|
- lib/standard/merges_settings.rb
|
145
150
|
- lib/standard/plugin.rb
|
146
151
|
- lib/standard/plugin/combines_plugin_configs.rb
|
@@ -176,14 +181,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
176
181
|
requirements:
|
177
182
|
- - ">="
|
178
183
|
- !ruby/object:Gem::Version
|
179
|
-
version:
|
184
|
+
version: 3.0.0
|
180
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
186
|
requirements:
|
182
187
|
- - ">="
|
183
188
|
- !ruby/object:Gem::Version
|
184
189
|
version: '0'
|
185
190
|
requirements: []
|
186
|
-
rubygems_version: 3.
|
191
|
+
rubygems_version: 3.4.10
|
187
192
|
signing_key:
|
188
193
|
specification_version: 4
|
189
194
|
summary: Ruby Style Guide, with linter & automatic code fixer
|