standard-rails 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,46 @@
1
+ # GENERATED FILE - DO NOT EDIT
2
+ #
3
+ # This file should look just like: https://github.com/rubocop/rubocop-rails/blob/master/lib/rubocop-rails.rb
4
+ # Except without the `Inject.defaults!` monkey patching.
5
+ #
6
+ # Because there are both necessary require statements and additional patching
7
+ # of RuboCop built-in cops in this file, we need to monitor it for changes
8
+ # in rubocop-rails and keep it up to date.
9
+ #
10
+ # Last updated from rubocop-rails v2.19.1
11
+
12
+ # frozen_string_literal: true
13
+
14
+ require "rubocop"
15
+ require "rack/utils"
16
+ require "active_support/inflector"
17
+ require "active_support/core_ext/object/blank"
18
+
19
+ require_path = Pathname.new(Gem.loaded_specs["rubocop-rails"].full_require_paths.first)
20
+ require require_path.join("rubocop/rails")
21
+ require require_path.join("rubocop/rails/version")
22
+ # require_relative 'rubocop/rails/inject'
23
+ require require_path.join("rubocop/rails/schema_loader")
24
+ require require_path.join("rubocop/rails/schema_loader/schema")
25
+
26
+ # RuboCop::Rails::Inject.defaults!
27
+
28
+ require require_path.join("rubocop/cop/rails_cops")
29
+
30
+ RuboCop::Cop::Style::HashExcept.minimum_target_ruby_version(2.0)
31
+
32
+ RuboCop::Cop::Style::MethodCallWithArgsParentheses.singleton_class.prepend(
33
+ Module.new do
34
+ def autocorrect_incompatible_with
35
+ super.push(RuboCop::Cop::Rails::EagerEvaluationLogMessage)
36
+ end
37
+ end
38
+ )
39
+
40
+ RuboCop::Cop::Style::RedundantSelf.singleton_class.prepend(
41
+ Module.new do
42
+ def autocorrect_incompatible_with
43
+ super.push(RuboCop::Cop::Rails::SafeNavigation)
44
+ end
45
+ end
46
+ )
@@ -0,0 +1,76 @@
1
+ require "yaml"
2
+
3
+ module Standard
4
+ module Rails
5
+ class Plugin < LintRoller::Plugin
6
+ def initialize(config)
7
+ @config = config
8
+ end
9
+
10
+ def about
11
+ LintRoller::About.new(
12
+ name: "standard-rails",
13
+ version: VERSION,
14
+ homepage: "https://github.com/testdouble/standard-rails",
15
+ description: "Configuration for rubocop-rails rules"
16
+ )
17
+ end
18
+
19
+ def supported?(context)
20
+ true
21
+ end
22
+
23
+ def rules(context)
24
+ trick_rubocop_into_thinking_we_required_rubocop_rails!
25
+
26
+ LintRoller::Rules.new(
27
+ type: :object,
28
+ config_format: :rubocop,
29
+ value: rules_with_config_applied
30
+ )
31
+ end
32
+
33
+ private
34
+
35
+ def rules_with_config_applied
36
+ YAML.load_file(Pathname.new(__dir__).join("../../../config/base.yml")).tap do |rules|
37
+ if @config.key?("target_rails_version")
38
+ rules["AllCops"]["TargetRailsVersion"] = @config["target_rails_version"]
39
+ end
40
+ end
41
+ end
42
+
43
+ # This is not fantastic.
44
+ #
45
+ # When you `require "rubocop-rails"`, it will not only load the cops,
46
+ # but it will also monkey-patch RuboCop's default_configuration, which is
47
+ # something that can't be undone for the lifetime of the process.
48
+ #
49
+ # See: https://github.com/rubocop/rubocop-rails/blob/master/lib/rubocop-rails.rb#L14
50
+ #
51
+ # As an alternative, standard-rails loads the cops directly, and then
52
+ # simply tells the RuboCop config loader that it's been loaded. This is
53
+ # taking advantage of a private API of an `attr_reader` that probably wasn't
54
+ # meant to be mutated externally, but it's better than the `Inject` monkey
55
+ # patching that rubocop-rails does (and many other RuboCop plugins do)
56
+ def trick_rubocop_into_thinking_we_required_rubocop_rails!
57
+ without_warnings do
58
+ require_relative "load_rubocop_rails_without_the_monkey_patch"
59
+ end
60
+ RuboCop::ConfigLoader.default_configuration.loaded_features.add("rubocop-rails")
61
+ end
62
+
63
+ # This is also not fantastic, but because loading RuboCop before loading
64
+ # ActiveSupport will result in RuboCop redefining a number of ActiveSupport
65
+ # methods like String#blank?, we need to suppress the warnings that are
66
+ # emitted when we load the cops.
67
+ def without_warnings(&blk)
68
+ original_verbose = $VERBOSE
69
+ $VERBOSE = nil
70
+ yield
71
+ ensure
72
+ $VERBOSE = original_verbose
73
+ end
74
+ end
75
+ end
76
+ end
@@ -1,5 +1,5 @@
1
1
  module Standard
2
2
  module Rails
3
- VERSION = "0.0.1"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -1,8 +1,4 @@
1
- require_relative "rails/version"
1
+ require "lint_roller"
2
2
 
3
- module Standard
4
- module Rails
5
- class Error < StandardError; end
6
- # Your code goes here...
7
- end
8
- end
3
+ require_relative "rails/version"
4
+ require_relative "rails/plugin"
@@ -0,0 +1 @@
1
+ require_relative "standard/rails"
metadata CHANGED
@@ -1,29 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standard-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.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: 2023-03-26 00:00:00.000000000 Z
11
+ date: 2023-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lint_roller
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rubocop-rails
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
31
  - - "~>"
18
32
  - !ruby/object:Gem::Version
19
- version: 2.18.0
33
+ version: 2.19.0
20
34
  type: :runtime
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
- version: 2.18.0
40
+ version: 2.19.0
27
41
  description:
28
42
  email:
29
43
  - searls@gmail.com
@@ -39,7 +53,10 @@ files:
39
53
  - README.md
40
54
  - Rakefile
41
55
  - config/base.yml
56
+ - lib/standard-rails.rb
42
57
  - lib/standard/rails.rb
58
+ - lib/standard/rails/load_rubocop_rails_without_the_monkey_patch.rb
59
+ - lib/standard/rails/plugin.rb
43
60
  - lib/standard/rails/version.rb
44
61
  homepage: https://github.com/testdouble/standard-rails
45
62
  licenses:
@@ -49,6 +66,7 @@ metadata:
49
66
  source_code_uri: https://github.com/testdouble/standard-rails
50
67
  changelog_uri: https://github.com/testdouble/standard-rails/blob/main/CHANGELOG.md
51
68
  rubygems_mfa_required: 'true'
69
+ default_lint_roller_plugin: Standard::Rails::Plugin
52
70
  post_install_message:
53
71
  rdoc_options: []
54
72
  require_paths:
@@ -57,14 +75,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
57
75
  requirements:
58
76
  - - ">="
59
77
  - !ruby/object:Gem::Version
60
- version: 2.6.0
78
+ version: 2.7.0
61
79
  required_rubygems_version: !ruby/object:Gem::Requirement
62
80
  requirements:
63
81
  - - ">="
64
82
  - !ruby/object:Gem::Version
65
83
  version: '0'
66
84
  requirements: []
67
- rubygems_version: 3.4.8
85
+ rubygems_version: 3.4.10
68
86
  signing_key:
69
87
  specification_version: 4
70
88
  summary: A Standard plugin that adds Rails-specific rules to Standard