boxt_rubocop 0.0.47 → 1.0.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/README.md +23 -2
- data/Rakefile +23 -5
- data/VERSION +1 -1
- data/{default.yml → config/default.yml} +4 -3
- data/lib/boxt_rubocop.rb +6 -13
- data/lib/rubocop/boxt/inject.rb +20 -0
- data/lib/rubocop/boxt/version.rb +7 -0
- data/lib/rubocop/boxt.rb +14 -0
- data/lib/rubocop/cop/boxt/api_path_format.rb +1 -3
- data/lib/rubocop/cop/boxt_cops.rb +3 -0
- metadata +7 -4
- data/lib/boxt_rubocop/version.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1744a7d3b5eec56f26ffb86af39b0bf4ff4178a59f9480f4129fcbccbff30c0e
|
4
|
+
data.tar.gz: d0a3ab0c0b3946e9800c3b254c856a24d960e521f6f70e21296c57fd602855b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3790f37f11cb18067d2e9419ec525d35b04938f47422529fd6be992962cd90e5309d55ad727b8a9e364a95d26831ed797dd24f647e35bbc30eac61a478402433
|
7
|
+
data.tar.gz: 52c2d7a75751ea244e9f89687fbcc83a69e47171e8f922ce364d7b4059ed36fc4379d81f105efd400dc8611a68f00a42b38f54752eee11deb8bbf388f8f85bbf
|
data/README.md
CHANGED
@@ -28,16 +28,37 @@ bundle
|
|
28
28
|
|
29
29
|
## Usage
|
30
30
|
|
31
|
-
|
31
|
+
Put this into your .rubocop.yml.
|
32
|
+
|
33
|
+
```yml
|
34
|
+
require:
|
35
|
+
- boxt_rubocop
|
36
|
+
```
|
37
|
+
|
38
|
+
To enable additional configuration for `rubocop-rails` and `rubocop-rspec`, add the following to your .rubocop.yml:
|
32
39
|
|
33
40
|
```yml
|
34
41
|
inherit_gem:
|
35
42
|
boxt_rubocop:
|
36
|
-
- default.yml # use default cops
|
37
43
|
- rails.yml # use Rails cops - see Additional Extensions/Cops
|
38
44
|
- rspec.yml # use rspec cops - see Additional Extensions/Cops
|
39
45
|
```
|
40
46
|
|
47
|
+
## Creating new custom cops
|
48
|
+
|
49
|
+
Use the rake task new_cop to generate a cop template:
|
50
|
+
|
51
|
+
```sh
|
52
|
+
$ bundle exec rake 'new_cop[Boxt/Name]'
|
53
|
+
[create] lib/rubocop/cop/boxt/name.rb
|
54
|
+
[create] spec/rubocop/cop/boxt/name_spec.rb
|
55
|
+
[modify] lib/rubocop/cop/boxt_cops.rb - `require_relative 'boxt/name'` was injected.
|
56
|
+
[modify] A configuration for the cop is added into config/default.yml.
|
57
|
+
|
58
|
+
```
|
59
|
+
|
60
|
+
Documentation on creating a new cop can be found [here](https://docs.rubocop.org/rubocop/1.56/development.html#create-a-new-cop).
|
61
|
+
|
41
62
|
### NewCops
|
42
63
|
|
43
64
|
`NewCops` is enabled by default.
|
data/Rakefile
CHANGED
@@ -1,12 +1,30 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
|
-
require "rake/testtask"
|
5
4
|
require "rspec/core/rake_task"
|
6
5
|
|
7
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
8
|
-
t.pattern = Dir.glob("spec/**/*_spec.rb")
|
9
|
-
end
|
10
|
-
|
11
6
|
desc "Map rake test to rake spec"
|
12
7
|
task test: :spec
|
8
|
+
|
9
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
10
|
+
spec.pattern = FileList["spec/**/*_spec.rb"]
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Generate a new cop with a template"
|
14
|
+
task :new_cop, [:cop] => :environment do |_task, args|
|
15
|
+
require "rubocop"
|
16
|
+
|
17
|
+
cop_name = args.fetch(:cop) do
|
18
|
+
warn "usage: bundle exec rake 'new_cop[Boxt/Name]'"
|
19
|
+
exit!
|
20
|
+
end
|
21
|
+
|
22
|
+
generator = RuboCop::Cop::Generator.new(cop_name)
|
23
|
+
|
24
|
+
generator.write_source
|
25
|
+
generator.write_spec
|
26
|
+
generator.inject_require(root_file_path: "lib/rubocop/cop/boxt_cops.rb")
|
27
|
+
generator.inject_config(config_file_path: "config/default.yml")
|
28
|
+
|
29
|
+
puts generator.todo
|
30
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
1.0.1
|
@@ -1,6 +1,3 @@
|
|
1
|
-
require:
|
2
|
-
- ./lib/rubocop/cop/boxt/api_path_format.rb
|
3
|
-
|
4
1
|
AllCops:
|
5
2
|
Exclude:
|
6
3
|
- "**/*/schema.rb"
|
@@ -10,6 +7,10 @@ AllCops:
|
|
10
7
|
- vendor/**/*
|
11
8
|
NewCops: enable
|
12
9
|
|
10
|
+
Boxt/ApiPathFormat:
|
11
|
+
Description: 'Ensure that the API path uses kebab case'
|
12
|
+
Enabled: false
|
13
|
+
|
13
14
|
Layout/ClassStructure:
|
14
15
|
Enabled: true
|
15
16
|
|
data/lib/boxt_rubocop.rb
CHANGED
@@ -1,18 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "rubocop"
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
require_relative "rubocop/boxt"
|
6
|
+
require_relative "rubocop/boxt/version"
|
7
|
+
require_relative "rubocop/boxt/inject"
|
7
8
|
|
8
|
-
|
9
|
-
module_function
|
9
|
+
RuboCop::Boxt::Inject.defaults!
|
10
10
|
|
11
|
-
|
12
|
-
# Provide a root path helper for the gem root dir
|
13
|
-
#
|
14
|
-
# Returns Pathname
|
15
|
-
def root
|
16
|
-
Pathname.new(File.dirname(__dir__))
|
17
|
-
end
|
18
|
-
end
|
11
|
+
require_relative "rubocop/cop/boxt_cops"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The original code is from https://github.com/rubocop/rubocop-rspec/blob/master/lib/rubocop/rspec/inject.rb
|
4
|
+
# See https://github.com/rubocop/rubocop-rspec/blob/master/MIT-LICENSE.md
|
5
|
+
module RuboCop
|
6
|
+
module Boxt
|
7
|
+
# Because RuboCop doesn't yet support plugins, we have to monkey patch in a
|
8
|
+
# bit of our configuration.
|
9
|
+
module Inject
|
10
|
+
def self.defaults!
|
11
|
+
path = CONFIG_DEFAULT.to_s
|
12
|
+
hash = ConfigLoader.send(:load_yaml_configuration, path)
|
13
|
+
config = Config.new(hash, path).tap(&:make_excludes_absolute)
|
14
|
+
Rails.logger.debug { "configuration from #{path}" } if ConfigLoader.debug?
|
15
|
+
config = ConfigLoader.merge_with_default(config, path)
|
16
|
+
ConfigLoader.instance_variable_set(:@default_configuration, config)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/rubocop/boxt.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "boxt/version"
|
4
|
+
|
5
|
+
module RuboCop
|
6
|
+
module Boxt
|
7
|
+
class Error < StandardError; end
|
8
|
+
PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
|
9
|
+
CONFIG_DEFAULT = PROJECT_ROOT.join("config", "default.yml").freeze
|
10
|
+
CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze
|
11
|
+
|
12
|
+
private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
|
13
|
+
end
|
14
|
+
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "rubocop"
|
4
|
-
|
5
3
|
module RuboCop
|
6
4
|
module Cop
|
7
5
|
module Boxt
|
@@ -25,7 +23,7 @@ module RuboCop
|
|
25
23
|
# get "/installation-days"
|
26
24
|
# namespace "password-resets"
|
27
25
|
#
|
28
|
-
class ApiPathFormat <
|
26
|
+
class ApiPathFormat < Base
|
29
27
|
def_node_matcher :path_defining_method_with_string_path, <<~PATTERN
|
30
28
|
(send nil? {:post | :get | :namespace} (:str $_))
|
31
29
|
PATTERN
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boxt_rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boxt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -105,10 +105,13 @@ files:
|
|
105
105
|
- README.md
|
106
106
|
- Rakefile
|
107
107
|
- VERSION
|
108
|
-
- default.yml
|
108
|
+
- config/default.yml
|
109
109
|
- lib/boxt_rubocop.rb
|
110
|
-
- lib/
|
110
|
+
- lib/rubocop/boxt.rb
|
111
|
+
- lib/rubocop/boxt/inject.rb
|
112
|
+
- lib/rubocop/boxt/version.rb
|
111
113
|
- lib/rubocop/cop/boxt/api_path_format.rb
|
114
|
+
- lib/rubocop/cop/boxt_cops.rb
|
112
115
|
- rails.yml
|
113
116
|
- rspec.yml
|
114
117
|
homepage: https://github.com/boxt/boxt_rubocop
|