standard 1.36.0 → 1.38.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4cce4c8b3cfe5994fa8931693c13c9bdf987433cf956f5d6648bf67f6bdb2d5f
4
- data.tar.gz: 17e17f6fa6a3d5e829f20ebcc0ba5a6539d41b634df5de0730f1f8c9918d21ec
3
+ metadata.gz: f78e04ed9ba26c056a144f8584e28ade38906bf4f0e5078802654cd5d7b99082
4
+ data.tar.gz: 7d6b129ca13e5cbb8dc9ffed5891edcd81975780873501443f125906846d8a3c
5
5
  SHA512:
6
- metadata.gz: 84f3243ad0d727237653f1d76dcee395e7a46e594734a4257c64faf881bd54da3e0856d673cab6c89f9cb81475cb5a564e0aa69319b154207fc7c02baa3c0bff
7
- data.tar.gz: 148af7206a5f02c14b389f02dfa97507b697cf10b3119a307c4d0f5f7a7ca143411d958c7cce5ffb95d9e02c227cdb15ca7f6de321dbbc68612bfded6f9293e3
6
+ metadata.gz: 8de4b19e062290cbc42f4b9d3f73cc2b1412b9dc683b6499a0d443b32f598e1a7d48e0f46f1e4343f18a6032ba6a3fb74a3b90a00257e4f3777ecbc73d5fd758
7
+ data.tar.gz: 42bf30e5370ca89431b4c8546320fb3c840c1ce7c7256dae9f516ed88f71f8ad1a1b77ea644c417d3ecab3ce98481aecc29211965b6f1c18903d5eccaa9cfc78
@@ -16,7 +16,11 @@ jobs:
16
16
  strategy:
17
17
  matrix:
18
18
  os: [ubuntu-latest]
19
- ruby-version: [2.7, '3.0', 3.1, 3.2, 3.3]
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
 
data/.standard.yml CHANGED
@@ -1,4 +1,4 @@
1
- ruby_version: 2.6
1
+ ruby_version: 3.0
2
2
  ignore:
3
3
  - tmp/**/*
4
4
  - test/fixture/**/*
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
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
+
16
+ ## 1.37.0
17
+
18
+ * Updates rubocop to [1.64.1](https://github.com/rubocop/rubocop/releases/tag/v1.64.1)
19
+
3
20
  ## 1.36.0
4
21
 
5
22
  * Updates rubocop to [1.63.5](https://github.com/rubocop/rubocop/releases/tag/v1.63.5)
data/Gemfile CHANGED
@@ -6,6 +6,8 @@ gem "bundler"
6
6
  gem "minitest", "~> 5.0"
7
7
  gem "rake", "~> 13.0"
8
8
  gem "m"
9
+ gem "mutex_m"
10
+ gem "ruby-lsp"
9
11
 
10
12
  # You may want to run these off path locally:
11
13
  # gem "lint_roller", path: "../lint_roller"
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- standard (1.36.0)
4
+ standard (1.38.0)
5
5
  language_server-protocol (~> 3.17.0.2)
6
6
  lint_roller (~> 1.0)
7
- rubocop (~> 1.63.0)
7
+ rubocop (~> 1.64.0)
8
8
  standard-custom (~> 1.0.0)
9
9
  standard-performance (~> 1.4)
10
10
 
@@ -21,16 +21,18 @@ 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)
31
33
  regexp_parser (2.8.2)
32
34
  rexml (3.2.6)
33
- rubocop (1.63.5)
35
+ rubocop (1.64.1)
34
36
  json (~> 2.3)
35
37
  language_server-protocol (>= 3.17.0)
36
38
  parallel (~> 1.10)
@@ -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/README.md CHANGED
@@ -502,6 +502,7 @@ Here are a few examples of Ruby Standard-compliant teams & projects:
502
502
  * [thoughtbot](https://thoughtbot.com/)
503
503
  * [Topkey](https://topkey.io)
504
504
  * [University of Wisconsin-Eau Claire](https://www.uwec.edu/)
505
+ * [Cartwheel](https://www.cartwheel.org)
505
506
 
506
507
  Does your team use Standard? [Add your name to the list](https://github.com/standardrb/standard/edit/main/README.md)!
507
508
 
data/config/base.yml CHANGED
@@ -1662,6 +1662,9 @@ Style/Semicolon:
1662
1662
  Style/Send:
1663
1663
  Enabled: false
1664
1664
 
1665
+ Style/SendWithLiteralMethodName:
1666
+ Enabled: false
1667
+
1665
1668
  Style/SignalException:
1666
1669
  Enabled: false
1667
1670
 
@@ -1724,6 +1727,9 @@ Style/Strip:
1724
1727
  Style/StructInheritance:
1725
1728
  Enabled: false
1726
1729
 
1730
+ Style/SuperArguments:
1731
+ Enabled: true
1732
+
1727
1733
  Style/SuperWithArgsParentheses:
1728
1734
  Enabled: true
1729
1735
 
data/config/default.yml CHANGED
@@ -1,6 +1,5 @@
1
1
  AllCops:
2
- # Prevent RuboCop from exploding when it finds an older-than-2.6 .ruby-version
3
- TargetRubyVersion: 2.6
2
+ TargetRubyVersion: 3.0
4
3
  Exclude: []
5
4
  DisabledByDefault: true
6
5
  StyleGuideBaseURL: https://github.com/standardrb/standard
data/config/ruby-3.2.yml CHANGED
@@ -1,4 +1,4 @@
1
- inherit_from: ./base.yml
1
+ inherit_from: ./ruby-3.3.yml
2
2
 
3
3
  AllCops:
4
4
  TargetRubyVersion: 3.2
@@ -0,0 +1,4 @@
1
+ inherit_from: ./base.yml
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 3.3
@@ -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
@@ -57,6 +57,8 @@ module Standard::Base
57
57
  "ruby-3.1.yml"
58
58
  elsif desired_version < Gem::Version.new("3.3")
59
59
  "ruby-3.2.yml"
60
+ elsif desired_version < Gem::Version.new("3.4")
61
+ "ruby-3.3.yml"
60
62
  else
61
63
  default
62
64
  end
@@ -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,10 +47,6 @@ module Standard
51
47
  end
52
48
  end
53
49
 
54
- handle "textDocument/diagnostic" do |_request|
55
- # no op, diagnostics are handled in textDocument/didChange
56
- end
57
-
58
50
  handle "textDocument/didChange" do |request|
59
51
  params = request[:params]
60
52
  result = diagnostic(params[:textDocument][:uri], params[:contentChanges][0][:text])
@@ -189,7 +181,7 @@ module Standard
189
181
  message: msg,
190
182
  range: {
191
183
  start: {character: loc[:start_column] - 1, line: loc[:start_line] - 1},
192
- end: {character: loc[:last_column] - 1, line: loc[:last_line] - 1}
184
+ end: {character: loc[:last_column], line: loc[:last_line] - 1}
193
185
  },
194
186
  severity: severity,
195
187
  source: "standard"
@@ -154,7 +154,7 @@ module Standard
154
154
  end
155
155
 
156
156
  def except(hash_or_config, keys)
157
- hash_or_config.to_h.reject { |key, _| keys.include?(key) }.to_h
157
+ hash_or_config.to_h.except(*keys).to_h
158
158
  end
159
159
 
160
160
  # Always deletes nil entries, always overwrites arrays
@@ -1,3 +1,3 @@
1
1
  module Standard
2
- VERSION = Gem::Version.new("1.36.0")
2
+ VERSION = Gem::Version.new("1.38.0")
3
3
  end
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 = ">= 2.6.0"
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,7 +23,7 @@ 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.63.0"
26
+ spec.add_dependency "rubocop", "~> 1.64.0"
27
27
 
28
28
  spec.add_dependency "lint_roller", "~> 1.0"
29
29
  spec.add_dependency "standard-custom", "~> 1.0.0"
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.36.0
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-05-14 00:00:00.000000000 Z
11
+ date: 2024-06-23 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.63.0
19
+ version: 1.64.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.63.0
26
+ version: 1.64.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: lint_roller
29
29
  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
@@ -176,14 +179,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
176
179
  requirements:
177
180
  - - ">="
178
181
  - !ruby/object:Gem::Version
179
- version: 2.6.0
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.1.6
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