standard 1.37.0 → 1.38.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +5 -1
- data/.standard.yml +1 -1
- data/CHANGELOG.md +13 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +10 -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 +60 -0
- data/lib/ruby_lsp/standard/wraps_built_in_lsp_standardizer.rb +98 -0
- data/lib/standard/base/plugin.rb +2 -0
- data/lib/standard/lsp/routes.rb +1 -1
- data/lib/standard/plugin/merges_plugins_into_rubocop_config.rb +1 -1
- data/lib/standard/version.rb +1 -1
- data/standard.gemspec +1 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f78e04ed9ba26c056a144f8584e28ade38906bf4f0e5078802654cd5d7b99082
|
4
|
+
data.tar.gz: 7d6b129ca13e5cbb8dc9ffed5891edcd81975780873501443f125906846d8a3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8de4b19e062290cbc42f4b9d3f73cc2b1412b9dc683b6499a0d443b32f598e1a7d48e0f46f1e4343f18a6032ba6a3fb74a3b90a00257e4f3777ecbc73d5fd758
|
7
|
+
data.tar.gz: 42bf30e5370ca89431b4c8546320fb3c840c1ce7c7256dae9f516ed88f71f8ad1a1b77ea644c417d3ecab3ce98481aecc29211965b6f1c18903d5eccaa9cfc78
|
data/.github/workflows/test.yml
CHANGED
data/.standard.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## Unreleased
|
4
|
+
|
5
|
+
## 1.38.0
|
6
|
+
|
7
|
+
* Update minimum Ruby version to 3.0
|
8
|
+
* @koic backported a line column bug in our LSP
|
9
|
+
[#635](https://github.com/standardrb/standard/pull/635)
|
10
|
+
* Implement a basic [Ruby LSP
|
11
|
+
add-on](https://github.com/Shopify/ruby-lsp/blob/main/ADDONS.md), which means
|
12
|
+
users would no longer need to install [our custom VS Code
|
13
|
+
extension](https://marketplace.visualstudio.com/items?itemName=testdouble.vscode-standard-ruby)
|
14
|
+
[#630](https://github.com/standardrb/standard/pull/630)
|
15
|
+
|
3
16
|
## 1.37.0
|
4
17
|
|
5
18
|
* Updates rubocop to [1.64.1](https://github.com/rubocop/rubocop/releases/tag/v1.64.1)
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
standard (1.
|
4
|
+
standard (1.38.0)
|
5
5
|
language_server-protocol (~> 3.17.0.2)
|
6
6
|
lint_roller (~> 1.0)
|
7
7
|
rubocop (~> 1.64.0)
|
@@ -21,10 +21,12 @@ GEM
|
|
21
21
|
rake (>= 0.9.2.2)
|
22
22
|
method_source (1.0.0)
|
23
23
|
minitest (5.20.0)
|
24
|
+
mutex_m (0.2.0)
|
24
25
|
parallel (1.23.0)
|
25
26
|
parser (3.3.0.5)
|
26
27
|
ast (~> 2.4.1)
|
27
28
|
racc
|
29
|
+
prism (0.27.0)
|
28
30
|
racc (1.7.1)
|
29
31
|
rainbow (3.1.1)
|
30
32
|
rake (13.0.6)
|
@@ -46,6 +48,10 @@ GEM
|
|
46
48
|
rubocop-performance (1.21.0)
|
47
49
|
rubocop (>= 1.48.1, < 2.0)
|
48
50
|
rubocop-ast (>= 1.31.1, < 2.0)
|
51
|
+
ruby-lsp (0.16.6)
|
52
|
+
language_server-protocol (~> 3.17.0)
|
53
|
+
prism (>= 0.23.0, < 0.28)
|
54
|
+
sorbet-runtime (>= 0.5.10782)
|
49
55
|
ruby-progressbar (1.13.0)
|
50
56
|
simplecov (0.22.0)
|
51
57
|
docile (~> 1.1)
|
@@ -53,6 +59,7 @@ GEM
|
|
53
59
|
simplecov_json_formatter (~> 0.1)
|
54
60
|
simplecov-html (0.12.3)
|
55
61
|
simplecov_json_formatter (0.1.4)
|
62
|
+
sorbet-runtime (0.5.11385)
|
56
63
|
standard-custom (1.0.2)
|
57
64
|
lint_roller (~> 1.0)
|
58
65
|
rubocop (~> 1.50)
|
@@ -69,7 +76,9 @@ DEPENDENCIES
|
|
69
76
|
bundler
|
70
77
|
m
|
71
78
|
minitest (~> 5.0)
|
79
|
+
mutex_m
|
72
80
|
rake (~> 13.0)
|
81
|
+
ruby-lsp
|
73
82
|
simplecov
|
74
83
|
standard!
|
75
84
|
|
data/config/default.yml
CHANGED
data/config/ruby-3.2.yml
CHANGED
data/config/ruby-3.3.yml
ADDED
@@ -0,0 +1,60 @@
|
|
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 initializer
|
8
|
+
@wraps_built_in_lsp_standardizer = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
def name
|
12
|
+
"Standard Ruby"
|
13
|
+
end
|
14
|
+
|
15
|
+
def activate(global_state, message_queue)
|
16
|
+
warn "Activating Standard Ruby LSP addon v#{::Standard::VERSION}"
|
17
|
+
@wraps_built_in_lsp_standardizer = WrapsBuiltinLspStandardizer.new
|
18
|
+
global_state.register_formatter("standard", @wraps_built_in_lsp_standardizer)
|
19
|
+
register_additional_file_watchers(global_state, message_queue)
|
20
|
+
warn "Initialized Standard Ruby LSP addon #{::Standard::VERSION}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def deactivate
|
24
|
+
@wraps_built_in_lsp_standardizer = nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def register_additional_file_watchers(global_state, message_queue)
|
28
|
+
return unless global_state.supports_watching_files
|
29
|
+
|
30
|
+
message_queue << Request.new(
|
31
|
+
id: "standard-file-watcher",
|
32
|
+
method: "client/registerCapability",
|
33
|
+
params: Interface::RegistrationParams.new(
|
34
|
+
registrations: [
|
35
|
+
Interface::Registration.new(
|
36
|
+
id: "workspace/didChangeWatchedFilesStandard",
|
37
|
+
method: "workspace/didChangeWatchedFiles",
|
38
|
+
register_options: Interface::DidChangeWatchedFilesRegistrationOptions.new(
|
39
|
+
watchers: [
|
40
|
+
Interface::FileSystemWatcher.new(
|
41
|
+
glob_pattern: "**/.standard.yml",
|
42
|
+
kind: Constant::WatchKind::CREATE | Constant::WatchKind::CHANGE | Constant::WatchKind::DELETE
|
43
|
+
)
|
44
|
+
]
|
45
|
+
)
|
46
|
+
)
|
47
|
+
]
|
48
|
+
)
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
def workspace_did_change_watched_files(changes)
|
53
|
+
if changes.any? { |change| change[:uri].end_with?(".standard.yml") }
|
54
|
+
@wraps_built_in_lsp_standardizer.init!
|
55
|
+
warn "Re-initialized Standard Ruby LSP addon #{::Standard::VERSION} due to .standard.yml file change"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,98 @@
|
|
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
|
+
@config = ::Standard::BuildsConfig.new.call([])
|
11
|
+
@standardizer = ::Standard::Lsp::Standardizer.new(
|
12
|
+
@config,
|
13
|
+
::Standard::Lsp::Logger.new
|
14
|
+
)
|
15
|
+
@rubocop_config = @config.rubocop_config_store.for_pwd
|
16
|
+
@cop_registry = RuboCop::Cop::Registry.global.to_h
|
17
|
+
end
|
18
|
+
|
19
|
+
def run_formatting(uri, document)
|
20
|
+
@standardizer.format(uri_to_path(uri), document.source)
|
21
|
+
end
|
22
|
+
|
23
|
+
def run_diagnostic(uri, document)
|
24
|
+
offenses = @standardizer.offenses(uri_to_path(uri), document.source)
|
25
|
+
|
26
|
+
offenses.map { |o|
|
27
|
+
cop_name = o[:cop_name]
|
28
|
+
|
29
|
+
msg = o[:message].delete_prefix(cop_name)
|
30
|
+
loc = o[:location]
|
31
|
+
|
32
|
+
severity = case o[:severity]
|
33
|
+
when "error", "fatal"
|
34
|
+
RubyLsp::Constant::DiagnosticSeverity::ERROR
|
35
|
+
when "warning"
|
36
|
+
RubyLsp::Constant::DiagnosticSeverity::WARNING
|
37
|
+
when "convention"
|
38
|
+
RubyLsp::Constant::DiagnosticSeverity::INFORMATION
|
39
|
+
when "refactor", "info"
|
40
|
+
RubyLsp::Constant::DiagnosticSeverity::HINT
|
41
|
+
else # the above cases fully cover what RuboCop sends at this time
|
42
|
+
logger.puts "Unknown severity: #{severity.inspect}"
|
43
|
+
RubyLsp::Constant::DiagnosticSeverity::HINT
|
44
|
+
end
|
45
|
+
|
46
|
+
RubyLsp::Interface::Diagnostic.new(
|
47
|
+
code: cop_name,
|
48
|
+
code_description: code_description(cop_name),
|
49
|
+
message: msg,
|
50
|
+
source: "Standard Ruby",
|
51
|
+
severity: severity,
|
52
|
+
range: RubyLsp::Interface::Range.new(
|
53
|
+
start: RubyLsp::Interface::Position.new(line: loc[:start_line] - 1, character: loc[:start_column] - 1),
|
54
|
+
end: RubyLsp::Interface::Position.new(line: loc[:last_line] - 1, character: loc[:last_column])
|
55
|
+
)
|
56
|
+
# TODO: We need to do something like to support quickfixes thru code actions
|
57
|
+
# See: https://github.com/Shopify/ruby-lsp/blob/4c1906172add4d5c39c35d3396aa29c768bfb898/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb#L62
|
58
|
+
# data: {
|
59
|
+
# correctable: correctable?(offense),
|
60
|
+
# code_actions: to_lsp_code_actions
|
61
|
+
# }
|
62
|
+
#
|
63
|
+
# Right now, our offenses are all just JSON parsed from stdout shelling to RuboCop, so
|
64
|
+
# it seems we don't have the corrector available to us.
|
65
|
+
#
|
66
|
+
# Lifted from:
|
67
|
+
# https://github.com/Shopify/ruby-lsp/blob/8d4c17efce4e8ecc8e7c557ab2981db6b22c0b6d/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb#L201
|
68
|
+
# def correctable?(offense)
|
69
|
+
# !offense.corrector.nil?
|
70
|
+
# end
|
71
|
+
)
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
# duplicated from: lib/standard/lsp/routes.rb
|
78
|
+
# modified to incorporate Ruby LSP's to_standardized_path method
|
79
|
+
def uri_to_path(uri)
|
80
|
+
if uri.respond_to?(:to_standardized_path) && !(standardized_path = uri.to_standardized_path).nil?
|
81
|
+
standardized_path
|
82
|
+
else
|
83
|
+
uri.to_s.sub(%r{^file://}, "")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# lifted from:
|
88
|
+
# https://github.com/Shopify/ruby-lsp/blob/4c1906172add4d5c39c35d3396aa29c768bfb898/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb#L84
|
89
|
+
def code_description(cop_name)
|
90
|
+
if (cop_class = @cop_registry[cop_name]&.first)
|
91
|
+
if (doc_url = cop_class.documentation_url(@rubocop_config))
|
92
|
+
Interface::CodeDescription.new(href: doc_url)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
data/lib/standard/base/plugin.rb
CHANGED
data/lib/standard/lsp/routes.rb
CHANGED
@@ -181,7 +181,7 @@ module Standard
|
|
181
181
|
message: msg,
|
182
182
|
range: {
|
183
183
|
start: {character: loc[:start_column] - 1, line: loc[:start_line] - 1},
|
184
|
-
end: {character: loc[:last_column]
|
184
|
+
end: {character: loc[:last_column], line: loc[:last_line] - 1}
|
185
185
|
},
|
186
186
|
severity: severity,
|
187
187
|
source: "standard"
|
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"
|
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.38.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: 2024-06-
|
11
|
+
date: 2024-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -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
|
@@ -176,14 +179,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
176
179
|
requirements:
|
177
180
|
- - ">="
|
178
181
|
- !ruby/object:Gem::Version
|
179
|
-
version:
|
182
|
+
version: 3.0.0
|
180
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
184
|
requirements:
|
182
185
|
- - ">="
|
183
186
|
- !ruby/object:Gem::Version
|
184
187
|
version: '0'
|
185
188
|
requirements: []
|
186
|
-
rubygems_version: 3.
|
189
|
+
rubygems_version: 3.5.9
|
187
190
|
signing_key:
|
188
191
|
specification_version: 4
|
189
192
|
summary: Ruby Style Guide, with linter & automatic code fixer
|