barcoop 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +2 -0
- data/Gemfile +3 -0
- data/README.md +35 -0
- data/Rakefile +3 -0
- data/barcoop.gemspec +28 -0
- data/conf/rubocop.yml +105 -0
- data/lib/barcoop/cops/avoid_fixtures.rb +15 -0
- data/lib/barcoop/cops/avoid_rails_env.rb +28 -0
- data/lib/barcoop/cops/avoid_timeout.rb +27 -0
- data/lib/barcoop/version.rb +5 -0
- data/lib/barcoop.rb +3 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d8ce64d411c35913faa32cf6523d4b76b41c9c66
|
4
|
+
data.tar.gz: c6def3f016fa0a2160b4e52e80e886a1f2617547
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3692b7c5a638a9df174e9ec3f2a71365980c8d73132b95eb4a5d547631d97ff09a252de00eee0e72ff74ae3b9153a64b420cde078c83d72b6008899c8e597b87
|
7
|
+
data.tar.gz: 5d965481afdfe7491680bf161126535158f76057747322df4a7a1114ab30bdd1085e00f80b606cc64efa221d048adfe26d08c39a583c0b15519e12f97a68df8d
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Gemfile.lock
|
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Barcoop
|
2
|
+
|
3
|
+
Barcoo's shared RuboCop configuration and cops.
|
4
|
+
|
5
|
+
### Installation
|
6
|
+
|
7
|
+
Add this line to your application's `Gemfile`:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
group :development, :test do
|
11
|
+
gem 'barcoop', require: false
|
12
|
+
end
|
13
|
+
```
|
14
|
+
|
15
|
+
Or to your gem's `gemspec` file:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
spec.add_development_dependency 'barcoop'
|
19
|
+
```
|
20
|
+
|
21
|
+
To use it just add the following line to your `.rubocop.yml` file:
|
22
|
+
```yaml
|
23
|
+
inherit_gem:
|
24
|
+
barcoop: conf/rubocop.yml
|
25
|
+
```
|
26
|
+
|
27
|
+
### Cops
|
28
|
+
|
29
|
+
This gems provides the following cops:
|
30
|
+
|
31
|
+
[AvoidFixtures](lib/barcoop/cops/avoid_fixtures.rb): Avoid using fixtures, use `FactoryGirl` instead
|
32
|
+
|
33
|
+
[AvoidRailsEnv](lib/barcoop/cops/avoid_rails_env.rb): Avoid using `Rails.env.environment?` and prefer adding a feature flag in a configuration file.
|
34
|
+
|
35
|
+
[AvoidTimeout](lib/barcoop/cops/avoid_timeout.rb): `Timeout.timeout` is not thread safe, see http://www.mikeperham.com/2015/05/08/timeout-rubys-most-dangerous-api/
|
data/Rakefile
ADDED
data/barcoop.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
lib = File.expand_path('../lib', __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
require 'barcoop/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = 'barcoop'
|
10
|
+
spec.version = Barcoop::VERSION
|
11
|
+
spec.authors = ['Sergio Medina']
|
12
|
+
spec.email = ['sergio.medina@offerista.com']
|
13
|
+
|
14
|
+
spec.summary = "barcoo's rubocop config and cops"
|
15
|
+
spec.description = "barcoo's rubocop config and cops"
|
16
|
+
spec.homepage = 'https://github.com/barcoo/barcoop'
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
20
|
+
end
|
21
|
+
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_runtime_dependency 'rubocop'
|
25
|
+
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.14'
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
+
end
|
data/conf/rubocop.yml
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
# see https://github.com/bbatsov/rubocop#configuration
|
2
|
+
# for info on how to configure rubocop
|
3
|
+
# see https://github.com/bbatsov/rubocop/blob/master/config/default.yml
|
4
|
+
# for default configuration
|
5
|
+
|
6
|
+
require:
|
7
|
+
- barcoop/cops/avoid_rails_env.rb
|
8
|
+
- barcoop/cops/avoid_fixtures.rb
|
9
|
+
- barcoop/cops/avoid_timeout.rb
|
10
|
+
|
11
|
+
AllCops:
|
12
|
+
TargetRubyVersion: 2.3
|
13
|
+
Include:
|
14
|
+
- '**/Rakefile'
|
15
|
+
- '**/config.ru'
|
16
|
+
- '**/Gemfile'
|
17
|
+
Exclude:
|
18
|
+
- 'db/**/*'
|
19
|
+
- 'script/**/*'
|
20
|
+
- 'vendor/**/*'
|
21
|
+
- 'test/dummy/db/**/*'
|
22
|
+
- 'test/dummy/vendor/**/*'
|
23
|
+
|
24
|
+
Rails:
|
25
|
+
Enabled: true
|
26
|
+
|
27
|
+
Documentation:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Metrics/LineLength:
|
31
|
+
Max: 200
|
32
|
+
# Enabled: false
|
33
|
+
|
34
|
+
Metrics/MethodLength:
|
35
|
+
Max: 40
|
36
|
+
# Enabled: false
|
37
|
+
|
38
|
+
Metrics/ModuleLength:
|
39
|
+
Max: 500
|
40
|
+
# Enabled: false
|
41
|
+
|
42
|
+
Metrics/AbcSize:
|
43
|
+
# The ABC size is a calculated magnitude, so this number can be a Fixnum or a Float.
|
44
|
+
# http://c2.com/cgi/wiki?AbcMetric
|
45
|
+
Max: 50
|
46
|
+
Exclude:
|
47
|
+
- 'test/**/*_test.rb' # ignore test methods which typically have high B count due to many asserts
|
48
|
+
|
49
|
+
Metrics/CyclomaticComplexity:
|
50
|
+
# http://www.rubydoc.info/github/bbatsov/rubocop/Rubocop/Cop/Style/CyclomaticComplexity
|
51
|
+
Max: 12
|
52
|
+
Exclude:
|
53
|
+
- 'test/**/*_test.rb'
|
54
|
+
|
55
|
+
Metrics/PerceivedComplexity:
|
56
|
+
# http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Metrics/PerceivedComplexity
|
57
|
+
Max: 13
|
58
|
+
Exclude:
|
59
|
+
- 'test/**/*_test.rb'
|
60
|
+
|
61
|
+
Style/RedundantReturn:
|
62
|
+
Enabled: false
|
63
|
+
|
64
|
+
Style/GuardClause:
|
65
|
+
Enabled: false
|
66
|
+
|
67
|
+
Style/IndentHash:
|
68
|
+
EnforcedStyle: consistent
|
69
|
+
|
70
|
+
Style/IndentArray:
|
71
|
+
EnforcedStyle: consistent
|
72
|
+
|
73
|
+
Metrics/ClassLength:
|
74
|
+
Max: 200
|
75
|
+
|
76
|
+
Style/RedundantSelf:
|
77
|
+
Enabled: false
|
78
|
+
|
79
|
+
Style/NegatedIf:
|
80
|
+
Enabled: false
|
81
|
+
|
82
|
+
Style/DefWithParentheses:
|
83
|
+
Enabled: false
|
84
|
+
|
85
|
+
Style/MultilineMethodCallIndentation:
|
86
|
+
EnforcedStyle: indented
|
87
|
+
|
88
|
+
Style/AlignParameters:
|
89
|
+
EnforcedStyle: with_fixed_indentation
|
90
|
+
|
91
|
+
Style/SingleLineBlockParams:
|
92
|
+
Enabled: false
|
93
|
+
|
94
|
+
Style/FrozenStringLiteralComment:
|
95
|
+
Enabled: true
|
96
|
+
|
97
|
+
Lint/EndAlignment:
|
98
|
+
EnforcedStyleAlignWith: variable
|
99
|
+
|
100
|
+
CaseIndentation:
|
101
|
+
EnforcedStyle: end
|
102
|
+
IndentOneStep: false
|
103
|
+
|
104
|
+
Style/FrozenStringLiteralComment:
|
105
|
+
Enabled: false
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Barcoop
|
4
|
+
module Cops
|
5
|
+
class AvoidFixtures < RuboCop::Cop::Cop
|
6
|
+
def on_send(node)
|
7
|
+
_receiver, method_name = *node
|
8
|
+
if method_name == :fixtures
|
9
|
+
msg = 'Avoid using fixtures, use FactoryGirl instead'
|
10
|
+
add_offense(node, :expression, msg)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Barcoop
|
4
|
+
module Cops
|
5
|
+
class AvoidRailsEnv < RuboCop::Cop::Cop
|
6
|
+
# def uncomment_to_test_this_cop()
|
7
|
+
# _foo = Rails.env.production?
|
8
|
+
# end
|
9
|
+
|
10
|
+
def rails_env?(node)
|
11
|
+
is_rails_env = false
|
12
|
+
if node.send_type?
|
13
|
+
receiver, method_name = *node
|
14
|
+
is_rails_env = method_name == :env && receiver.const_type? && receiver.const_name == 'Rails'
|
15
|
+
end
|
16
|
+
return is_rails_env
|
17
|
+
end
|
18
|
+
|
19
|
+
def on_send(node)
|
20
|
+
receiver, method_name = *node
|
21
|
+
if %i(production? development? test?).include?(method_name)
|
22
|
+
msg = 'Avoid using Rails.env.environment? and prefer adding a feature flag in the configuration file.'
|
23
|
+
add_offense(node, :expression, msg) if rails_env?(receiver)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Barcoop
|
4
|
+
module Cops
|
5
|
+
class AvoidTimeout < RuboCop::Cop::Cop
|
6
|
+
# def uncomment_to_test_this_cop()
|
7
|
+
# Timeout.timeout(5) do
|
8
|
+
# _foo = 'Timeout.timeout sucks http://www.mikeperham.com/2015/05/08/timeout-rubys-most-dangerous-api/'
|
9
|
+
# end
|
10
|
+
# timeout(5) do
|
11
|
+
# _bar = 'This is a deprecated call'
|
12
|
+
# end
|
13
|
+
# end
|
14
|
+
|
15
|
+
def on_send(node)
|
16
|
+
receiver, method_name = *node
|
17
|
+
if method_name == :timeout
|
18
|
+
if receiver.nil? || (receiver.const_type? && receiver.const_name == 'Timeout')
|
19
|
+
# TODO: add a real link, like AtomLinter/linter-shellcheck
|
20
|
+
msg = 'Timeout.timeout is not thread safe, see http://www.mikeperham.com/2015/05/08/timeout-rubys-most-dangerous-api/'
|
21
|
+
add_offense(node, :expression, msg)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/barcoop.rb
ADDED
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: barcoop
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sergio Medina
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubocop
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.14'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.14'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: barcoo's rubocop config and cops
|
56
|
+
email:
|
57
|
+
- sergio.medina@offerista.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rubocop.yml"
|
64
|
+
- Gemfile
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- barcoop.gemspec
|
68
|
+
- conf/rubocop.yml
|
69
|
+
- lib/barcoop.rb
|
70
|
+
- lib/barcoop/cops/avoid_fixtures.rb
|
71
|
+
- lib/barcoop/cops/avoid_rails_env.rb
|
72
|
+
- lib/barcoop/cops/avoid_timeout.rb
|
73
|
+
- lib/barcoop/version.rb
|
74
|
+
homepage: https://github.com/barcoo/barcoop
|
75
|
+
licenses: []
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.6.11
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: barcoo's rubocop config and cops
|
97
|
+
test_files: []
|