boxt_rubocop 0.0.47 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -2
- data/Rakefile +23 -5
- data/VERSION +1 -1
- 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 +6 -4
- data/default.yml +0 -63
- 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: 341e8b143a6ca39495d4ecb8f4ac3b4abb9e2035407202d8692fafd01ea32f2b
|
4
|
+
data.tar.gz: 41f53ec76d4e3f54adde9d56aaf4b04bc07c67cf35a0174f01479bbaa2473094
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5b071c38cc59d28d142aef6b24869a1d1e3a2dfbb02d1ab65faa3a7ad6eeed31b7bea037f600cdd3a6a7dc89b91f5816cd1abd9548920b94e3c13a7773a0aeb
|
7
|
+
data.tar.gz: 433ef4aced8b97690fb92a2a2346d40c944ad56caaf8304f547d40900f731ba8edb625055bc2e0d49e8ae96af73354e1604a063c2b390c3f4b778cd67e131bf7
|
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
|
-
0.0
|
1
|
+
1.0.0
|
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: 0.0
|
4
|
+
version: 1.0.0
|
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,12 @@ files:
|
|
105
105
|
- README.md
|
106
106
|
- Rakefile
|
107
107
|
- VERSION
|
108
|
-
- default.yml
|
109
108
|
- lib/boxt_rubocop.rb
|
110
|
-
- lib/
|
109
|
+
- lib/rubocop/boxt.rb
|
110
|
+
- lib/rubocop/boxt/inject.rb
|
111
|
+
- lib/rubocop/boxt/version.rb
|
111
112
|
- lib/rubocop/cop/boxt/api_path_format.rb
|
113
|
+
- lib/rubocop/cop/boxt_cops.rb
|
112
114
|
- rails.yml
|
113
115
|
- rspec.yml
|
114
116
|
homepage: https://github.com/boxt/boxt_rubocop
|
data/default.yml
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
require:
|
2
|
-
- ./lib/rubocop/cop/boxt/api_path_format.rb
|
3
|
-
|
4
|
-
AllCops:
|
5
|
-
Exclude:
|
6
|
-
- "**/*/schema.rb"
|
7
|
-
- Gemfile.lock
|
8
|
-
- node_modules/**/*
|
9
|
-
- tmp/**/*
|
10
|
-
- vendor/**/*
|
11
|
-
NewCops: enable
|
12
|
-
|
13
|
-
Layout/ClassStructure:
|
14
|
-
Enabled: true
|
15
|
-
|
16
|
-
Layout/LineLength:
|
17
|
-
Exclude:
|
18
|
-
- config/routes.rb
|
19
|
-
- config/routes/*
|
20
|
-
Max: 120
|
21
|
-
|
22
|
-
Metrics/AbcSize:
|
23
|
-
Exclude:
|
24
|
-
- db/migrate/**/*
|
25
|
-
|
26
|
-
Metrics/BlockLength:
|
27
|
-
CountAsOne: ["array", "hash"]
|
28
|
-
Exclude:
|
29
|
-
- "*.gemspec"
|
30
|
-
- Gemfile
|
31
|
-
- config/environments/*
|
32
|
-
- config/routes.rb
|
33
|
-
- config/routes/*
|
34
|
-
- db/migrate/**/*
|
35
|
-
- lib/tasks/**/*
|
36
|
-
- spec/**/*
|
37
|
-
- test/**/*
|
38
|
-
|
39
|
-
Metrics/ClassLength:
|
40
|
-
CountAsOne: ["array", "hash"]
|
41
|
-
Exclude:
|
42
|
-
- db/migrate/**/*
|
43
|
-
- spec/**/*
|
44
|
-
- test/**/*
|
45
|
-
|
46
|
-
Metrics/MethodLength:
|
47
|
-
CountAsOne: ["array", "heredoc", "hash"]
|
48
|
-
Exclude:
|
49
|
-
- db/migrate/**/*
|
50
|
-
- spec/**/*
|
51
|
-
- test/**/*
|
52
|
-
|
53
|
-
Metrics/ModuleLength:
|
54
|
-
CountAsOne: ["array", "hash"]
|
55
|
-
|
56
|
-
Style/Documentation:
|
57
|
-
Enabled: false
|
58
|
-
|
59
|
-
Style/DoubleNegation:
|
60
|
-
Enabled: false
|
61
|
-
|
62
|
-
Style/StringLiterals:
|
63
|
-
EnforcedStyle: double_quotes
|