standard 0.1.0 → 1.51.1
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/dependabot.yml +11 -0
- data/.github/workflows/test.yml +24 -0
- data/.github/workflows/update.yml +54 -0
- data/.gitignore +3 -0
- data/.standard.yml +1 -1
- data/CHANGELOG.md +703 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +71 -37
- data/LICENSE.txt +3 -4
- data/README.md +459 -264
- data/Rakefile +5 -4
- data/bin/console +0 -4
- data/bin/rake +27 -0
- data/bin/run +9 -0
- data/config/base.yml +1065 -193
- data/config/default.yml +8 -0
- data/config/ruby-1.8.yml +10 -2
- data/config/ruby-1.9.yml +11 -1
- data/config/ruby-2.0.yml +4 -0
- data/config/ruby-2.1.yml +4 -0
- data/config/ruby-2.2.yml +13 -5
- data/config/ruby-2.3.yml +10 -0
- data/config/ruby-2.4.yml +10 -0
- data/config/ruby-2.5.yml +10 -0
- data/config/ruby-2.6.yml +13 -0
- data/config/ruby-2.7.yml +10 -0
- data/config/ruby-3.0.yml +13 -0
- data/config/ruby-3.1.yml +11 -0
- data/config/ruby-3.2.yml +4 -0
- data/config/ruby-3.3.yml +7 -0
- data/docs/ARCHITECTURE.md +33 -0
- data/docs/RELEASE.md +41 -0
- data/docs/RUBY_VERSIONS.md +51 -0
- data/docs/UPGRADING.md +31 -0
- data/lib/ruby_lsp/standard/addon.rb +58 -0
- data/lib/ruby_lsp/standard/wraps_built_in_lsp_standardizer.rb +44 -0
- data/lib/standard/base/plugin.rb +69 -0
- data/lib/standard/base.rb +8 -0
- data/lib/standard/builds_config.rb +11 -1
- data/lib/standard/cli.rb +1 -7
- data/lib/standard/creates_config_store/assigns_rubocop_yaml.rb +2 -18
- data/lib/standard/creates_config_store/configures_ignored_paths.rb +2 -2
- data/lib/standard/creates_config_store/merges_user_config_extensions.rb +37 -0
- data/lib/standard/creates_config_store/sets_target_ruby_version.rb +21 -8
- data/lib/standard/creates_config_store.rb +5 -0
- data/lib/standard/formatter.rb +92 -37
- data/lib/standard/loads_runner.rb +17 -3
- data/lib/standard/loads_yaml_config.rb +18 -11
- data/lib/standard/lsp/diagnostic.rb +174 -0
- data/lib/standard/lsp/kills_server.rb +10 -0
- data/lib/standard/lsp/logger.rb +21 -0
- data/lib/standard/lsp/routes.rb +175 -0
- data/lib/standard/lsp/server.rb +37 -0
- data/lib/standard/lsp/standardizer.rb +34 -0
- data/lib/standard/lsp/stdin_rubocop_runner.rb +71 -0
- data/lib/standard/merges_settings.rb +22 -11
- data/lib/standard/plugin/combines_plugin_configs.rb +15 -0
- data/lib/standard/plugin/creates_runner_context.rb +15 -0
- data/lib/standard/plugin/determines_class_constant.rb +56 -0
- data/lib/standard/plugin/initializes_plugins.rb +23 -0
- data/lib/standard/plugin/merges_plugins_into_rubocop_config.rb +177 -0
- data/lib/standard/plugin/standardizes_configured_plugins.rb +37 -0
- data/lib/standard/plugin.rb +11 -0
- data/lib/standard/railtie.rb +1 -1
- data/lib/standard/rake.rb +8 -1
- data/lib/standard/{parses_cli_option.rb → resolves_yaml_option.rb} +9 -2
- data/lib/standard/rubocop/ext.rb +17 -0
- data/lib/standard/runners/genignore.rb +44 -0
- data/lib/standard/runners/help.rb +9 -5
- data/lib/standard/runners/lsp.rb +11 -0
- data/lib/standard/runners/rubocop.rb +14 -18
- data/lib/standard/runners/verbose_version.rb +14 -0
- data/lib/standard/version.rb +1 -1
- data/lib/standard.rb +6 -4
- data/standard.gemspec +22 -20
- metadata +72 -73
- data/.circleci/config.yml +0 -35
- data/lib/standard/cop/semantic_blocks.rb +0 -162
- data/lib/standard/detects_fixability.rb +0 -20
data/config/default.yml
ADDED
data/config/ruby-1.8.yml
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
inherit_from: ./ruby-1.9.yml
|
2
2
|
|
3
|
+
Style/HashSyntax:
|
4
|
+
EnforcedStyle: hash_rockets
|
5
|
+
|
3
6
|
Style/Lambda:
|
4
7
|
Enabled: false
|
5
8
|
|
6
|
-
Style/
|
7
|
-
|
9
|
+
Style/FileWrite:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Style/FileRead:
|
13
|
+
Enabled: false
|
8
14
|
|
15
|
+
Layout/DotPosition:
|
16
|
+
Enabled: false
|
data/config/ruby-1.9.yml
CHANGED
@@ -1,4 +1,14 @@
|
|
1
|
-
inherit_from: ./ruby-2.
|
1
|
+
inherit_from: ./ruby-2.0.yml
|
2
2
|
|
3
3
|
Style/Encoding:
|
4
4
|
Enabled: false
|
5
|
+
|
6
|
+
Style/HashConversion:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
# Percent delimiters are not supported until Ruby 2.0
|
10
|
+
Style/PercentLiteralDelimiters:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Style/FileNull:
|
14
|
+
Enabled: false
|
data/config/ruby-2.0.yml
ADDED
data/config/ruby-2.1.yml
ADDED
data/config/ruby-2.2.yml
CHANGED
@@ -1,8 +1,16 @@
|
|
1
|
-
inherit_from: ./
|
1
|
+
inherit_from: ./ruby-2.3.yml
|
2
2
|
|
3
3
|
AllCops:
|
4
|
-
TargetRubyVersion: 2.
|
4
|
+
TargetRubyVersion: 2.2
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
# The below cops are for features not available until Ruby 2.3 but,
|
7
|
+
# as of this writing, the cops don't correctly use the TargetRubyVersion.
|
8
|
+
|
9
|
+
Style/HashFetchChain:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Layout/HeredocIndentation:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Style/SafeNavigation:
|
16
|
+
Enabled: false
|
data/config/ruby-2.3.yml
ADDED
data/config/ruby-2.4.yml
ADDED
data/config/ruby-2.5.yml
ADDED
data/config/ruby-2.6.yml
ADDED
data/config/ruby-2.7.yml
ADDED
data/config/ruby-3.0.yml
ADDED
data/config/ruby-3.1.yml
ADDED
data/config/ruby-3.2.yml
ADDED
data/config/ruby-3.3.yml
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Standard Ruby's Architecture
|
2
|
+
|
3
|
+
Architecture is not a 4-letter word (but the silly abbreviation 'a10e' is!), so
|
4
|
+
as Standard's internal structure has introduced more moving parts, it's
|
5
|
+
important to plant a stake in the ground and explain where all the cops are
|
6
|
+
buried.
|
7
|
+
|
8
|
+
Starting with version 1.28.0, Standard Ruby introduced plugin support and
|
9
|
+
refactored how it loads its own rules from one large YAML file into several
|
10
|
+
plugins. As a result, what was a single `standard` gem is now spread across 3
|
11
|
+
gems.
|
12
|
+
|
13
|
+
Here's how it's all organized:
|
14
|
+
|
15
|
+
* [standard](https://github.com/standardrb/standard) - The main gem. The one
|
16
|
+
people install and think of. Because `standard` has a hard dependency on `rubocop`,
|
17
|
+
the base configuration of RuboCop's built-in rules is bundled into the gem, even
|
18
|
+
though it's now [defined as a plugin](lib/standard/base/plugin.rb)
|
19
|
+
* [standard-performance](https://github.com/standardrb/standard-performance) - A
|
20
|
+
plugin that depends on and configures
|
21
|
+
[rubocop-performance](https://github.com/rubocop/rubocop-performance)
|
22
|
+
* [standard-custom](https://github.com/standardrb/standard-custom) - A plugin
|
23
|
+
that implements and configures any custom rules that the Standard team writes
|
24
|
+
and maintains itself with the intention that they be part of the default
|
25
|
+
Standard Ruby experience (there's only one of these rules so far)
|
26
|
+
|
27
|
+
To glue these things together, yet another gem was created (gems are free,
|
28
|
+
right?) to define a very simple plugin API. That gem is called
|
29
|
+
[lint_roller](https://github.com/standardrb/lint_roller) and it can be used by
|
30
|
+
any gem that provides or consumes linting and formatting rules. Because Standard
|
31
|
+
Ruby is built on RuboCop's configuration and runner, RuboCop could adopt
|
32
|
+
`lint_roller` as its plugin system and plugins could support both `rubocop`
|
33
|
+
and `standard` out of the box.
|
data/docs/RELEASE.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# How to release Standard Ruby
|
2
|
+
|
3
|
+
Because this gem was generated with the [bundler `gem`
|
4
|
+
command](https://bundler.io/man/bundle-gem.1.html), [our Rakefile](/Rakefile)
|
5
|
+
loads `bundler/gem_tasks`, which provides a lot of the commands one needs
|
6
|
+
to manage a gem's release lifecycle:
|
7
|
+
|
8
|
+
```
|
9
|
+
$ rake -T
|
10
|
+
rake build # Build standard-x.x.x.gem into the pkg directory
|
11
|
+
rake clean # Remove any temporary products
|
12
|
+
rake clobber # Remove any generated files
|
13
|
+
rake install # Build and install standard-x.x.x.gem into system gems
|
14
|
+
rake install:local # Build and install standard-x.x.x.gem into system gems without network access
|
15
|
+
rake release[remote] # Create tag vx.x.x and build and push standard-0.5.2.gem to rubygems.org
|
16
|
+
```
|
17
|
+
|
18
|
+
Most of these commands are depended on (read: run by) `./bin/rake release`, which is
|
19
|
+
really the only one we'll need for releasing the gem to
|
20
|
+
[Rubygems.org](https://rubygems.org/gems/standard).
|
21
|
+
|
22
|
+
## Release steps
|
23
|
+
|
24
|
+
1. Make sure git is up to date and `./bin/rake` exits cleanly
|
25
|
+
1. If you upgraded a Rubocop dependency, be sure to lock it down in
|
26
|
+
`standard.gemspec`. To avoid being broken transitively, we stick to exact
|
27
|
+
release dependencies (e.g. "0.91.0" instead of "~> 0.91")
|
28
|
+
1. Update `CHANGELOG.md` as exhaustively as you are able and set the top header
|
29
|
+
to "Unreleased"
|
30
|
+
1. Bump the appropriate version segment in `lib/standard/version.rb` (basic
|
31
|
+
semantic versioning rules apply; if the release updates Rubocop, follow its
|
32
|
+
version bump at a minimum—if rubocop saw minor bump, we'll also bump the
|
33
|
+
minor version)
|
34
|
+
1. Run `bundle` so that Bundler writes this version to `Gemfile.lock`
|
35
|
+
1. Commit `lib/standard/version.rb`, `Gemfile.lock`, and `CHANGELOG.md` together
|
36
|
+
with the message equal to the new version (e.g. "0.42.1")
|
37
|
+
1. Finally, run `./bin/rake release`, which will hopefully succeed
|
38
|
+
1. Provide your multi-factor-auth token when prompted to finish publishing the
|
39
|
+
gem
|
40
|
+
1. [Tweet](https://twitter.com) about your awesome new release! (Shameless
|
41
|
+
self-promotion is the most important part of open source software)
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Ruby versions
|
2
|
+
|
3
|
+
## Handling new releases
|
4
|
+
|
5
|
+
When a new Ruby version comes out, you shouldn't have to make any immediate
|
6
|
+
changes to Standard Ruby. The default configuration is the `base.yml`
|
7
|
+
configuration and should continue to work correctly.
|
8
|
+
|
9
|
+
Often, Rubocop will add new rules to encourage usage of new language features in
|
10
|
+
new Ruby versions. When that happens:
|
11
|
+
|
12
|
+
1. Add the rule to the `base.yml` file and disable it.
|
13
|
+
1. Assess the new rule and see if it should be added to Standard Ruby. If not,
|
14
|
+
you're done. If so, enable it in `base.yml` and read on.
|
15
|
+
1. Add a new config file for the penultimate minor version of Ruby. For example,
|
16
|
+
if the new version is `3.1` then the new config file would be for `3.0`.
|
17
|
+
1. In the new config file, make sure it inherits from `base.yml` and disable the
|
18
|
+
new rule.
|
19
|
+
1. In what was previously the latest config file, make sure it inherits from
|
20
|
+
your new config file.
|
21
|
+
|
22
|
+
That should add new rules to Standard Ruby safely and gracefully.
|
23
|
+
|
24
|
+
## Maintenance and support
|
25
|
+
|
26
|
+
We will support the actively maintained ruby versions from the [ruby maintenance
|
27
|
+
policy](https://www.ruby-lang.org/en/downloads/branches/) along with the most
|
28
|
+
recently EOL version for an additional ~9 months, dropping support for EOL
|
29
|
+
versions around the time that a new supported ruby version is released and
|
30
|
+
added.
|
31
|
+
|
32
|
+
With the current ruby release cadence (new version near end of year, EOL drop
|
33
|
+
around April 1), this means we'll have a release of all the Standard gems around
|
34
|
+
the new year which adds support for the new ruby version and drops support for
|
35
|
+
what was an already-EOL but still-supported older ruby version.
|
36
|
+
|
37
|
+
## Coordination across gems
|
38
|
+
|
39
|
+
We will align versions/dependencies amongst the Standard gems:
|
40
|
+
|
41
|
+
- [standard-custom](https://github.com/standardrb/standard-custom)
|
42
|
+
- [standard-performance](https://github.com/standardrb/standard-performance)
|
43
|
+
- [standard-rails](https://github.com/standardrb/standard-rails)
|
44
|
+
- [standard-sorbet](https://github.com/standardrb/standard-sorbet)
|
45
|
+
- [standard](https://github.com/standardrb/standard)
|
46
|
+
|
47
|
+
This means keeping them consistent in regard to:
|
48
|
+
|
49
|
+
- The minimum required ruby version configured in their `gemspec`
|
50
|
+
- Using that version in their internal `.standard.yml` configurations
|
51
|
+
- Including the full range of supported rubies in their CI ruby matrix
|
data/docs/UPGRADING.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Upgrading Standard
|
2
|
+
|
3
|
+
Since standard now encompasses both a tool itself and a series of plug-ins it makes sense to first update the standard plug-ins and then the standard tool itself. Each plug-in is a configuration for its corresponding rubocop plug-in.
|
4
|
+
|
5
|
+
The official standard plug-ins that are included in standard are:
|
6
|
+
|
7
|
+
- **Standard Performance:** corresponding to rubocop-performance
|
8
|
+
- **Standard Custom:** for custom cops created for standard
|
9
|
+
|
10
|
+
## Updating Standard Plugins
|
11
|
+
|
12
|
+
1. Update Rubocop plugin in the gemspec file and gem file.
|
13
|
+
1. Keep standard in the gem file up-to-date. This will bring any testing utilities in standard into the plug-in repository.
|
14
|
+
1. Run `./bin/rake` to run the tests
|
15
|
+
1. Configure any cops that need to be configured so that the tests pass
|
16
|
+
1. Update the change log to the best of your ability and title it as unreleased
|
17
|
+
1. Make your commit for these updates and push to the main branch
|
18
|
+
1. Update the version in version.rb and update the version in the Changelog replacing the word “Unreleased”
|
19
|
+
1. Run bundle to write the new version number to the lock file
|
20
|
+
1. Run `./bin/rake release` to release the gem to RubyGems and create the version git tag. Push the tag to GitHub.
|
21
|
+
|
22
|
+
## Updating Standard
|
23
|
+
|
24
|
+
1. Update Rubocop as well as Standard Performance in the gemspec file and gem file.
|
25
|
+
1. Run `./bin/rake` to run the tests
|
26
|
+
1. Configure any cops that need to be configured so that the tests pass
|
27
|
+
1. Update the change log to the best of your ability and title it as unreleased
|
28
|
+
1. Make your commit for these updates and push to the main branch
|
29
|
+
1. Update the version in version.rb and update the version in the Changelog replacing the word “Unreleased”
|
30
|
+
1. Run bundle to write the new version number to the lock file
|
31
|
+
1. Run `./bin/rake` to release the gem to RubyGems and create the version git tag. Push the tag to GitHub.
|
@@ -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,44 @@
|
|
1
|
+
module RubyLsp
|
2
|
+
module Standard
|
3
|
+
class WrapsBuiltinLspStandardizer
|
4
|
+
include RubyLsp::Requests::Support::Formatter
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
init!
|
8
|
+
end
|
9
|
+
|
10
|
+
def init!
|
11
|
+
@standardizer = ::Standard::Lsp::Standardizer.new(
|
12
|
+
::Standard::BuildsConfig.new.call([])
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def run_formatting(uri, document)
|
17
|
+
@standardizer.format(uri_to_path(uri), document.source)
|
18
|
+
end
|
19
|
+
|
20
|
+
def run_diagnostic(uri, document)
|
21
|
+
@standardizer.offenses(uri_to_path(uri), document.source, document.encoding)
|
22
|
+
end
|
23
|
+
|
24
|
+
def run_range_formatting(_uri, _partial_source, _base_indentation)
|
25
|
+
# Not yet supported. Should return the formatted version of `partial_source` which is a partial selection of the
|
26
|
+
# entire document. For example, it should not try to add a frozen_string_literal magic comment and all style
|
27
|
+
# corrections should start from the `base_indentation`
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
# duplicated from: lib/standard/lsp/routes.rb
|
34
|
+
# modified to incorporate Ruby LSP's to_standardized_path method
|
35
|
+
def uri_to_path(uri)
|
36
|
+
if uri.respond_to?(:to_standardized_path) && !(standardized_path = uri.to_standardized_path).nil?
|
37
|
+
standardized_path
|
38
|
+
else
|
39
|
+
uri.to_s.sub(%r{^file://}, "")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Standard::Base
|
2
|
+
class Plugin < LintRoller::Plugin
|
3
|
+
def initialize(config)
|
4
|
+
@config = config
|
5
|
+
end
|
6
|
+
|
7
|
+
def about
|
8
|
+
LintRoller::About.new(
|
9
|
+
name: "standard-base",
|
10
|
+
version: VERSION,
|
11
|
+
homepage: "https://github.com/standardrb/standard",
|
12
|
+
description: "Configuration for RuboCop's built-in rules"
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
def supported?(context)
|
17
|
+
true
|
18
|
+
end
|
19
|
+
|
20
|
+
def rules(context)
|
21
|
+
LintRoller::Rules.new(
|
22
|
+
type: :path,
|
23
|
+
config_format: :rubocop,
|
24
|
+
value: determine_yaml_path(context.target_ruby_version)
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def determine_yaml_path(desired_version)
|
31
|
+
desired_version = Gem::Version.new(desired_version) unless desired_version.is_a?(Gem::Version)
|
32
|
+
default = "base.yml"
|
33
|
+
|
34
|
+
file_name = if !Gem::Version.correct?(desired_version)
|
35
|
+
default
|
36
|
+
elsif desired_version < Gem::Version.new("1.9")
|
37
|
+
"ruby-1.8.yml"
|
38
|
+
elsif desired_version < Gem::Version.new("2.0")
|
39
|
+
"ruby-1.9.yml"
|
40
|
+
elsif desired_version < Gem::Version.new("2.1")
|
41
|
+
"ruby-2.0.yml"
|
42
|
+
elsif desired_version < Gem::Version.new("2.2")
|
43
|
+
"ruby-2.1.yml"
|
44
|
+
elsif desired_version < Gem::Version.new("2.3")
|
45
|
+
"ruby-2.2.yml"
|
46
|
+
elsif desired_version < Gem::Version.new("2.4")
|
47
|
+
"ruby-2.3.yml"
|
48
|
+
elsif desired_version < Gem::Version.new("2.5")
|
49
|
+
"ruby-2.4.yml"
|
50
|
+
elsif desired_version < Gem::Version.new("2.6")
|
51
|
+
"ruby-2.5.yml"
|
52
|
+
elsif desired_version < Gem::Version.new("3.0")
|
53
|
+
"ruby-2.7.yml"
|
54
|
+
elsif desired_version < Gem::Version.new("3.1")
|
55
|
+
"ruby-3.0.yml"
|
56
|
+
elsif desired_version < Gem::Version.new("3.2")
|
57
|
+
"ruby-3.1.yml"
|
58
|
+
elsif desired_version < Gem::Version.new("3.3")
|
59
|
+
"ruby-3.2.yml"
|
60
|
+
elsif desired_version < Gem::Version.new("3.4")
|
61
|
+
"ruby-3.3.yml"
|
62
|
+
else
|
63
|
+
default
|
64
|
+
end
|
65
|
+
|
66
|
+
Pathname.new(__dir__).join("../../../config/#{file_name}")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -7,13 +7,23 @@ module Standard
|
|
7
7
|
|
8
8
|
class BuildsConfig
|
9
9
|
def initialize
|
10
|
+
@resolves_yaml_option = ResolvesYamlOption.new
|
10
11
|
@loads_yaml_config = LoadsYamlConfig.new
|
11
12
|
@merges_settings = MergesSettings.new
|
12
13
|
@creates_config_store = CreatesConfigStore.new
|
13
14
|
end
|
14
15
|
|
15
16
|
def call(argv, search_path = Dir.pwd)
|
16
|
-
|
17
|
+
standard_yaml_path = @resolves_yaml_option.call(argv, search_path, "--config", ".standard.yml")
|
18
|
+
|
19
|
+
# Don't load the existing todo file when generating a new todo file. Otherwise the
|
20
|
+
# new todo file won't have the ignore rules in the existing file.
|
21
|
+
todo_yaml_path = unless argv.include?("--generate-todo")
|
22
|
+
@resolves_yaml_option.call(argv, search_path, "--todo", ".standard_todo.yml")
|
23
|
+
end
|
24
|
+
|
25
|
+
standard_config = @loads_yaml_config.call(standard_yaml_path, todo_yaml_path)
|
26
|
+
|
17
27
|
settings = @merges_settings.call(argv, standard_config)
|
18
28
|
Config.new(
|
19
29
|
settings.runner,
|
data/lib/standard/cli.rb
CHANGED
@@ -3,9 +3,6 @@ require_relative "loads_runner"
|
|
3
3
|
|
4
4
|
module Standard
|
5
5
|
class Cli
|
6
|
-
SUCCESS_STATUS_CODE = 0
|
7
|
-
FAILURE_STATUS_CODE = 1
|
8
|
-
|
9
6
|
def initialize(argv)
|
10
7
|
@argv = argv
|
11
8
|
@builds_config = BuildsConfig.new
|
@@ -14,10 +11,7 @@ module Standard
|
|
14
11
|
|
15
12
|
def run
|
16
13
|
config = @builds_config.call(@argv)
|
17
|
-
|
18
|
-
success = @loads_runner.call(config.runner).call(config)
|
19
|
-
|
20
|
-
success ? SUCCESS_STATUS_CODE : FAILURE_STATUS_CODE
|
14
|
+
@loads_runner.call(config.runner).call(config).to_i
|
21
15
|
end
|
22
16
|
end
|
23
17
|
end
|
@@ -3,24 +3,8 @@ require "pathname"
|
|
3
3
|
class Standard::CreatesConfigStore
|
4
4
|
class AssignsRubocopYaml
|
5
5
|
def call(config_store, standard_config)
|
6
|
-
config_store.options_config =
|
7
|
-
config_store.instance_variable_get(
|
8
|
-
end
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
def rubocop_yaml_path(desired_version)
|
13
|
-
file_name = if desired_version < Gem::Version.new("1.9")
|
14
|
-
"ruby-1.8.yml"
|
15
|
-
elsif desired_version < Gem::Version.new("2.0")
|
16
|
-
"ruby-1.9.yml"
|
17
|
-
elsif desired_version < Gem::Version.new("2.3")
|
18
|
-
"ruby-2.2.yml"
|
19
|
-
else
|
20
|
-
"base.yml"
|
21
|
-
end
|
22
|
-
|
23
|
-
Pathname.new(__dir__).join("../../../config/#{file_name}")
|
6
|
+
config_store.options_config = Pathname.new(__dir__).join("../../../config/default.yml")
|
7
|
+
config_store.instance_variable_get(:@options_config)
|
24
8
|
end
|
25
9
|
end
|
26
10
|
end
|
@@ -8,7 +8,7 @@ class Standard::CreatesConfigStore
|
|
8
8
|
# Standard's own default ignores:
|
9
9
|
"bin/*",
|
10
10
|
"db/schema.rb",
|
11
|
-
"tmp/**/*"
|
11
|
+
"tmp/**/*"
|
12
12
|
].map { |path| [path, ["AllCops"]] }.freeze
|
13
13
|
|
14
14
|
def call(options_config, standard_config)
|
@@ -17,7 +17,7 @@ class Standard::CreatesConfigStore
|
|
17
17
|
options_config[cop] ||= {}
|
18
18
|
options_config[cop]["Exclude"] ||= []
|
19
19
|
options_config[cop]["Exclude"] |= [
|
20
|
-
absolutify(standard_config[:config_root], path)
|
20
|
+
absolutify(standard_config[:config_root], path)
|
21
21
|
]
|
22
22
|
end
|
23
23
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative "../file_finder"
|
2
|
+
require_relative "../plugin"
|
3
|
+
|
4
|
+
class Standard::CreatesConfigStore
|
5
|
+
class MergesUserConfigExtensions
|
6
|
+
class ExtendConfigPlugin < LintRoller::Plugin
|
7
|
+
def initialize(path)
|
8
|
+
@yaml_path = Standard::FileFinder.new.call(path, Dir.pwd)
|
9
|
+
end
|
10
|
+
|
11
|
+
def about
|
12
|
+
About.new("Pseudo-plugin wrapping the `extend_config' path: #{@yaml_path}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def rules(context)
|
16
|
+
LintRoller::Rules.new(
|
17
|
+
type: :path,
|
18
|
+
config_format: :rubocop,
|
19
|
+
value: @yaml_path
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize
|
25
|
+
@merges_plugins_into_rubocop_config = Standard::Plugin::MergesPluginsIntoRubocopConfig.new
|
26
|
+
end
|
27
|
+
|
28
|
+
def call(options_config, standard_config)
|
29
|
+
return unless standard_config[:extend_config]&.any?
|
30
|
+
|
31
|
+
plugins = standard_config[:extend_config].map { |path|
|
32
|
+
ExtendConfigPlugin.new(path)
|
33
|
+
}
|
34
|
+
@merges_plugins_into_rubocop_config.call(options_config, standard_config, plugins, permit_merging: false)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|