barcoop 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '083d5afc9aa39df36db6326511a599e66e6547bb'
4
- data.tar.gz: 4aa91c0f8d399b2330cedb9841fbda05060181b4
3
+ metadata.gz: fe78a4f14b92fcc57af4a34a86d25bee198a3073
4
+ data.tar.gz: cfee362b2207fb7e759786a6b83c3643991962c6
5
5
  SHA512:
6
- metadata.gz: 88e85efb579edba751443d35b6bdb0520df5323a119f34a6554703883a14c3dbef7058fe58824de0cd1d6c29055ee917c7c02c958baa4055dcf7e47c0500aef1
7
- data.tar.gz: 9308383757ed2bdbf9a30ad1a7ccf11250a5484e4999f6126827ff46d272aa2fba33ec54dae18b00a3d2cce543bce87a4a59b5202306b9b8064cc3679d11b766
6
+ metadata.gz: 5aece3f4cfbd163fcc8614bce668a8de73423c7244fa2fb1481b64bce7f51f4378118c1f095ffa8717f16664db73ae8197cb29bb22264d633dfb8b5c1704c877
7
+ data.tar.gz: df23af6ddd33a2d2444afd21536a7394a98d40d1fbd7b98f5bd3dbdf5f10a679dcc6e4b830d0bb03b3d9ba64331bb607f2df981303c0e12b72f7e5a58a26039b
data/conf/rubocop.yml CHANGED
@@ -4,7 +4,7 @@
4
4
  # for default configuration
5
5
 
6
6
  require:
7
- - barcoop/cops/avoid_timeout.rb
7
+ - barcoop/cop/barcoo/avoid_timeout.rb
8
8
 
9
9
  AllCops:
10
10
  TargetRubyVersion: 2.3
@@ -2,8 +2,8 @@ inherit_from:
2
2
  - rubocop.yml
3
3
 
4
4
  require:
5
- - barcoop/cops/avoid_rails_env.rb
6
- - barcoop/cops/avoid_fixtures.rb
5
+ - barcoop/cop/barcoo/avoid_rails_env.rb
6
+ - barcoop/cop/barcoo/avoid_fixtures.rb
7
7
 
8
8
  Rails:
9
9
  Enabled: true
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Barcoop
4
- VERSION = '0.2.3'
4
+ VERSION = '0.2.4'
5
5
  end
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.3
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/cops/avoid_fixtures.rb
72
- - lib/barcoop/cops/avoid_rails_env.rb
73
- - lib/barcoop/cops/avoid_timeout.rb
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