rubocop-elegant 0.0.13 → 0.0.15

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52b4a90ea309c9255ce91551140e414d270d93084d5db71ab0ca6c274b989064
4
- data.tar.gz: 88cf9d0d858f6c551fa8b4adc9c9a319f8008496f97853f458c6c419c61d8b7b
3
+ metadata.gz: 41a4bba1e8a54cc943ed7c75113c8a1786b4e8ae7b8e7b886133ab657bfff375
4
+ data.tar.gz: 6d16cb13b8b1c5d5a79ee8c39462d6957a0cc49b798294b7fe1fce3473018e72
5
5
  SHA512:
6
- metadata.gz: 8578b0c3c3ec4dfda7a4bb23be3595cebffc8fc6a61189fe671d24f64ee520e3b12db3e76651d6885c6b8d29e18692f1f0cb806aac70cf1e3a4eb25cca57d303
7
- data.tar.gz: 0b73760980abf0f65481797d62e82fa7e813dbc980cb9f14274ce2185132ea68dcbd116d0b0ceff8fb9ae4650f1724b76aab4534ffe8bc268111ab80845e7540
6
+ metadata.gz: 480a11bf5d184e5e899b3ac48bd17270bdda9fe84417aa837d5ced0f0b8efe6e77caada317cd4386d903a4a5477a7254fa5c609f1701b7b09fc4ea9500257afe
7
+ data.tar.gz: d5e924d77377f1446657e4c5457aab1b86763cc0fe5fb7d0d3cf79d212795f28eec3f686bac0744a99671dcd16a768c788c26f6e2db9a3b908011d9a8b7ecbc9
data/config/default.yml CHANGED
@@ -16,12 +16,14 @@ Elegant/GoodVariableName:
16
16
  Description: 'Checks that variable names match the configured pattern'
17
17
  Enabled: true
18
18
  VersionAdded: '0.0.3'
19
- Pattern: '^(@{1,2}|\$)?(the_|test_|fake_)?[a-z]{1,16}$'
19
+ Pattern: '^(_.*|(@{1,2}|\$)?(the_|test_|fake_)?[a-z]{1,16})$'
20
+ AllowedNames: []
20
21
  Elegant/GoodMethodName:
21
22
  Description: 'Checks that method names match the configured pattern'
22
23
  Enabled: true
23
24
  VersionAdded: '0.0.3'
24
- Pattern: '^((fake_|the_)?[a-z]{1,16}[!?]?|test_[a-z_]+|on_[a-z_]+)$'
25
+ Pattern: '^(((to|fake|the|with|without|on)_)?[a-z]{1,16}[!?]?|test_[a-z_]+)$'
26
+ AllowedNames: []
25
27
 
26
28
  Naming/VariableName:
27
29
  Enabled: false
@@ -21,6 +21,7 @@ module RuboCop
21
21
  private
22
22
 
23
23
  def check(node, name)
24
+ return if allowed?(name)
24
25
  return if match?(name)
25
26
  add_offense(node, message: format(MSG, name: name))
26
27
  end
@@ -29,6 +30,10 @@ module RuboCop
29
30
  pattern.match?(name)
30
31
  end
31
32
 
33
+ def allowed?(name)
34
+ Array(cop_config['AllowedNames']).map(&:to_s).include?(name)
35
+ end
36
+
32
37
  def pattern
33
38
  @pattern ||= Regexp.new(cop_config['Pattern'] || '^[a-z]+[!?]?$')
34
39
  end
@@ -29,6 +29,7 @@ module RuboCop
29
29
  private
30
30
 
31
31
  def check(node, name)
32
+ return if allowed?(name)
32
33
  return if match?(name)
33
34
  add_offense(node, message: format(MSG, name: name))
34
35
  end
@@ -37,6 +38,10 @@ module RuboCop
37
38
  pattern.match?(name)
38
39
  end
39
40
 
41
+ def allowed?(name)
42
+ Array(cop_config['AllowedNames']).map(&:to_s).include?(name)
43
+ end
44
+
40
45
  def pattern
41
46
  @pattern ||= Regexp.new(cop_config['Pattern'] || '^[a-z]+$')
42
47
  end
@@ -12,11 +12,13 @@ module RuboCop
12
12
  MSG = 'Comment is not allowed, unless it is SPDX, magic, rubocop directive, or docblock'
13
13
  public_constant :MSG
14
14
 
15
+ # rubocop:disable Elegant/GoodMethodName
15
16
  def on_new_investigation
16
17
  processed_source.comments.each do |comment|
17
18
  register(comment) unless allowed?(comment)
18
19
  end
19
20
  end
21
+ # rubocop:enable Elegant/GoodMethodName
20
22
 
21
23
  private
22
24
 
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to?(:required_rubygems_version=)
10
10
  s.required_ruby_version = '>=2.2'
11
11
  s.name = 'rubocop-elegant'
12
- s.version = '0.0.13'
12
+ s.version = '0.0.15'
13
13
  s.license = 'MIT'
14
14
  s.summary = 'Set of custom RuboCop cops for elegant Ruby coding'
15
15
  s.description =
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-elegant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko