barcoop 0.2.3 → 0.2.4
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/conf/rubocop.yml +1 -1
- data/conf/rubocop_rails.yml +2 -2
- data/lib/barcoop/cop/barcoo/avoid_fixtures.rb +18 -0
- data/lib/barcoop/cop/barcoo/avoid_rails_env.rb +31 -0
- data/lib/barcoop/cop/barcoo/avoid_timeout.rb +30 -0
- data/lib/barcoop/version.rb +1 -1
- metadata +4 -4
- data/lib/barcoop/cops/avoid_fixtures.rb +0 -15
- data/lib/barcoop/cops/avoid_rails_env.rb +0 -28
- data/lib/barcoop/cops/avoid_timeout.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe78a4f14b92fcc57af4a34a86d25bee198a3073
|
4
|
+
data.tar.gz: cfee362b2207fb7e759786a6b83c3643991962c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5aece3f4cfbd163fcc8614bce668a8de73423c7244fa2fb1481b64bce7f51f4378118c1f095ffa8717f16664db73ae8197cb29bb22264d633dfb8b5c1704c877
|
7
|
+
data.tar.gz: df23af6ddd33a2d2444afd21536a7394a98d40d1fbd7b98f5bd3dbdf5f10a679dcc6e4b830d0bb03b3d9ba64331bb607f2df981303c0e12b72f7e5a58a26039b
|
data/conf/rubocop.yml
CHANGED
data/conf/rubocop_rails.yml
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# cops are nested this way because the name of the cop is LastModule::ClassName
|
4
|
+
module Barcoop
|
5
|
+
module Cop
|
6
|
+
module Barcoo
|
7
|
+
class AvoidFixtures < RuboCop::Cop::Cop
|
8
|
+
def on_send(node)
|
9
|
+
_receiver, method_name = *node
|
10
|
+
if method_name == :fixtures
|
11
|
+
msg = 'Avoid using fixtures, use FactoryGirl instead'
|
12
|
+
add_offense(node, :expression, msg)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# cops are nested this way because the name of the cop is LastModule::ClassName
|
4
|
+
module Barcoop
|
5
|
+
module Cop
|
6
|
+
module Barcoo
|
7
|
+
class AvoidRailsEnv < RuboCop::Cop::Cop
|
8
|
+
# def uncomment_to_test_this_cop()
|
9
|
+
# _foo = Rails.env.production?
|
10
|
+
# end
|
11
|
+
|
12
|
+
def rails_env?(node)
|
13
|
+
is_rails_env = false
|
14
|
+
if node.send_type?
|
15
|
+
receiver, method_name = *node
|
16
|
+
is_rails_env = method_name == :env && receiver.const_type? && receiver.const_name == 'Rails'
|
17
|
+
end
|
18
|
+
return is_rails_env
|
19
|
+
end
|
20
|
+
|
21
|
+
def on_send(node)
|
22
|
+
receiver, method_name = *node
|
23
|
+
if %i(production? development? test?).include?(method_name)
|
24
|
+
msg = 'Avoid using Rails.env.environment? and prefer adding a feature flag in the configuration file.'
|
25
|
+
add_offense(node, :expression, msg) if rails_env?(receiver)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# cops are nested this way because the name of the cop is LastModule::ClassName
|
4
|
+
module Barcoop
|
5
|
+
module Cop
|
6
|
+
module Barcoo
|
7
|
+
class AvoidTimeout < RuboCop::Cop::Cop
|
8
|
+
# def uncomment_to_test_this_cop()
|
9
|
+
# Timeout.timeout(5) do
|
10
|
+
# _foo = 'Timeout.timeout sucks http://www.mikeperham.com/2015/05/08/timeout-rubys-most-dangerous-api/'
|
11
|
+
# end
|
12
|
+
# timeout(5) do
|
13
|
+
# _bar = 'This is a deprecated call'
|
14
|
+
# end
|
15
|
+
# end
|
16
|
+
|
17
|
+
def on_send(node)
|
18
|
+
receiver, method_name = *node
|
19
|
+
if method_name == :timeout
|
20
|
+
if receiver.nil? || (receiver.const_type? && receiver.const_name == 'Timeout')
|
21
|
+
# TODO: add a real link, like AtomLinter/linter-shellcheck
|
22
|
+
msg = 'Timeout.timeout is not thread safe, see http://www.mikeperham.com/2015/05/08/timeout-rubys-most-dangerous-api/'
|
23
|
+
add_offense(node, :expression, msg)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/barcoop/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: barcoop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Medina
|
@@ -68,9 +68,9 @@ files:
|
|
68
68
|
- conf/rubocop.yml
|
69
69
|
- conf/rubocop_rails.yml
|
70
70
|
- lib/barcoop.rb
|
71
|
-
- lib/barcoop/
|
72
|
-
- lib/barcoop/
|
73
|
-
- lib/barcoop/
|
71
|
+
- lib/barcoop/cop/barcoo/avoid_fixtures.rb
|
72
|
+
- lib/barcoop/cop/barcoo/avoid_rails_env.rb
|
73
|
+
- lib/barcoop/cop/barcoo/avoid_timeout.rb
|
74
74
|
- lib/barcoop/version.rb
|
75
75
|
homepage: https://github.com/barcoo/barcoop
|
76
76
|
licenses: []
|
@@ -1,15 +0,0 @@
|
|
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
|
@@ -1,28 +0,0 @@
|
|
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
|
@@ -1,27 +0,0 @@
|
|
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
|