arcadia_cops 4.0.2 → 4.0.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
  SHA256:
3
- metadata.gz: 6651da173543ee1ffb9d8e31b0dfda75c35ef5454f9d1ff054160ae5d621041a
4
- data.tar.gz: d7e2497155d064da862d66b65a1163f5abe01ef1a0afee89df5e879ac46ea281
3
+ metadata.gz: 6e254a8851f6048dabca6101e69ab0160d19a6155636f8fd46eb46e8970ed17f
4
+ data.tar.gz: b2d36f4a92357caf5468c31deab4e1af9894220da245ea51e7a4bae4f84d946c
5
5
  SHA512:
6
- metadata.gz: dc99132ea7385e8d1e9cd2943b130fd2736dfef8f6a024b8b341fc4748ee519588f290c8af65c5806ef8460427d72ba21a4532a97bc9b36a54f7db12cb1cef59
7
- data.tar.gz: '03087562410c086336d1d94f59431675a5b10bef7ad631acd27857e63eb15653c0bbc1fd5357a34f1d9e380f578c11ccee7963a650eb6b10f341a2a48356006f'
6
+ metadata.gz: a4a552a043a4889583cb7e2be39c74663b9b66906265b069efa674185a6e4ef7c82c55e4040e28305aec637b2290677f4921e962e41efdc420a8f7826cbcff6d
7
+ data.tar.gz: 6f26d7596c968cc0559b3d47190bf1d09755bd507d02705654b2c8476dcdaa040bdc282af30704ad41cb904c1f4e81435d150b51bff5d775dfeadd66909b0f14
data/README.md CHANGED
@@ -18,6 +18,8 @@ Add a new cop to the `enabled.yml`, bump the version, and put in a PR for review
18
18
 
19
19
  To see all cops including those that aren't enabled run `bundle exec rubocop --show-cops`.
20
20
 
21
+ WHen developing custom cops, make sure to add specs and run run `bundle exec rspec` before releasing.
22
+
21
23
  ## Release
22
24
 
23
25
  Ensure you have bumped the version and run `rake release` to release to rubygems.org.
data/config/config.yml CHANGED
@@ -4,6 +4,7 @@
4
4
  require:
5
5
  - rubocop-rails
6
6
  - rubocop-rspec
7
+ - ../lib/arcadia_cops.rb
7
8
 
8
9
  # Common configuration.
9
10
  AllCops:
data/config/enabled.yml CHANGED
@@ -687,3 +687,9 @@ Style/Not:
687
687
 
688
688
  Style/NegatedUnless:
689
689
  Enabled: true
690
+
691
+ ArcadiaCops/SimpleModifierConditional:
692
+ Enabled: true
693
+
694
+ ArcadiaCops/SimpleUnless:
695
+ Enabled: true
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ArcadiaCops
4
+ # Cop to tackle prevent more complicated modifier if/unless statements
5
+ # https://github.com/airbnb/ruby/blob/12435e8136d2adf710de999bc0f6bef01215df2c/rubocop-airbnb/lib/rubocop/cop/airbnb/simple_modifier_conditional.rb
6
+ class SimpleModifierConditional < RuboCop::Cop::Cop
7
+ MSG = 'Modifier if/unless usage is okay when the body is simple, ' \
8
+ 'the condition is simple, and the whole thing fits on one line. ' \
9
+ 'Otherwise, avoid modifier if/unless.'.freeze
10
+
11
+ def_node_matcher :multiple_conditionals?, '(if ({and or :^} ...) ...)'
12
+
13
+ def on_if(node)
14
+ return unless node.modifier_form?
15
+
16
+ if multiple_conditionals?(node) || node.multiline?
17
+ add_offense(node)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ArcadiaCops
4
+ # Cop to tackle prevent unless statements with multiple conditions
5
+ # https://github.com/airbnb/ruby/blob/12435e8136d2adf710de999bc0f6bef01215df2c/rubocop-airbnb/lib/rubocop/cop/airbnb/simple_unless.rb
6
+ class SimpleUnless < RuboCop::Cop::Cop
7
+ MSG = 'Unless usage is okay when there is only one conditional'.freeze
8
+
9
+ def_node_matcher :multiple_conditionals?, '(if ({and or :^} ...) ...)'
10
+
11
+ def on_if(node)
12
+ return unless node.unless?
13
+
14
+ add_offense(node) if multiple_conditionals?(node)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubocop'
4
+ Dir.glob(File.expand_path('arcadia_cops/*.rb', File.dirname(__FILE__))).map(&method(:require))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arcadia_cops
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.2
4
+ version: 4.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - engineering
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-07 00:00:00.000000000 Z
11
+ date: 2023-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.29.1
19
+ version: '1.29'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.29.1
26
+ version: '1.29'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rubocop-rails
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 2.0.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rake
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +94,7 @@ dependencies:
80
94
  - - ">="
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
- description: Contains enabled rubocops for arcadia power ruby repos.
97
+ description: Contains enabled rubocops for Arcadia ruby repos.
84
98
  email:
85
99
  - engineering@arcadia.com
86
100
  executables: []
@@ -90,11 +104,14 @@ files:
90
104
  - README.md
91
105
  - config/config.yml
92
106
  - config/enabled.yml
107
+ - lib/arcadia_cops.rb
108
+ - lib/arcadia_cops/simple_modifier_conditional.rb
109
+ - lib/arcadia_cops/simple_unless.rb
93
110
  homepage: https://github.com/ArcadiaPower/arcadia_cops/
94
111
  licenses:
95
112
  - MIT
96
113
  metadata: {}
97
- post_install_message:
114
+ post_install_message:
98
115
  rdoc_options: []
99
116
  require_paths:
100
117
  - lib
@@ -109,8 +126,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
126
  - !ruby/object:Gem::Version
110
127
  version: '0'
111
128
  requirements: []
112
- rubygems_version: 3.1.6
113
- signing_key:
129
+ rubygems_version: 3.4.9
130
+ signing_key:
114
131
  specification_version: 4
115
- summary: Arcadia Power Style Cops
132
+ summary: Arcadia Style Cops
116
133
  test_files: []