reek 3.10.1 → 3.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +26 -25
- data/.simplecov +10 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +3 -2
- data/README.md +11 -0
- data/bin/code_climate_reek +1 -1
- data/docs/Feature-Envy.md +1 -1
- data/docs/style-guide.md +1 -7
- data/lib/reek/ast/ast_node_class_map.rb +1 -1
- data/lib/reek/ast/node.rb +4 -4
- data/lib/reek/ast/object_refs.rb +1 -3
- data/lib/reek/ast/reference_collector.rb +2 -4
- data/lib/reek/ast/sexp_extensions/send.rb +1 -1
- data/lib/reek/ast/sexp_extensions/variables.rb +1 -1
- data/lib/reek/cli/application.rb +3 -12
- data/lib/reek/cli/command.rb +1 -5
- data/lib/reek/cli/option_interpreter.rb +5 -2
- data/lib/reek/cli/reek_command.rb +5 -1
- data/lib/reek/cli/warning_collector.rb +1 -2
- data/lib/reek/code_comment.rb +3 -3
- data/lib/reek/configuration/app_configuration.rb +3 -3
- data/lib/reek/context/attribute_context.rb +3 -1
- data/lib/reek/context/code_context.rb +2 -3
- data/lib/reek/context/statement_counter.rb +4 -2
- data/lib/reek/context/visibility_tracker.rb +6 -6
- data/lib/reek/context_builder.rb +7 -6
- data/lib/reek/examiner.rb +2 -1
- data/lib/reek/rake/task.rb +1 -2
- data/lib/reek/report.rb +4 -4
- data/lib/reek/report/code_climate/code_climate_formatter.rb +2 -3
- data/lib/reek/report/formatter.rb +4 -3
- data/lib/reek/report/report.rb +2 -2
- data/lib/reek/smells/control_parameter.rb +4 -4
- data/lib/reek/smells/data_clump.rb +4 -4
- data/lib/reek/smells/duplicate_method_call.rb +5 -5
- data/lib/reek/smells/long_parameter_list.rb +1 -1
- data/lib/reek/smells/long_yield_list.rb +1 -1
- data/lib/reek/smells/nested_iterators.rb +5 -5
- data/lib/reek/smells/nil_check.rb +1 -1
- data/lib/reek/smells/repeated_conditional.rb +1 -1
- data/lib/reek/smells/smell_configuration.rb +4 -6
- data/lib/reek/smells/smell_detector.rb +4 -3
- data/lib/reek/smells/smell_repository.rb +2 -2
- data/lib/reek/smells/smell_warning.rb +1 -1
- data/lib/reek/smells/too_many_instance_variables.rb +1 -1
- data/lib/reek/smells/too_many_methods.rb +1 -1
- data/lib/reek/smells/too_many_statements.rb +1 -1
- data/lib/reek/smells/uncommunicative_method_name.rb +4 -4
- data/lib/reek/smells/uncommunicative_module_name.rb +4 -4
- data/lib/reek/smells/uncommunicative_parameter_name.rb +4 -4
- data/lib/reek/smells/uncommunicative_variable_name.rb +5 -5
- data/lib/reek/source/source_code.rb +3 -3
- data/lib/reek/source/source_locator.rb +3 -4
- data/lib/reek/spec/should_reek.rb +4 -2
- data/lib/reek/spec/should_reek_of.rb +4 -4
- data/lib/reek/spec/should_reek_only_of.rb +1 -1
- data/lib/reek/spec/smell_matcher.rb +1 -1
- data/lib/reek/tree_dresser.rb +1 -1
- data/lib/reek/version.rb +1 -1
- data/reek.gemspec +1 -2
- data/spec/reek/cli/application_spec.rb +31 -0
- data/spec/reek/cli/reek_command_spec.rb +45 -0
- data/spec/reek/rake/task_spec.rb +33 -0
- data/spec/reek/smells/utility_function_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -2
- data/tasks/configuration.rake +1 -1
- data/tasks/test.rake +1 -1
- metadata +11 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a251ceb10b65df518731985aac57a7f73b29961b
|
4
|
+
data.tar.gz: 9490529cdf278161c31bf009b99bbb39dd9d633f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1a8f22deef9a74aa7eb9938e637372e276b5af8ede419383364579950b4d59d3632bce86b8c023749282bd527fe7e27074f7a18154f8a7356157518c4b690c0
|
7
|
+
data.tar.gz: c2057985478a62c26b33b6e45db1c0dffc11ede4fa188ce6df4191369b8b5d0aba6d3f7b76f3d91004305f965e67e08b31339e6d9f89c3ca65dc2ad209a1ac76
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -22,21 +22,15 @@ Metrics/LineLength:
|
|
22
22
|
Metrics/ParameterLists:
|
23
23
|
CountKeywordArgs: false
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
# Allow small arrays of words with quotes
|
30
|
-
Style/WordArray:
|
31
|
-
MinSize: 3
|
32
|
-
|
33
|
-
# Allow single-line method definitions
|
34
|
-
Style/SingleLineMethods:
|
35
|
-
Enabled: false
|
25
|
+
Style/AccessorMethodName:
|
26
|
+
Exclude:
|
27
|
+
- 'lib/reek/context/visibility_tracker.rb'
|
36
28
|
|
37
|
-
|
38
|
-
|
39
|
-
|
29
|
+
Style/Documentation:
|
30
|
+
Exclude:
|
31
|
+
- 'lib/reek/ast/sexp_extensions/send.rb'
|
32
|
+
- 'lib/reek/ast/sexp_extensions/super.rb'
|
33
|
+
- 'lib/reek/ast/sexp_extensions/variables.rb'
|
40
34
|
|
41
35
|
# Place . on the previous line
|
42
36
|
Style/DotPosition:
|
@@ -50,19 +44,26 @@ Style/EmptyLineBetweenDefs:
|
|
50
44
|
Style/MultilineBlockChain:
|
51
45
|
Enabled: false
|
52
46
|
|
47
|
+
# Indent one level for follow-up lines
|
48
|
+
Style/MultilineMethodCallIndentation:
|
49
|
+
EnforcedStyle: indented
|
50
|
+
|
51
|
+
# Indent one level for follow-up lines
|
52
|
+
Style/MultilineOperationIndentation:
|
53
|
+
EnforcedStyle: indented
|
54
|
+
|
55
|
+
# There's nothing wrong with parallel assignment
|
56
|
+
Style/ParallelAssignment:
|
57
|
+
Enabled: false
|
58
|
+
|
53
59
|
# Allow Perl-style references to regex matches
|
54
60
|
Style/PerlBackrefs:
|
55
61
|
Enabled: false
|
56
62
|
|
57
|
-
|
58
|
-
|
59
|
-
- 'lib/reek/ast/sexp_extensions/send.rb'
|
60
|
-
- 'lib/reek/ast/sexp_extensions/super.rb'
|
61
|
-
- 'lib/reek/ast/sexp_extensions/variables.rb'
|
62
|
-
|
63
|
-
Style/AccessorMethodName:
|
64
|
-
Exclude:
|
65
|
-
- 'lib/reek/context/visibility_tracker.rb'
|
66
|
-
|
67
|
-
Style/ParallelAssignment:
|
63
|
+
# Allow single-line method definitions
|
64
|
+
Style/SingleLineMethods:
|
68
65
|
Enabled: false
|
66
|
+
|
67
|
+
# Allow small arrays of words with quotes
|
68
|
+
Style/WordArray:
|
69
|
+
MinSize: 4
|
data/.simplecov
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
SimpleCov.start do
|
2
|
+
track_files 'lib/**/*.rb'
|
3
|
+
add_filter 'lib/reek/version.rb' # version.rb is loaded too early to test
|
4
|
+
end
|
5
|
+
|
6
|
+
SimpleCov.at_exit do
|
7
|
+
SimpleCov.result.format!
|
8
|
+
SimpleCov.minimum_coverage 98.9
|
9
|
+
SimpleCov.minimum_coverage_by_file 81.4
|
10
|
+
end
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -3,14 +3,15 @@ source 'https://rubygems.org'
|
|
3
3
|
gemspec
|
4
4
|
|
5
5
|
group :development do
|
6
|
-
gem 'aruba', '~> 0.
|
6
|
+
gem 'aruba', '~> 0.12.0'
|
7
7
|
gem 'ataru', '~> 0.2.0'
|
8
8
|
gem 'cucumber', '~> 2.0'
|
9
9
|
gem 'factory_girl', '~> 4.0'
|
10
10
|
gem 'rake', '~> 10.0'
|
11
11
|
gem 'rspec', '~> 3.0'
|
12
|
-
gem 'rubocop', '~> 0.
|
12
|
+
gem 'rubocop', '~> 0.37.0'
|
13
13
|
gem 'yard', '~> 0.8.7'
|
14
|
+
gem 'simplecov', '~> 0.11.1'
|
14
15
|
|
15
16
|
platforms :mri do
|
16
17
|
gem 'redcarpet', '~> 3.3.1'
|
data/README.md
CHANGED
@@ -61,6 +61,17 @@ demo.rb -- 8 warnings:
|
|
61
61
|
[3]:Dirty#awful has unused parameter 'y' (UnusedParameters)
|
62
62
|
```
|
63
63
|
|
64
|
+
## Supported rubies
|
65
|
+
|
66
|
+
`Reek` is officially running on the following MRI rubies:
|
67
|
+
|
68
|
+
- 2.0
|
69
|
+
- 2.1
|
70
|
+
- 2.2
|
71
|
+
- 2.3
|
72
|
+
|
73
|
+
Other rubies like Rubinius or JRuby are not officially supported but should work as well.
|
74
|
+
|
64
75
|
## Fixing Smell Warnings
|
65
76
|
|
66
77
|
Reek focuses on high-level code smells, so we can't tell you how to fix warnings in
|
data/bin/code_climate_reek
CHANGED
data/docs/Feature-Envy.md
CHANGED
@@ -42,7 +42,7 @@ _Feature Envy_ reports any method that refers to self less often than it refers
|
|
42
42
|
|
43
43
|
## Differences to _Utility Function_
|
44
44
|
|
45
|
-
_Feature Envy_ is only triggered if there are some references to self and _[Utility Function](Utility
|
45
|
+
_Feature Envy_ is only triggered if there are some references to self and _[Utility Function](Utility-Function.md)_ is triggered if there are no references to self.
|
46
46
|
|
47
47
|
## Configuration
|
48
48
|
|
data/docs/style-guide.md
CHANGED
@@ -9,10 +9,4 @@ We use instance vars only:
|
|
9
9
|
|
10
10
|
For everything else we use proper getters / setters.
|
11
11
|
|
12
|
-
If possible those should be private.
|
13
|
-
|
14
|
-
```Ruby
|
15
|
-
private_attr_reader :configuration
|
16
|
-
private_attr_writer :failure_message
|
17
|
-
private_attr_accessor :examiner
|
18
|
-
```
|
12
|
+
If possible those should be private.
|
data/lib/reek/ast/node.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'private_attr/everywhere'
|
2
1
|
require_relative '../cli/silencer'
|
3
2
|
|
4
3
|
Reek::CLI::Silencer.silently do
|
@@ -12,7 +11,6 @@ module Reek
|
|
12
11
|
#
|
13
12
|
class Node < ::Parser::AST::Node
|
14
13
|
attr_reader :parent
|
15
|
-
private_attr_reader :comments
|
16
14
|
|
17
15
|
def initialize(type, children = [], options = {})
|
18
16
|
@comments = options.fetch(:comments, [])
|
@@ -109,14 +107,14 @@ module Reek
|
|
109
107
|
each_sexp do |elem|
|
110
108
|
elem.look_for_type(target_type, ignoring, &blk) unless ignoring.include?(elem.type)
|
111
109
|
end
|
112
|
-
|
110
|
+
yield self if type == target_type
|
113
111
|
end
|
114
112
|
|
115
113
|
# See ".find_nodes" for documentation.
|
116
114
|
def look_for_types(target_types, ignoring = [], &blk)
|
117
115
|
return if ignoring.include?(type)
|
118
116
|
if target_types.include? type
|
119
|
-
|
117
|
+
yield self
|
120
118
|
else
|
121
119
|
each_sexp do |elem|
|
122
120
|
elem.look_for_types(target_types, ignoring, &blk)
|
@@ -126,6 +124,8 @@ module Reek
|
|
126
124
|
|
127
125
|
private
|
128
126
|
|
127
|
+
attr_reader :comments
|
128
|
+
|
129
129
|
def each_sexp
|
130
130
|
children.each { |elem| yield elem if elem.is_a? ::Parser::AST::Node }
|
131
131
|
end
|
data/lib/reek/ast/object_refs.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'private_attr/everywhere'
|
2
|
-
|
3
1
|
module Reek
|
4
2
|
module AST
|
5
3
|
#
|
@@ -7,7 +5,7 @@ module Reek
|
|
7
5
|
# of an abstract syntax tree.
|
8
6
|
#
|
9
7
|
class ReferenceCollector
|
10
|
-
STOP_NODES = [:class, :module, :def, :defs]
|
8
|
+
STOP_NODES = [:class, :module, :def, :defs].freeze
|
11
9
|
|
12
10
|
def initialize(ast)
|
13
11
|
@ast = ast
|
@@ -19,7 +17,7 @@ module Reek
|
|
19
17
|
|
20
18
|
private
|
21
19
|
|
22
|
-
|
20
|
+
attr_reader :ast
|
23
21
|
|
24
22
|
def explicit_self_calls
|
25
23
|
[:self, :super, :zsuper, :ivar, :ivasgn].flat_map do |node_type|
|
data/lib/reek/cli/application.rb
CHANGED
@@ -13,9 +13,6 @@ module Reek
|
|
13
13
|
class Application
|
14
14
|
attr_reader :configuration
|
15
15
|
|
16
|
-
private_attr_accessor :status
|
17
|
-
private_attr_reader :command, :options
|
18
|
-
|
19
16
|
def initialize(argv)
|
20
17
|
@options = configure_options(argv)
|
21
18
|
@status = options.success_exit_code
|
@@ -25,19 +22,13 @@ module Reek
|
|
25
22
|
|
26
23
|
def execute
|
27
24
|
command.execute self
|
28
|
-
status
|
29
|
-
end
|
30
|
-
|
31
|
-
def report_success
|
32
|
-
self.status = options.success_exit_code
|
33
|
-
end
|
34
|
-
|
35
|
-
def report_smells
|
36
|
-
self.status = options.failure_exit_code
|
37
25
|
end
|
38
26
|
|
39
27
|
private
|
40
28
|
|
29
|
+
attr_accessor :status
|
30
|
+
attr_reader :command, :options
|
31
|
+
|
41
32
|
def configure_options(argv)
|
42
33
|
Options.new(argv).parse
|
43
34
|
rescue OptionParser::InvalidOption => error
|
data/lib/reek/cli/command.rb
CHANGED
@@ -1,20 +1,16 @@
|
|
1
|
-
require 'private_attr/everywhere'
|
2
|
-
|
3
1
|
module Reek
|
4
2
|
module CLI
|
5
3
|
#
|
6
4
|
# Base class for all commands
|
7
5
|
#
|
8
6
|
class Command
|
9
|
-
attr_reader :options
|
10
|
-
|
11
7
|
def initialize(options)
|
12
8
|
@options = options
|
13
9
|
end
|
14
10
|
|
15
11
|
private
|
16
12
|
|
17
|
-
|
13
|
+
attr_reader :options
|
18
14
|
end
|
19
15
|
end
|
20
16
|
end
|
@@ -10,8 +10,7 @@ module Reek
|
|
10
10
|
class OptionInterpreter
|
11
11
|
include Input
|
12
12
|
extend Forwardable
|
13
|
-
def_delegators :options, :smells_to_detect
|
14
|
-
private_attr_reader :argv, :options
|
13
|
+
def_delegators :options, :smells_to_detect, :success_exit_code, :failure_exit_code
|
15
14
|
|
16
15
|
def initialize(options)
|
17
16
|
@options = options
|
@@ -50,6 +49,10 @@ module Reek
|
|
50
49
|
def sort_by_issue_count
|
51
50
|
options.sorting == :smelliness
|
52
51
|
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
attr_reader :argv, :options
|
53
56
|
end
|
54
57
|
end
|
55
58
|
end
|
@@ -12,12 +12,16 @@ module Reek
|
|
12
12
|
options.sources.each do |source|
|
13
13
|
reporter.add_examiner Examiner.new(source, smell_names, configuration: app.configuration)
|
14
14
|
end
|
15
|
-
reporter.smells? ? app.report_smells : app.report_success
|
16
15
|
reporter.show
|
16
|
+
result_code
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
20
20
|
|
21
|
+
def result_code
|
22
|
+
reporter.smells? ? options.failure_exit_code : options.success_exit_code
|
23
|
+
end
|
24
|
+
|
21
25
|
def reporter
|
22
26
|
@reporter ||= options.reporter
|
23
27
|
end
|
data/lib/reek/code_comment.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'yaml'
|
2
|
-
require 'private_attr/everywhere'
|
3
2
|
|
4
3
|
module Reek
|
5
4
|
#
|
@@ -9,11 +8,10 @@ module Reek
|
|
9
8
|
class CodeComment
|
10
9
|
CONFIGURATION_REGEX = /:reek:(\w+)(:\s*\{.*?\})?/
|
11
10
|
SANITIZE_REGEX = /(#|\n|\s)+/ # Matches '#', newlines and > 1 whitespaces.
|
12
|
-
DISABLE_DETECTOR_CONFIGURATION = ': { enabled: false }'
|
11
|
+
DISABLE_DETECTOR_CONFIGURATION = ': { enabled: false }'.freeze
|
13
12
|
MINIMUM_CONTENT_LENGTH = 2
|
14
13
|
|
15
14
|
attr_reader :config
|
16
|
-
private_attr_reader :original_comment
|
17
15
|
|
18
16
|
#
|
19
17
|
# @param comment [String] - the original comment as found in the source code
|
@@ -35,6 +33,8 @@ module Reek
|
|
35
33
|
|
36
34
|
private
|
37
35
|
|
36
|
+
attr_reader :original_comment
|
37
|
+
|
38
38
|
def sanitized_comment
|
39
39
|
@sanitized_comment ||= original_comment.
|
40
40
|
gsub(CONFIGURATION_REGEX, '').
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'pathname'
|
2
|
-
require 'private_attr/everywhere'
|
3
2
|
require_relative './configuration_file_finder'
|
4
3
|
require_relative './configuration_validator'
|
5
4
|
require_relative './default_directive'
|
@@ -14,8 +13,7 @@ module Reek
|
|
14
13
|
# @public
|
15
14
|
class AppConfiguration
|
16
15
|
include ConfigurationValidator
|
17
|
-
EXCLUDE_PATHS_KEY = 'exclude_paths'
|
18
|
-
private_attr_writer :directory_directives, :default_directive, :excluded_paths
|
16
|
+
EXCLUDE_PATHS_KEY = 'exclude_paths'.freeze
|
19
17
|
|
20
18
|
# Instantiate a configuration via given path.
|
21
19
|
#
|
@@ -103,6 +101,8 @@ module Reek
|
|
103
101
|
|
104
102
|
private
|
105
103
|
|
104
|
+
attr_writer :directory_directives, :default_directive, :excluded_paths
|
105
|
+
|
106
106
|
def directory_directives
|
107
107
|
@directory_directives ||= {}.extend(DirectoryDirectives)
|
108
108
|
end
|