ducalis 0.6.0 → 0.7.0

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
  SHA1:
3
- metadata.gz: c318246f914585d93588a49a31dfb31c7598b5f5
4
- data.tar.gz: 8a4d1be3c918559feffab7275779250d76c60dfb
3
+ metadata.gz: 1cebb8b9bfce243520e492e14428a31520166d57
4
+ data.tar.gz: 71377e24c677052deba2729e4d6edad9d5661408
5
5
  SHA512:
6
- metadata.gz: 319fb773559268eec362ae2a8f561d6f92a2f77d9d9b44825d4eb0fa70548173af97cdf266346677231ca152da5e9d416478b60a1b322845c1f576e55035b032
7
- data.tar.gz: 4c81501488830a22fb562b31c32f4104f0d47d9dda9ab5102c2a0c9b149a328c30ead9a774f1368869af7cc128d8a86d3f2631be9f3783994fc993e0a2e0b732
6
+ metadata.gz: a80ee7b95acfc74476566eb5c5cf4b02dd94889a27f1832772e30d6e85cc923443dcf3e659847e455c3884dde71b1fcb75e09a85bb2e1ebd3cc4cbe81af3ebd8
7
+ data.tar.gz: 113862c9e97fd9c418f31ccd172153660daf9406307fa5e8fbb5756658b173ebda5ce8e7dde7f5dfe00cfcf1d0e157fad33d3daca70d84fd5c514702e5709a81
@@ -1,6 +1,6 @@
1
1
  engines:
2
2
  rubocop:
3
3
  enabled: true
4
- channel: rubocop-0-46
4
+ channel: rubocop-0-52
5
5
  config:
6
6
  file: .rubocop.yml
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.3
2
+ TargetRubyVersion: 2.1
3
3
  UseCache: false
4
4
  Exclude:
5
5
  - 'client/vendor/bundle/**/*'
@@ -1,5 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.1.1
3
4
  - 2.2.9
4
5
  - 2.3.6
5
6
  - 2.4.3
@@ -7,3 +8,10 @@ before_install:
7
8
  - gem update --system
8
9
  - gem --version
9
10
  - gem install bundler
11
+ script:
12
+ - bundle exec rake
13
+ - bash bin/legacy_versions_test.sh
14
+ matrix:
15
+ include:
16
+ - rvm: 2.5.0
17
+ env: IGNORE_LEGACY=true
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ducalis (0.6.0)
4
+ ducalis (0.7.0)
5
5
  git (~> 1.3, >= 1.3.0)
6
6
  policial (= 0.0.4)
7
7
  regexp-examples (~> 1.3, >= 1.3.2)
8
- rubocop (~> 0.46.0, >= 0.45.0)
8
+ rubocop (>= 0.45.0)
9
9
 
10
10
  GEM
11
11
  remote: https://rubygems.org/
@@ -37,6 +37,7 @@ GEM
37
37
  multipart-post (2.0.0)
38
38
  octokit (4.8.0)
39
39
  sawyer (~> 0.8.0, >= 0.5.3)
40
+ parallel (1.12.1)
40
41
  parser (2.5.0.0)
41
42
  ast (~> 2.4.0)
42
43
  policial (0.0.4)
@@ -45,19 +46,18 @@ GEM
45
46
  octokit (~> 4.3)
46
47
  rubocop (~> 0.39)
47
48
  powerpack (0.1.1)
48
- pry (0.11.2)
49
+ pry (0.11.3)
49
50
  coderay (~> 1.1.0)
50
51
  method_source (~> 0.9.0)
51
52
  public_suffix (3.0.2)
52
- rainbow (2.2.2)
53
- rake
54
- rake (12.1.0)
53
+ rainbow (3.0.0)
54
+ rake (12.3.0)
55
55
  regexp-examples (1.4.2)
56
56
  rspec (3.7.0)
57
57
  rspec-core (~> 3.7.0)
58
58
  rspec-expectations (~> 3.7.0)
59
59
  rspec-mocks (~> 3.7.0)
60
- rspec-core (3.7.0)
60
+ rspec-core (3.7.1)
61
61
  rspec-support (~> 3.7.0)
62
62
  rspec-expectations (3.7.0)
63
63
  diff-lcs (>= 1.2.0, < 2.0)
@@ -65,11 +65,12 @@ GEM
65
65
  rspec-mocks (3.7.0)
66
66
  diff-lcs (>= 1.2.0, < 2.0)
67
67
  rspec-support (~> 3.7.0)
68
- rspec-support (3.7.0)
69
- rubocop (0.46.0)
70
- parser (>= 2.3.1.1, < 3.0)
68
+ rspec-support (3.7.1)
69
+ rubocop (0.52.1)
70
+ parallel (~> 1.10)
71
+ parser (>= 2.4.0.2, < 3.0)
71
72
  powerpack (~> 0.1)
72
- rainbow (>= 1.99.1, < 3.0)
73
+ rainbow (>= 2.2.2, < 4.0)
73
74
  ruby-progressbar (~> 1.7)
74
75
  unicode-display_width (~> 1.0, >= 1.0.1)
75
76
  ruby-progressbar (1.9.0)
@@ -89,4 +90,4 @@ DEPENDENCIES
89
90
  rspec (~> 3.0)
90
91
 
91
92
  BUNDLED WITH
92
- 1.16.0.pre.2
93
+ 1.16.1
data/Rakefile CHANGED
@@ -5,8 +5,8 @@ require 'rspec/core/rake_task'
5
5
  require 'rubocop/rake_task'
6
6
 
7
7
  RuboCop::RakeTask.new do |task|
8
- task.options = %w(--auto-correct)
8
+ task.options = %w[--auto-correct]
9
9
  end
10
10
 
11
11
  RSpec::Core::RakeTask.new(:spec)
12
- task default: %i(rubocop spec)
12
+ task default: %i[rubocop spec]
@@ -26,7 +26,7 @@ if ARGV.any? { |arg| arg == '--docs' }
26
26
  end
27
27
 
28
28
  if Ducalis::PassedArgs.ci_mode?
29
- Ducalis::CLI.new(ARGV - %w(--ci)).start
29
+ Ducalis::CLI.new(ARGV - %w[--ci]).start
30
30
  else
31
31
  Ducalis::PassedArgs.process_args!
32
32
 
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+
3
+ set -e
4
+
5
+ if [ -n "${IGNORE_LEGACY-}" ]; then
6
+ echo "$(tput bold)Nothing to test!"
7
+ exit 0;
8
+ fi
9
+
10
+ echo "$(tput bold)Enforcing old RuboCop version: $(tput sgr0)"
11
+ sed -i.bak "s/'>= 0.45.0'/'>= 0.45.0', '0.46.0'/" ducalis.gemspec
12
+ bundle install --no-deployment --quiet --no-color
13
+ bundle show rubocop
14
+ echo "$(tput bold)Running rspec on old RuboCop version: $(tput sgr0)"
15
+ bundle exec rspec --format progress
16
+ echo "$(tput bold)Enforcing new RuboCop version: $(tput sgr0)"
17
+ mv ducalis.gemspec.bak ducalis.gemspec
18
+ bundle install --no-deployment --quiet --no-color
19
+ bundle show rubocop
20
+ echo "$(tput bold)Running rspec on new RuboCop version: $(tput sgr0)"
21
+ bundle exec rspec --format progress
@@ -31,5 +31,5 @@ Gem::Specification.new do |spec|
31
31
  spec.add_dependency 'git', '~> 1.3', '>= 1.3.0'
32
32
  spec.add_dependency 'policial', '0.0.4'
33
33
  spec.add_dependency 'regexp-examples', '~> 1.3', '>= 1.3.2'
34
- spec.add_dependency 'rubocop', '>= 0.45.0', '~> 0.46.0'
34
+ spec.add_dependency 'rubocop', '>= 0.45.0'
35
35
  end
@@ -4,7 +4,7 @@ require 'parser/current'
4
4
  require 'policial'
5
5
 
6
6
  module Ducalis
7
- DOTFILE = '.ducalis.yml'
7
+ DOTFILE = '.ducalis.yml'.freeze
8
8
  DUCALIS_HOME = File.realpath(File.join(File.dirname(__FILE__), '..'))
9
9
  DEFAULT_FILE = File.join(DUCALIS_HOME, 'config', DOTFILE)
10
10
  end
@@ -61,3 +61,7 @@ require 'ducalis/cops/too_long_workers'
61
61
  require 'ducalis/cops/uncommented_gem'
62
62
  require 'ducalis/cops/unlocked_gem'
63
63
  require 'ducalis/cops/useless_only'
64
+
65
+ require 'ducalis/cops/extensions/rubocop_cast'
66
+
67
+ RuboCop::Cop::Cop.prepend(RubocopCast)
@@ -5,7 +5,7 @@ require 'logger'
5
5
  module Ducalis
6
6
  module Commentators
7
7
  class Console
8
- DOCUMENTATION_PATH = 'https://ducalis-rb.github.io/'
8
+ DOCUMENTATION_PATH = 'https://ducalis-rb.github.io/'.freeze
9
9
 
10
10
  def initialize(config)
11
11
  @config = config
@@ -3,7 +3,7 @@
3
3
  module Ducalis
4
4
  module Commentators
5
5
  class Github
6
- STATUS = 'COMMENT'
6
+ STATUS = 'COMMENT'.freeze
7
7
  SIMILARITY_THRESHOLD = 0.8
8
8
 
9
9
  def initialize(config)
@@ -15,7 +15,7 @@ module Ducalis
15
15
  | You can read more [here](https://medium.com/planet-arkency/a61fd75ab2d3).
16
16
  MESSAGE
17
17
 
18
- METHODS_BLACK_LIST = %i(
18
+ METHODS_BLACK_LIST = %i[
19
19
  after_commit
20
20
  after_create
21
21
  after_destroy
@@ -35,7 +35,7 @@ module Ducalis
35
35
  before_save
36
36
  before_update
37
37
  before_validation
38
- ).freeze
38
+ ].freeze
39
39
 
40
40
  def on_send(node)
41
41
  return unless in_model?
@@ -8,8 +8,8 @@ module Ducalis
8
8
  | Prefer to use `:only` over `:except` in controllers because it's more explicit and will be easier to maintain for new developers.
9
9
  MESSAGE
10
10
 
11
- FILTERS = %i(before_filter after_filter around_filter
12
- before_action after_action around_action).freeze
11
+ FILTERS = %i[before_filter after_filter around_filter
12
+ before_action after_action around_action].freeze
13
13
 
14
14
  def on_send(node)
15
15
  _, method_name, *args = *node
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubocopCast
4
+ OLD_RUBOCOP_VERSION = Gem::Version.new('0.46.0')
5
+
6
+ def add_offense(node, loc, message = nil, severity = nil)
7
+ if Gem::Version.new(RuboCop::Version.version) > OLD_RUBOCOP_VERSION
8
+ super(node, location: loc, message: message, severity: severity)
9
+ else
10
+ super(node, loc, message, severity)
11
+ end
12
+ end
13
+ end
@@ -1,18 +1,19 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module TypeResolving
3
- MODELS_CLASS_NAMES = %w(
4
+ MODELS_CLASS_NAMES = %w[
4
5
  ApplicationRecord
5
6
  ActiveRecord::Base
6
- ).freeze
7
+ ].freeze
7
8
 
8
- WORKERS_SUFFIXES = %w(
9
+ WORKERS_SUFFIXES = %w[
9
10
  Worker
10
11
  Job
11
- ).freeze
12
+ ].freeze
12
13
 
13
- CONTROLLER_SUFFIXES = %w(
14
+ CONTROLLER_SUFFIXES = %w[
14
15
  Controller
15
- ).freeze
16
+ ].freeze
16
17
 
17
18
  SERVICES_PATH = File.join('app', 'services')
18
19
 
@@ -42,9 +42,9 @@ module Ducalis
42
42
  alias on_defs on_def
43
43
  alias on_send on_def
44
44
 
45
- def_node_search :date_today, '(send (const nil :Date) :today)'
46
- def_node_search :date_current, '(send (const nil :Date) :current)'
47
- def_node_search :time_current, '(send (const nil :Time) :current)'
48
- def_node_search :time_now, '(send (const nil :Time) :now)'
45
+ def_node_search :date_today, '(send (const _ :Date) :today)'
46
+ def_node_search :date_current, '(send (const _ :Date) :current)'
47
+ def_node_search :time_current, '(send (const _ :Time) :current)'
48
+ def_node_search :time_now, '(send (const _ :Time) :now)'
49
49
  end
50
50
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'rubocop'
3
4
 
4
5
  module Ducalis
@@ -7,13 +8,13 @@ module Ducalis
7
8
  | Prefer to use %<alternative>s method instead of %<original>s because of %<reason>s.
8
9
  MESSAGE
9
10
 
10
- WHITE_LIST = %w(cache file params attrs options).freeze
11
+ WHITE_LIST = %w[cache file params attrs options].freeze
11
12
 
12
13
  ALWAYS_TRUE = ->(_who, _what, _args) { true }
13
14
 
14
15
  DELETE_CHECK = lambda do |who, _what, args|
15
- !%i(sym str).include?(args.first && args.first.type) &&
16
- args.count <= 1 && !WHITE_LIST.any? { |regex| who.to_s.include?(regex) }
16
+ !%i[sym str].include?(args.first && args.first.type) &&
17
+ args.count <= 1 && WHITE_LIST.none? { |regex| who.to_s.include?(regex) }
17
18
  end
18
19
 
19
20
  VALIDATE_CHECK = lambda do |_who, _what, args|
@@ -64,7 +65,7 @@ module Ducalis
64
65
  }.freeze
65
66
 
66
67
  DETAILS = "Dangerous methods are:
67
- #{DESCRIPTION.keys.map { |name| "`#{name}`" }.join(', ')}."
68
+ #{DESCRIPTION.keys.map { |name| "`#{name}`" }.join(', ')}.".freeze
68
69
 
69
70
  def on_send(node)
70
71
  who, what, *args = *node
@@ -37,9 +37,9 @@ module Ducalis
37
37
  ).freeze
38
38
 
39
39
  DETAILS = "Available regexes are:
40
- #{SELF_DESCRIPTIVE.map { |name| "`#{name}`" }.join(', ')}"
40
+ #{SELF_DESCRIPTIVE.map { |name| "`#{name}`" }.join(', ')}".freeze
41
41
 
42
- DEFAULT_EXAMPLE = 'some_example'
42
+ DEFAULT_EXAMPLE = 'some_example'.freeze
43
43
 
44
44
  def on_begin(node)
45
45
  not_defined_regexes(node).each do |regex|
@@ -17,7 +17,7 @@ module Ducalis
17
17
  | [About RESTful architecture](<https://confreaks.tv/videos/railsconf2017-in-relentless-pursuit-of-rest>)
18
18
  MESSAGE
19
19
 
20
- WHITELIST = %i(index show new edit create update destroy).freeze
20
+ WHITELIST = %i[index show new edit create update destroy].freeze
21
21
 
22
22
  def on_def(node)
23
23
  return unless in_controller?
@@ -10,10 +10,10 @@ module Ducalis
10
10
  MESSAGE
11
11
 
12
12
  VALIDATEBLE_METHODS =
13
- ::Ducalis::CallbacksActiverecord::METHODS_BLACK_LIST + %i(
13
+ ::Ducalis::CallbacksActiverecord::METHODS_BLACK_LIST + %i[
14
14
  validates
15
15
  validate
16
- )
16
+ ]
17
17
 
18
18
  def on_send(node)
19
19
  _, method_name, *args = *node
@@ -30,7 +30,7 @@ module Ducalis
30
30
  def skip_node?(current_node)
31
31
  key, value = *current_node
32
32
  return true unless current_node.type == :pair
33
- return true unless %w(if unless).include?(key.source)
33
+ return true unless %w[if unless].include?(key.source)
34
34
  return true unless value.type == :str
35
35
  false
36
36
  end
@@ -16,13 +16,9 @@ module Ducalis
16
16
 
17
17
  def on_class(node)
18
18
  return unless in_worker?
19
- check_code_length(node)
20
- end
21
-
22
- private
23
-
24
- def message(length, max_length)
25
- format("#{OFFENSE} [%d/%d]", length, max_length)
19
+ length = code_length(node)
20
+ return unless length > max_length
21
+ add_offense(node, :expression, "#{OFFENSE} [#{length}/#{max_length}]")
26
22
  end
27
23
  end
28
24
  end
@@ -12,7 +12,7 @@ module Ducalis
12
12
  | It will increase [bus-factor](<https://en.wikipedia.org/wiki/Bus_factor>).
13
13
  MESSAGE
14
14
 
15
- ALLOWED_KEYS = %w(require group :require :group).freeze
15
+ ALLOWED_KEYS = %w[require group :require :group].freeze
16
16
 
17
17
  def investigate(processed_source)
18
18
  return unless processed_source.ast
@@ -27,7 +27,7 @@ module Ducalis
27
27
 
28
28
  private
29
29
 
30
- def_node_search :gem_declarations, '(send nil :gem str #allowed_args?)'
30
+ def_node_search :gem_declarations, '(send _ :gem str #allowed_args?)'
31
31
 
32
32
  def commented?(processed_source, node)
33
33
  processed_source.comments
@@ -17,6 +17,6 @@ module Ducalis
17
17
  end
18
18
  end
19
19
 
20
- def_node_search :gem_declarations, '(send nil :gem (str _))'
20
+ def_node_search :gem_declarations, '(send _ :gem (str _))'
21
21
  end
22
22
  end
@@ -25,8 +25,8 @@ module Ducalis
25
25
 
26
26
  MESSAGE
27
27
 
28
- FILTERS = %i(before_filter after_filter around_filter
29
- before_action after_action around_action).freeze
28
+ FILTERS = %i[before_filter after_filter around_filter
29
+ before_action after_action around_action].freeze
30
30
 
31
31
  def on_send(node)
32
32
  _, method_name, *args = *node
@@ -65,8 +65,8 @@ class SpecsProcessor < Parser::AST::Processor
65
65
  end
66
66
 
67
67
  class Documentation
68
- SIGNAL_WORD = 'raises'
69
- RULE_WORD = '[rule]'
68
+ SIGNAL_WORD = 'raises'.freeze
69
+ RULE_WORD = '[rule]'.freeze
70
70
 
71
71
  def call
72
72
  Dir[File.join(File.dirname(__FILE__), 'cops', '*.rb')].sort.map do |f|
@@ -5,7 +5,7 @@ require 'singleton'
5
5
 
6
6
  module PatchedRubocop
7
7
  class GitFilesAccess
8
- DELETED = 'deleted'
8
+ DELETED = 'deleted'.freeze
9
9
 
10
10
  include PatchedRubocop::Diffs
11
11
  include Singleton
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ducalis
4
- VERSION = '0.6.0'
4
+ VERSION = '0.7.0'.freeze
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.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ignat Zakrevsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-18 00:00:00.000000000 Z
11
+ date: 2018-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git
@@ -71,9 +71,6 @@ dependencies:
71
71
  - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  version: 0.45.0
74
- - - "~>"
75
- - !ruby/object:Gem::Version
76
- version: 0.46.0
77
74
  type: :runtime
78
75
  prerelease: false
79
76
  version_requirements: !ruby/object:Gem::Requirement
@@ -81,15 +78,13 @@ dependencies:
81
78
  - - ">="
82
79
  - !ruby/object:Gem::Version
83
80
  version: 0.45.0
84
- - - "~>"
85
- - !ruby/object:Gem::Version
86
- version: 0.46.0
87
81
  description: " Ducalis is RuboCop based static code analyzer for enterprise Rails
88
82
  \ applications.\n"
89
83
  email:
90
84
  - iezakrevsky@gmail.com
91
85
  executables:
92
86
  - ducalis
87
+ - legacy_versions_test.sh
93
88
  extensions: []
94
89
  extra_rdoc_files: []
95
90
  files:
@@ -105,6 +100,7 @@ files:
105
100
  - README.md
106
101
  - Rakefile
107
102
  - bin/ducalis
103
+ - bin/legacy_versions_test.sh
108
104
  - config/.ducalis.yml
109
105
  - ducalis.gemspec
110
106
  - lib/ducalis.rb
@@ -122,6 +118,7 @@ files:
122
118
  - lib/ducalis/cops/data_access_objects.rb
123
119
  - lib/ducalis/cops/enforce_namespace.rb
124
120
  - lib/ducalis/cops/evlis_overusing.rb
121
+ - lib/ducalis/cops/extensions/rubocop_cast.rb
125
122
  - lib/ducalis/cops/extensions/type_resolving.rb
126
123
  - lib/ducalis/cops/fetch_expression.rb
127
124
  - lib/ducalis/cops/keyword_defaults.rb