ducalis 0.5.3 → 0.5.4

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
  SHA1:
3
- metadata.gz: 91cf323e4eba82ef0585479b751e91805b46bae2
4
- data.tar.gz: f4e8b12ff782bc3fcf0e220f2f9ec3ca2771fcec
3
+ metadata.gz: 328e7b375b3c04b775fa5857eccbc0ea72fde606
4
+ data.tar.gz: 9e36648c4778ba101e3af5811a8356359383b7a4
5
5
  SHA512:
6
- metadata.gz: 0c79353e420fe0386cd95da89c558668d9cad61a30df8e67c1198aafd910094db80529e1d3be1c3122a37ca0328e647eb02ed1f25cecee92e6fce7ed0165b119
7
- data.tar.gz: 63018b24719db126d2230007546b3b09303dceaf6f00d5abbfe6a6cbe04b5f60d33e7beff930b84a5b1ffc272a6dbc70fc500cda8aa63828ac38182027e5eb6d
6
+ metadata.gz: 89622fd354b5feabd9390c12107a5e651e4dfbd1a3659efdebd578a930b33ebf4a40313723d00fde39b9558954f440413365701e59d891f2502b6bf0ddd10041
7
+ data.tar.gz: 1387adbbc6154a6b2eca280a3cea8d030b0f90fbf3a6bcc53e0604227df29d08607ba8b167d420f78099028d3ed1c2d6c8e130161464da237cfa9ff965fce4e0
@@ -450,6 +450,15 @@ def employee
450
450
  @employee
451
451
  end
452
452
 
453
+ ```
454
+ ## Ducalis::PreferableMethods
455
+
456
+ Prefer to use %<alternative>s method instead of %<original>s because of
457
+ %<reason>s.
458
+
459
+ ![](https://placehold.it/15/f03c15/000000?text=+) raises for `delete` method calling
460
+ ```ruby
461
+ User.where(id: 7).delete
453
462
  ```
454
463
  ## Ducalis::PrivateInstanceAssign
455
464
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ducalis (0.5.3)
4
+ ducalis (0.5.4)
5
5
  git (~> 1.3, >= 1.3.0)
6
6
  policial (= 0.0.4)
7
7
  regexp-examples (~> 1.3, >= 1.3.2)
@@ -11,7 +11,7 @@ module Ducalis
11
11
  end
12
12
 
13
13
  def id
14
- @id ||= ENV.fetch('CI_PULL_REQUEST').split("/").last
14
+ @id ||= ENV.fetch('CI_PULL_REQUEST').split('/').last
15
15
  end
16
16
 
17
17
  def sha
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+ require 'rubocop'
3
+
4
+ module Ducalis
5
+ class PreferableMethods < RuboCop::Cop::Cop
6
+ OFFENSE = %(
7
+ Prefer to use %<alternative>s method instead of %<original>s because of
8
+ %<reason>s.
9
+ ).strip
10
+ DESCRIPTION = {
11
+ # Method => [Alternative, Reason]
12
+ delete_all: [:destroy_all, 'it is not invoking callbacks'],
13
+ delete: [:destroy, 'it is not invoking callbacks']
14
+ }.freeze
15
+
16
+ def on_send(node)
17
+ _who, what, *_args = *node
18
+ return unless DESCRIPTION.keys.include?(what)
19
+ alternative, reason = DESCRIPTION.fetch(what)
20
+ add_offense(node, :expression, format(OFFENSE, original: what,
21
+ alternative: alternative,
22
+ reason: reason))
23
+ end
24
+ end
25
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ducalis
4
- VERSION = '0.5.3'
4
+ VERSION = '0.5.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ducalis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ignat Zakrevsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-31 00:00:00.000000000 Z
11
+ date: 2017-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git
@@ -137,6 +137,7 @@ files:
137
137
  - lib/ducalis/cops/module_like_class.rb
138
138
  - lib/ducalis/cops/params_passing.rb
139
139
  - lib/ducalis/cops/possible_tap.rb
140
+ - lib/ducalis/cops/preferable_methods.rb
140
141
  - lib/ducalis/cops/private_instance_assign.rb
141
142
  - lib/ducalis/cops/protected_scope_cop.rb
142
143
  - lib/ducalis/cops/raise_withour_error_class.rb