ducalis 0.7.0 → 0.8.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
- SHA1:
3
- metadata.gz: 1cebb8b9bfce243520e492e14428a31520166d57
4
- data.tar.gz: 71377e24c677052deba2729e4d6edad9d5661408
2
+ SHA256:
3
+ metadata.gz: 9b9c876d0a00b147a1b951611b7ad2f0e7c1acfaecdb03f00a76a206e582678b
4
+ data.tar.gz: 447e6dbfb3ae6d84b6f63234ae66aa7db0741ef463daaca07ed3715bcccdf160
5
5
  SHA512:
6
- metadata.gz: a80ee7b95acfc74476566eb5c5cf4b02dd94889a27f1832772e30d6e85cc923443dcf3e659847e455c3884dde71b1fcb75e09a85bb2e1ebd3cc4cbe81af3ebd8
7
- data.tar.gz: 113862c9e97fd9c418f31ccd172153660daf9406307fa5e8fbb5756658b173ebda5ce8e7dde7f5dfe00cfcf1d0e157fad33d3daca70d84fd5c514702e5709a81
6
+ metadata.gz: cc5cfd83af5d1754ece8f915ffcf04850f39f167fa79c89845b610c9e1b53835a536479598241d1e81e7559f4265ee04d665073f7190e734acea05c270667d74
7
+ data.tar.gz: 36ee864dfdd14acc6f941ca5ade14876cff2cfd2a49020d146326010340e9ee7f519c5e36c740f6e46b5323c04a64ab3aeea4fe20277594fa6b5c72c236fff1b
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.3.4
1
+ 2.5.1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ducalis (0.7.0)
4
+ ducalis (0.8.0)
5
5
  git (~> 1.3, >= 1.3.0)
6
6
  policial (= 0.0.4)
7
7
  regexp-examples (~> 1.3, >= 1.3.2)
data/README.md CHANGED
@@ -5,26 +5,21 @@
5
5
  [![Maintainability](https://api.codeclimate.com/v1/badges/d03d4e567e8728d2c58b/maintainability)](https://codeclimate.com/github/ignat-z/ducalis/maintainability)
6
6
 
7
7
  __Ducalis__ is RuboCop-based static code analyzer for enterprise Rails applications.
8
- As __Ducalis__ isn't style checker and could sometimes be false-positive it's not
8
+
9
+ Documentation available at https://ducalis-rb.github.io/.
10
+
11
+ __Ducalis__ isn't style checker and could sometimes be false-positive it's not
9
12
  necessary to follow all it rules, the main purpose of __Ducalis__ is help to find
10
13
  possible weak code parts.
11
14
 
12
- [Documentation](<https://ducalis-rb.github.io/>)
15
+ ## Installation and Usage
13
16
 
14
- ## Installation
15
-
16
- Add this line to your application's Gemfile:
17
+ Add this line to your application's `Gemfile`:
17
18
 
18
19
  ```ruby
19
20
  gem 'ducalis'
20
21
  ```
21
22
 
22
- ## License
23
-
24
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
25
-
26
- ## Usage
27
-
28
23
  There are a lot of variants how you can use __Ducalis__:
29
24
 
30
25
  1. As CLI application. In this mode __Ducalis__ will notify you about any
@@ -72,9 +67,19 @@ def remove_audits
72
67
  end
73
68
  ```
74
69
 
70
+ The main behavior of Ducalis can be controlled via the
71
+ [.ducalis.yml](<https://github.com/ignat-z/ducalis/blob/master/config/.ducalis.yml>).
72
+ It makes it possible to enable/disable certain cops (checks) and to alter their
73
+ behavior if they accept any parameters. List of all available cops could be
74
+ found in the [documentation](<https://ducalis-rb.github.io/>).
75
+
76
+ ## License
77
+
78
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
79
+
75
80
  ## Contribution
76
81
 
77
- To pass your code through the all checks you simply need to run:
82
+ Contributions are welcome! To pass your code through the all checks you simply need to run:
78
83
 
79
84
  ```
80
85
  bundle exec rake
data/config/.ducalis.yml CHANGED
@@ -120,3 +120,11 @@ Ducalis/ModuleLikeClass:
120
120
  - Sidekiq::Worker
121
121
  - Singleton
122
122
  - ActiveModel::Model
123
+ - Virtus.model
124
+
125
+ Ducalis/DescriptiveBlockNames:
126
+ Enabled: true
127
+ MinimalLenght: 3
128
+ WhiteList:
129
+ - to
130
+ - id
data/lib/ducalis.rb CHANGED
@@ -37,6 +37,7 @@ require 'ducalis/cops/callbacks_activerecord'
37
37
  require 'ducalis/cops/case_mapping'
38
38
  require 'ducalis/cops/controllers_except'
39
39
  require 'ducalis/cops/data_access_objects'
40
+ require 'ducalis/cops/descriptive_block_names'
40
41
  require 'ducalis/cops/fetch_expression'
41
42
  require 'ducalis/cops/only_defs'
42
43
  require 'ducalis/cops/keyword_defaults'
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubocop'
4
+
5
+ module Ducalis
6
+ class DescriptiveBlockNames < RuboCop::Cop::Cop
7
+ OFFENSE = <<-MESSAGE.gsub(/^ +\|\s/, '').strip
8
+ | Please, use descriptive names as block arguments. There is no any sanse to save on letters.
9
+ MESSAGE
10
+
11
+ def on_block(node)
12
+ _send, args, _inner = *node
13
+ block_arguments(args).each do |violation_node|
14
+ add_offense(violation_node, :expression, OFFENSE)
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def violate?(node)
21
+ node.to_s.length < minimal_length &&
22
+ !node.to_s.start_with?('_') &&
23
+ !white_list.include?(node.to_s)
24
+ end
25
+
26
+ def white_list
27
+ cop_config.fetch('WhiteList')
28
+ end
29
+
30
+ def minimal_length
31
+ cop_config.fetch('MinimalLenght').to_i
32
+ end
33
+
34
+ def_node_search :block_arguments, '(arg #violate?)'
35
+ end
36
+ end
@@ -13,6 +13,8 @@ module Ducalis
13
13
  | %<source>s
14
14
  | ```
15
15
 
16
+ | If your hash contains `nil` or `false` values and you want to treat them not like an actual values you should preliminarily remove this values from hash.
17
+ | You can use `compact` (in case if you do not want to ignore `false` values) or `keep_if { |key, value| value }` (if you want to ignore all `false` and `nil` values).
16
18
  MESSAGE
17
19
 
18
20
  def investigate(processed_source)
@@ -66,16 +66,30 @@ end
66
66
 
67
67
  class Documentation
68
68
  SIGNAL_WORD = 'raises'.freeze
69
+ PREFER_WORD = 'better'.freeze
69
70
  RULE_WORD = '[rule]'.freeze
70
71
 
72
+ def cop_rules
73
+ cops.map do |file|
74
+ rules = spec_cases_for(file).select do |desc, _code|
75
+ desc.include?(RULE_WORD)
76
+ end
77
+ [file, rules]
78
+ end
79
+ end
80
+
71
81
  def call
72
- Dir[File.join(File.dirname(__FILE__), 'cops', '*.rb')].sort.map do |f|
82
+ cops.map do |f|
73
83
  present_cop(klass_const_for(f), spec_cases_for(f))
74
84
  end.flatten.join("\n")
75
85
  end
76
86
 
77
87
  private
78
88
 
89
+ def cops
90
+ Dir[File.join(File.dirname(__FILE__), 'cops', '*.rb')].sort
91
+ end
92
+
79
93
  def present_cop(klass, specs)
80
94
  [
81
95
  "## #{klass}\n", # header
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ducalis
4
- VERSION = '0.7.0'.freeze
4
+ VERSION = '0.8.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.7.0
4
+ version: 0.8.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-19 00:00:00.000000000 Z
11
+ date: 2018-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git
@@ -116,6 +116,7 @@ files:
116
116
  - lib/ducalis/cops/case_mapping.rb
117
117
  - lib/ducalis/cops/controllers_except.rb
118
118
  - lib/ducalis/cops/data_access_objects.rb
119
+ - lib/ducalis/cops/descriptive_block_names.rb
119
120
  - lib/ducalis/cops/enforce_namespace.rb
120
121
  - lib/ducalis/cops/evlis_overusing.rb
121
122
  - lib/ducalis/cops/extensions/rubocop_cast.rb
@@ -174,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
175
  version: '0'
175
176
  requirements: []
176
177
  rubyforge_project:
177
- rubygems_version: 2.5.2
178
+ rubygems_version: 2.7.6
178
179
  signing_key:
179
180
  specification_version: 4
180
181
  summary: RuboCop based static code analyzer