arcadia_cops 4.0.2 → 4.0.3

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: 6fa3774ee46a2326ed47a8c64c089fd5fb681e2c0f4e1d56d3d09126d2ea72f0
4
+ data.tar.gz: d0dd3053c5f3f6edc72c04d2932f9d42a0622e9abec2332662e1649156179b48
5
5
  SHA512:
6
- metadata.gz: dc99132ea7385e8d1e9cd2943b130fd2736dfef8f6a024b8b341fc4748ee519588f290c8af65c5806ef8460427d72ba21a4532a97bc9b36a54f7db12cb1cef59
7
- data.tar.gz: '03087562410c086336d1d94f59431675a5b10bef7ad631acd27857e63eb15653c0bbc1fd5357a34f1d9e380f578c11ccee7963a650eb6b10f341a2a48356006f'
6
+ metadata.gz: 3431f7f1a85ce8dbea1e054057a52ba2604887debe3434f6fcdd98f552130924febe617414720089e4e3aedf956d80d2b2797873c959909385da18519303432a
7
+ data.tar.gz: 7feddebc66a0eea0b7ce21b0994a526b4a6e4daa52972a4531f25e8e67352e5510ca60634c1a14c0d851238c52dbfb9ddcb753315cd32fb6a2d41c2c7f088421
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.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-07 00:00:00.000000000 Z
11
+ date: 2022-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -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,6 +104,9 @@ 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
@@ -112,5 +129,5 @@ requirements: []
112
129
  rubygems_version: 3.1.6
113
130
  signing_key:
114
131
  specification_version: 4
115
- summary: Arcadia Power Style Cops
132
+ summary: Arcadia Style Cops
116
133
  test_files: []