ezcater_rubocop 0.50.2.rc0 → 0.50.2.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/README.md +12 -0
- data/conf/rubocop.yml +3 -0
- data/config/default.yml +4 -0
- data/ezcater_rubocop.gemspec +12 -1
- data/lib/ezcater_rubocop.rb +1 -0
- data/lib/ezcater_rubocop/version.rb +1 -1
- data/lib/rubocop/cop/ezcater/private_attr.rb +91 -0
- metadata +3 -12
- data/.circleci/config.yml +0 -46
- data/.gitignore +0 -12
- data/.rspec +0 -3
- data/.rubocop.yml +0 -6
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.travis.yml +0 -8
- data/Rakefile +0 -6
- data/bin/console +0 -14
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d12c8292918b188ea1df51f50a4b2aaeba09808
|
4
|
+
data.tar.gz: '0219fcf647fe0325ac794de1498e822db2b429d9'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b56adca97c94e2e92a1f9746ead3e0dab36b36f97f09dea46d5dd2f7c7ef0080391ae85814601ff0ebca93a7c4565306419267d8a7e8f6388caf7ea0ed14afbb
|
7
|
+
data.tar.gz: 7c2c268cf647c3dc634e17bb2d961663a1eaf00c0c284767240d0b427d4df2642d2465104fe79f97ea08137d229a197a3f585db3b9f06fc0d3623a80033ddb59
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -56,6 +56,17 @@ Run `rubocop` for an entire project:
|
|
56
56
|
See the `rubocop` command-line for additional options including auto-generating
|
57
57
|
configuration for existing offenses and auto-correction.
|
58
58
|
|
59
|
+
### Circle Script
|
60
|
+
|
61
|
+
This gem contains a script, `circle_rubocop.rb`, that can be used to run RuboCop in CI.
|
62
|
+
|
63
|
+
The behavior of the script is that all files are checked on master or if the rubocop
|
64
|
+
configuration has changed. On non-master branches, only the files added or changed on
|
65
|
+
the branch are checked.
|
66
|
+
|
67
|
+
For non-master branches, `[rubocop skip]` can be included in the commit message to skip
|
68
|
+
running rubocop.
|
69
|
+
|
59
70
|
## Versioning
|
60
71
|
|
61
72
|
This gem is versioned based on the MAJOR.MINOR version of `rubocop`. The first
|
@@ -71,6 +82,7 @@ the latest compatible version each time that the MAJOR.MINOR version of `rubocop
|
|
71
82
|
is updated.
|
72
83
|
|
73
84
|
## Custom Cops
|
85
|
+
1. [PrivateAttr](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/private_attr.rb) - Require methods from the `private_attr` gem.
|
74
86
|
1. [RspecDotNotSelfDot](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/rspec_dot_not_self_dot.rb) - Enforce ".<class method>" instead of "self.<class method>" for example group description.
|
75
87
|
1. [RspecRequireBrowserMock](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/rspec_require_browser_mock.rb) - Enforce use of `mock_ezcater_app`, `mock_chrome_browser` & `mock_custom_browser` helpers instead of mocking `Browser` or `EzBrowser` directly.
|
76
88
|
1. [RspecRequireFeatureFlagMock](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/rspec_require_feature_flag_mock.rb) - Enforce use of `mock_feature_flag` helper instead of mocking `FeatureFlag.is_active?` directly.
|
data/conf/rubocop.yml
CHANGED
data/config/default.yml
CHANGED
data/ezcater_rubocop.gemspec
CHANGED
@@ -22,9 +22,20 @@ Gem::Specification.new do |spec|
|
|
22
22
|
"public gem pushes."
|
23
23
|
end
|
24
24
|
|
25
|
+
excluded_files = %w[.circleci/config.yml
|
26
|
+
.gitignore
|
27
|
+
.rspec
|
28
|
+
.rubocop.yml
|
29
|
+
.ruby-gemset
|
30
|
+
.ruby-version
|
31
|
+
.travis.yml
|
32
|
+
bin/console
|
33
|
+
bin/setup
|
34
|
+
Rakefile]
|
35
|
+
|
25
36
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
37
|
f.match(%r{^(test|spec|features)/})
|
27
|
-
end
|
38
|
+
end - excluded_files
|
28
39
|
spec.bindir = "bin"
|
29
40
|
spec.executables << "circle_rubocop.rb"
|
30
41
|
spec.require_paths = ["lib"]
|
data/lib/ezcater_rubocop.rb
CHANGED
@@ -12,6 +12,7 @@ puts "configuration from #{DEFAULT_FILES}" if RuboCop::ConfigLoader.debug?
|
|
12
12
|
config = RuboCop::ConfigLoader.merge_with_default(config, path)
|
13
13
|
RuboCop::ConfigLoader.instance_variable_set(:@default_configuration, config)
|
14
14
|
|
15
|
+
require "rubocop/cop/ezcater/private_attr"
|
15
16
|
require "rubocop/cop/ezcater/rspec_require_browser_mock"
|
16
17
|
require "rubocop/cop/ezcater/rspec_require_feature_flag_mock"
|
17
18
|
require "rubocop/cop/ezcater/rspec_dot_not_self_dot"
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module RuboCop
|
2
|
+
module Cop
|
3
|
+
module Ezcater
|
4
|
+
# This cop checks for the use of `attr_accessor`, `attr_reader`, `attr_writer`
|
5
|
+
# and `alias_method` after the access modifiers `private` and `protected`
|
6
|
+
# and requires the use of methods from the private_attr gem instead.
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
#
|
10
|
+
# # bad
|
11
|
+
#
|
12
|
+
# class C
|
13
|
+
# private
|
14
|
+
#
|
15
|
+
# attr_accessor :foo
|
16
|
+
# attr_reader :bar
|
17
|
+
# attr_writer :baz
|
18
|
+
# alias_method :foobar, foo
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
#
|
22
|
+
# @example
|
23
|
+
#
|
24
|
+
# # good
|
25
|
+
#
|
26
|
+
# class C
|
27
|
+
# private_attr_accessor :foo
|
28
|
+
# private_attr_reader :bar
|
29
|
+
# private_attr_writer :baz
|
30
|
+
# private_alias_method :foobar, :foo
|
31
|
+
#
|
32
|
+
# private
|
33
|
+
#
|
34
|
+
# def shy
|
35
|
+
# puts "hi"
|
36
|
+
# end
|
37
|
+
# end
|
38
|
+
class PrivateAttr < Cop
|
39
|
+
ATTR_METHODS = %i[attr_accessor
|
40
|
+
attr_reader
|
41
|
+
attr_writer].freeze
|
42
|
+
|
43
|
+
ACCESS_AFFECTED_METHODS = (ATTR_METHODS + %i[alias_method]).to_set.freeze
|
44
|
+
|
45
|
+
MSG = "Use `%s_%s` instead".freeze
|
46
|
+
|
47
|
+
def on_class(node)
|
48
|
+
check_node(node.children[2]) # class body
|
49
|
+
end
|
50
|
+
|
51
|
+
def on_module(node)
|
52
|
+
check_node(node.children[1]) # module body
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def check_node(node)
|
58
|
+
return unless node&.begin_type?
|
59
|
+
|
60
|
+
check_scope(node)
|
61
|
+
end
|
62
|
+
|
63
|
+
def format_message(visibility, method_name)
|
64
|
+
format(MSG, visibility, method_name)
|
65
|
+
end
|
66
|
+
|
67
|
+
def check_scope(node, current_visibility = :public)
|
68
|
+
node.children.reduce(current_visibility) do |visibility, child|
|
69
|
+
check_child_scope(child, visibility)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def check_child_scope(node, current_visibility)
|
74
|
+
if node.send_type?
|
75
|
+
if node.access_modifier? && !node.method?(:module_function)
|
76
|
+
current_visibility = node.method_name
|
77
|
+
elsif ACCESS_AFFECTED_METHODS.include?(node.method_name) && current_visibility != :public
|
78
|
+
add_offense(node,
|
79
|
+
:expression,
|
80
|
+
format_message(current_visibility, node.method_name))
|
81
|
+
end
|
82
|
+
elsif node.kwbegin_type?
|
83
|
+
check_scope(node, current_visibility)
|
84
|
+
end
|
85
|
+
|
86
|
+
current_visibility
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ezcater_rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.50.2.
|
4
|
+
version: 0.50.2.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ezCater, Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -116,27 +116,18 @@ executables:
|
|
116
116
|
extensions: []
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
|
-
- ".circleci/config.yml"
|
120
|
-
- ".gitignore"
|
121
|
-
- ".rspec"
|
122
|
-
- ".rubocop.yml"
|
123
|
-
- ".ruby-gemset"
|
124
|
-
- ".ruby-version"
|
125
|
-
- ".travis.yml"
|
126
119
|
- CHANGELOG.md
|
127
120
|
- Gemfile
|
128
121
|
- LICENSE.txt
|
129
122
|
- README.md
|
130
|
-
- Rakefile
|
131
123
|
- bin/circle_rubocop.rb
|
132
|
-
- bin/console
|
133
|
-
- bin/setup
|
134
124
|
- conf/rubocop.yml
|
135
125
|
- conf/rubocop_rails.yml
|
136
126
|
- config/default.yml
|
137
127
|
- ezcater_rubocop.gemspec
|
138
128
|
- lib/ezcater_rubocop.rb
|
139
129
|
- lib/ezcater_rubocop/version.rb
|
130
|
+
- lib/rubocop/cop/ezcater/private_attr.rb
|
140
131
|
- lib/rubocop/cop/ezcater/rspec_dot_not_self_dot.rb
|
141
132
|
- lib/rubocop/cop/ezcater/rspec_require_browser_mock.rb
|
142
133
|
- lib/rubocop/cop/ezcater/rspec_require_feature_flag_mock.rb
|
data/.circleci/config.yml
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
version: 2
|
2
|
-
jobs:
|
3
|
-
build:
|
4
|
-
parallelism: 1
|
5
|
-
working_directory: ~/ezcater
|
6
|
-
docker:
|
7
|
-
- image: circleci/ruby:2.4.1
|
8
|
-
steps:
|
9
|
-
- checkout
|
10
|
-
|
11
|
-
# Restore bundle cache
|
12
|
-
- restore_cache:
|
13
|
-
keys:
|
14
|
-
- ruby-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile" }}-{{ checksum "ezcater_rubocop.gemspec" }}
|
15
|
-
- ruby-cache-{{ arch }}-{{ .Branch }}-
|
16
|
-
- ruby-cache-
|
17
|
-
|
18
|
-
# Bundle install dependencies
|
19
|
-
- run: gem install bundler --no-document
|
20
|
-
- run: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
|
21
|
-
- run: bundle clean --force
|
22
|
-
|
23
|
-
# Store bundle cache
|
24
|
-
- save_cache:
|
25
|
-
key: ruby-cache-{{ .Branch }}-{{ checksum "Gemfile" }}-{{ checksum "ezcater_rubocop.gemspec" }}
|
26
|
-
paths:
|
27
|
-
- vendor/bundle
|
28
|
-
|
29
|
-
# Run Rubocop
|
30
|
-
- run:
|
31
|
-
name: RuboCop
|
32
|
-
command: bundle exec rubocop
|
33
|
-
|
34
|
-
# Run rspec in parallel
|
35
|
-
- type: shell
|
36
|
-
command: |
|
37
|
-
bundle exec rspec --profile 10 \
|
38
|
-
--format RspecJunitFormatter \
|
39
|
-
--out test_results/rspec.xml \
|
40
|
-
--format progress
|
41
|
-
|
42
|
-
# Save test results for timing analysis
|
43
|
-
- store_test_results:
|
44
|
-
path: test_results
|
45
|
-
- store_test_results:
|
46
|
-
path: tmp/capybara
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
data/.ruby-gemset
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
ezcater_rubocop
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.4.1
|
data/.travis.yml
DELETED
data/Rakefile
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "ezcater_rubocop"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|