arcadia_cops 4.0.0 → 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: 714b9d3dc23913b5a89337e4a5551632776738ef54046942157ce6d06c112a7a
4
- data.tar.gz: b7c9d8e5a4e0081656dadf9751c6fa268f163464647c088e24a9862e8d3b3160
3
+ metadata.gz: 6fa3774ee46a2326ed47a8c64c089fd5fb681e2c0f4e1d56d3d09126d2ea72f0
4
+ data.tar.gz: d0dd3053c5f3f6edc72c04d2932f9d42a0622e9abec2332662e1649156179b48
5
5
  SHA512:
6
- metadata.gz: 966b8836e19926088a5df02b7f6e466c2afa13c34df55f2000e491bb251f3ea054c806ab255f9f3dc0e63d2b4c17a3a9c4faa35e88bbcbe6b86b1abf9c7e7637
7
- data.tar.gz: 5d8b2ed5eb87eaea927afa7f76d7499cd4674b7d781eb10605e64b77ebe6ed453fc6c3b1cfda42b8a6e29d59c20d10324f596f96f27c0cd73b8c66a945e36d15
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
@@ -529,9 +529,6 @@ Lint/UselessAssignment:
529
529
  Lint/BinaryOperatorWithIdenticalOperands:
530
530
  Description: 'Checks for comparison of something with itself.'
531
531
 
532
- Lint/UselessElseWithoutRescue:
533
- Description: 'Checks for useless `else` in `begin..end` without `rescue`.'
534
-
535
532
  Lint/UselessSetterCall:
536
533
  Description: 'Checks for useless setter call to a local variable.'
537
534
 
@@ -680,3 +677,19 @@ RSpec/ScatteredLet:
680
677
 
681
678
  RSpec/Focus:
682
679
  Enabled: true
680
+
681
+ Style/AndOr:
682
+ Enabled: true
683
+ EnforcedStyle: always
684
+
685
+ Style/Not:
686
+ Enabled: true
687
+
688
+ Style/NegatedUnless:
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.0
4
+ version: 4.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - engineering
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-23 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
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.13'
19
+ version: 1.29.1
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.13'
26
+ version: 1.29.1
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.2
113
- signing_key:
129
+ rubygems_version: 3.1.6
130
+ signing_key:
114
131
  specification_version: 4
115
- summary: Arcadia Power Style Cops
132
+ summary: Arcadia Style Cops
116
133
  test_files: []